[fix] include all relation members from OSM in dependencies

This commit is contained in:
Al
2016-07-15 01:56:23 -04:00
parent cabe2c2930
commit dd20db85e1
2 changed files with 6 additions and 8 deletions

View File

@@ -259,12 +259,12 @@ class OSMPolygonReader(object):
inner_ways = []
admin_centers = []
for elem_id, role in deps:
if role in ('outer', ''):
for elem_id, elem_type, role in deps:
if role in ('outer', '') and elem_type == 'way':
outer_ways.append(elem_id)
elif role == 'inner':
elif role == 'inner' and elem_type == 'way':
inner_ways.append(elem_id)
elif role == 'admin_centre':
elif role == 'admin_centre' and elem_type == 'node':
val = self.nodes.get(long(elem_id))
if val is not None:
val['id'] = long(elem_id)

View File

@@ -82,10 +82,8 @@ def parse_osm(filename, allowed_types=ALL_OSM_TAGS, dependencies=False):
attrs[e.attrib['k']] = e.attrib['v']
elif dependencies and item_type == 'way' and e.tag == 'nd':
deps.append(long(e.attrib['ref']))
elif dependencies and item_type == 'relation' and e.tag == 'member' and \
e.attrib.get('type') in ('way', 'relation') and \
'role' in e.attrib:
deps.append((long(e.attrib['ref']), e.attrib['role']))
elif dependencies and item_type == 'relation' and e.tag == 'member' and 'role' in e.attrib:
deps.append((long(e.attrib['ref']), e.attrib.get('type'), e.attrib['role']))
key = elem_id if single_type else '{}:{}'.format(item_type, elem_id)
yield key, attrs, deps