-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransport_modes.py
77 lines (73 loc) · 2.36 KB
/
transport_modes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class TransportModesProvider(object):
TRANSPORT_MODES = {
'0': None,
# High speed train
'1': {
'node': [('railway','station'),('train','yes')],
'way': ('railway','rail'),
'relation': ('route','train')
},
# Intercity train
'2': {
'node': [('railway','station'),('train','yes')],
'way': ('railway','rail'),
'relation': ('route','train')
},
# Commuter rail
'3': {
'node': [('railway','station'),('train','yes')],
'way': ('railway','rail'),
'relation': ('route','train')
},
# Metro/Subway: default
'4': {
'node':[('railway','station'),('subway','yes')],
'way': [('railway','subway'),('tunnel','yes')],
'relation': ('route','subway')
},
# Light rail
'5': {
'node':[('railway','station'),('light_rail','yes')],
'way': ('railway','light_rail'),
'relation': ('route','light_rail')
},
# BRT
'6': {
'node':('highway','bus_stop'),
'way': ('busway','lane'),
'relation': ('route','bus')
},
# People mover
'7': None,
# Bus
'8': {
'node':('highway','bus_stop'),
'way': None,
'relation': ('route','bus')
},
# Tram
'9': {
'node':[('railway','station'),('tram','yes')],
'way': ('railway','tram'),
'relation': ('route','tram')
},
# Ferry
'10': {
'node':[('ferry','yes'),('amenity','ferry_terminal')],
'way': ('route','ferry'),
'relation': ('route','ferry')
}
}
def __init__(self, lines_info):
self._lines = {}
for line in lines_info:
self._lines[line['url_name']] = line
def tags(self, line_url_name, element_type):
transport_mode_id = self._lines[line_url_name]['transport_mode_id']
mode = self.TRANSPORT_MODES[str(transport_mode_id)] or self.TRANSPORT_MODES['4']
tags = mode[element_type]
if not isinstance(tags, list):
tags = [tags]
# We remove Nones from list
tags = list(filter(None, tags))
return tags