From 854ac853a9fecd878f8926769a36d0b08c314f60 Mon Sep 17 00:00:00 2001 From: Al Date: Tue, 14 Feb 2017 03:53:22 -0500 Subject: [PATCH] [fix] OSM neighborhoods index check --- scripts/geodata/neighborhoods/reverse_geocode.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/geodata/neighborhoods/reverse_geocode.py b/scripts/geodata/neighborhoods/reverse_geocode.py index 7c2f5e60..5582e2fe 100644 --- a/scripts/geodata/neighborhoods/reverse_geocode.py +++ b/scripts/geodata/neighborhoods/reverse_geocode.py @@ -411,16 +411,19 @@ class NeighborhoodReverseGeocoder(RTreePolygonIndex): skip_node = False for boundaries in (existing_osm_boundaries, existing_neighborhood_boundaries): - for poly_index, osm_props in enumerate(existing_osm_boundaries): + for poly_index, osm_props in enumerate(boundaries): containing_component = None name = osm_props.get('name') # Only exact name matches here since we're comparins OSM to OSM if name and name.lower() != attrs.get('name', '').lower(): continue - containing_ids = [(boundary['type'], boundary['id']) for boundary in existing_osm_boundaries[poly_index + 1:]] + if boundaries is existing_neighborhood_boundaries: + containing_component = AddressFormatter.SUBURB + else: + containing_ids = [(boundary['type'], boundary['id']) for boundary in existing_osm_boundaries[poly_index + 1:]] - containing_component = osm_address_components.component_from_properties(country, osm_props, containing=containing_ids) + containing_component = osm_address_components.component_from_properties(country, osm_props, containing=containing_ids) if containing_component and containing_component != component_name and AddressFormatter.component_order[containing_component] <= AddressFormatter.component_order[AddressFormatter.CITY]: skip_node = True