From cd91068f0f1fab47072709d256c3841489691eb8 Mon Sep 17 00:00:00 2001 From: Al Date: Tue, 13 Dec 2016 02:28:59 -0500 Subject: [PATCH] [neighborhoods] fix neighborhoods index checks to include the borough points while still not making letting something like Santa Monica pass as a neighborhoods when it's a proper city --- scripts/geodata/neighborhoods/reverse_geocode.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/geodata/neighborhoods/reverse_geocode.py b/scripts/geodata/neighborhoods/reverse_geocode.py index 733ed1d8..e968fdc0 100644 --- a/scripts/geodata/neighborhoods/reverse_geocode.py +++ b/scripts/geodata/neighborhoods/reverse_geocode.py @@ -323,21 +323,22 @@ class NeighborhoodReverseGeocoder(RTreePolygonIndex): for name_key in OSM_NAME_TAGS: osm_names.extend([v for k, v in six.iteritems(attrs) if k.startswith('{}:'.format(name_key))]) - if component_name and component_name != AddressFormatter.SUBURB: + if component_name and component_name not in (AddressFormatter.SUBURB, AddressFormatter.CITY_DISTRICT): existing_osm_boundaries = osm_admin_rtree.point_in_poly(lat, lon, return_all=True) - containing_ids = [(boundary['type'], boundary['id']) for boundary in existing_osm_boundaries] skip_node = False - for props in existing_osm_boundaries: + for i, props in enumerate(existing_osm_boundaries): containing_component = None name = props.get('name') # Only exact name matches here since we're comparins OSM to OSM - if name and name == attrs.get('name'): + if name and name != attrs.get('name'): continue + containing_ids = [(boundary['type'], boundary['id']) for boundary in existing_osm_boundaries[i + 1:]] + containing_component = osm_address_components.component_from_properties(country, props, containing=containing_ids) - if containing_component and containing_component != AddressFormatter.SUBURB: + if containing_component and containing_component not in (AddressFormatter.SUBURB, AddressFormatter.CITY_DISTRICT): skip_node = True break # Skip this element