source: subversion/applications/utils/export/tiledata2/enums.py @ 22219

Last change on this file since 22219 was 9920, checked in by ojw, 11 years ago

enums

File size: 2.3 KB
Line 
1
2class makeEnums:
3
4  def addEquivalent(self, mainTag, k, v):
5    self.equiv.append({
6      'fn': lambda tag: tag.get(k,'')==v,
7      'equiv': mainTag})
8   
9  def addSimple(self, name, k, v, options={}):
10    self.enums[name] = {
11      'name':name,
12      'fn': lambda tag: tag.get(k,'') == v}
13   
14    if(options.has_key('linkroads')):
15      self.addEquivalent(name, k, v+"_link")
16
17  def __init__(self):
18    self.enums = {}
19    self.equiv = []
20
21    # Big roads
22    for t in ('motorway','primary','trunk','secondary','tertiary'):
23      self.addSimple(t, 'highway', t, {'linkroads':True})
24     
25    # Normal roads
26    for t in ('unclassified','track','service'):
27      self.addSimple(t,'highway',t)
28
29    # Things which aren't much different from normal roads
30    for t in ('residential', 'road', 'living_street', 'raceway', 'urban'):
31      self.addEquivalent('unclassified', 'highway', t)
32    self.addEquivalent('track', 'highway', 'byway')
33
34    # Paths
35    for t in ('footway','bridleway','cycleway'):
36      self.addSimple(t,'highway',t)
37    for t in ('footpath','pedestrian','path','steps'):
38      self.addEquivalent('footway', 'highway', t)
39   
40    # Rail
41    self.addSimple('railway','railway','rail')
42    self.addSimple('subway','railway','subway')
43    for t in ('light_rail', 'disused', 'abandoned', 'narrow_gauge', 'preserved'):
44      self.addEquivalent('railway', 'railway', t)
45   
46    # Water
47    for t in ('river', 'canal', 'stream'):
48      self.addSimple(t,'waterway',t)
49    self.addEquivalent('stream', 'waterway', 'drain')
50
51    # Utilities
52    self.addSimple('powerline','power','line')
53    self.addSimple('pipeline','man_made','pipeline')
54
55    # Airports
56    self.addSimple('runway','aeroway','runway')
57    self.addSimple('runway','aeroway','taxiway')
58
59    # Wires
60    self.addSimple('aerialway', 'aerialway','cable_car')
61    for t in ('chair_lift','drag_lift'):
62      self.addEquivalent('aerialway', 'aerialway', t)
63
64    # Walls
65    self.addSimple('wall','man_made','wall')
66    for t in ('harbour_wall', 'city_wall', 'breakwater'):
67      self.addEquivalent('wall', 'man_made', t)
68    self.addEquivalent('wall', 'barrier', 'fence')
69
70    # Natural features
71    for t in ('cliff', 'coastline'):
72      self.addSimple(t,'natural', t)
73   
74
75if(__name__ == "__main__"):
76  a = makeEnums()
77  for name in sorted(a.enums.keys()):
78    print name
Note: See TracBrowser for help on using the repository browser.