regions.py

changeset 4
ac067a42b00f
parent 2
7378b802ddf8
equal deleted inserted replaced
3:10ce28475e9c 4:ac067a42b00f
51 root = tree.getroot() 51 root = tree.getroot()
52 nodes = parse_nodes(root) 52 nodes = parse_nodes(root)
53 regions = dict() 53 regions = dict()
54 extra_shapes = list() 54 extra_shapes = list()
55 for way in parse_boundaries(root, nodes = nodes): 55 for way in parse_boundaries(root, nodes = nodes):
56 if 'boundary' in way and 'ref' in way: 56 if 'boundary' in way and 'municipality' in way and 'name:fi' in way:
57 def clean(x):
58 return x.replace('/', '').replace(';', '')
59 way['ref'] = str.format(
60 '{municipality}/{name}',
61 municipality = str.upper(clean(way['municipality'])),
62 name = clean(way['name:fi']),
63 )
57 # defines a region 64 # defines a region
58 way['via_factor'] = int(way.get('via_factor', 1)) 65 way['via_factor'] = int(way.get('via_factor', 1))
59 if way['ref'] in regions: 66 if way['ref'] in regions:
60 raise ValueError(str.format( 67 raise ValueError(str.format(
61 'Region {ref} defined twice', 68 'Region {ref} defined twice',

mercurial