-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenums.py
78 lines (60 loc) · 2.29 KB
/
enums.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
78
class makeEnums:
def addEquivalent(self, mainTag, k, v):
self.equiv.append({
'fn': lambda tag: tag.get(k,'')==v,
'equiv': mainTag})
def addSimple(self, name, k, v, options={}):
self.enums[name] = {
'name':name,
'fn': lambda tag: tag.get(k,'') == v}
if(options.has_key('linkroads')):
self.addEquivalent(name, k, v+"_link")
def __init__(self):
self.enums = {}
self.equiv = []
# Big roads
for t in ('motorway','primary','trunk','secondary','tertiary'):
self.addSimple(t, 'highway', t, {'linkroads':True})
# Normal roads
for t in ('unclassified','track','service'):
self.addSimple(t,'highway',t)
# Things which aren't much different from normal roads
for t in ('residential', 'road', 'living_street', 'raceway', 'urban'):
self.addEquivalent('unclassified', 'highway', t)
self.addEquivalent('track', 'highway', 'byway')
# Paths
for t in ('footway','bridleway','cycleway'):
self.addSimple(t,'highway',t)
for t in ('footpath','pedestrian','path','steps'):
self.addEquivalent('footway', 'highway', t)
# Rail
self.addSimple('railway','railway','rail')
self.addSimple('subway','railway','subway')
for t in ('light_rail', 'disused', 'abandoned', 'narrow_gauge', 'preserved'):
self.addEquivalent('railway', 'railway', t)
# Water
for t in ('river', 'canal', 'stream'):
self.addSimple(t,'waterway',t)
self.addEquivalent('stream', 'waterway', 'drain')
# Utilities
self.addSimple('powerline','power','line')
self.addSimple('pipeline','man_made','pipeline')
# Airports
self.addSimple('runway','aeroway','runway')
self.addSimple('runway','aeroway','taxiway')
# Wires
self.addSimple('aerialway', 'aerialway','cable_car')
for t in ('chair_lift','drag_lift'):
self.addEquivalent('aerialway', 'aerialway', t)
# Walls
self.addSimple('wall','man_made','wall')
for t in ('harbour_wall', 'city_wall', 'breakwater'):
self.addEquivalent('wall', 'man_made', t)
self.addEquivalent('wall', 'barrier', 'fence')
# Natural features
for t in ('cliff', 'coastline'):
self.addSimple(t,'natural', t)
if(__name__ == "__main__"):
a = makeEnums()
for name in sorted(a.enums.keys()):
print name