[fix] putting the neighborhoods check after the dupe threshold check, as it's not really needed until then anyway
This commit is contained in:
@@ -366,35 +366,32 @@ class NeighborhoodReverseGeocoder(RTreePolygonIndex):
|
|||||||
if arg_max:
|
if arg_max:
|
||||||
ranks.append(arg_max)
|
ranks.append(arg_max)
|
||||||
|
|
||||||
if not ranks:
|
|
||||||
continue
|
|
||||||
|
|
||||||
existing_osm_boundaries = osm_admin_rtree.point_in_poly(lat, lon, return_all=True)
|
|
||||||
|
|
||||||
skip_node = False
|
|
||||||
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.lower() != attrs.get('name', ''.lower()):
|
|
||||||
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 != component_name and AddressFormatter.component_order[containing_component] <= AddressFormatter.component_order[AddressFormatter.CITY]:
|
|
||||||
skip_node = True
|
|
||||||
break
|
|
||||||
|
|
||||||
# Skip this element
|
|
||||||
if skip_node:
|
|
||||||
continue
|
|
||||||
|
|
||||||
ranks.sort(key=operator.itemgetter(0), reverse=True)
|
ranks.sort(key=operator.itemgetter(0), reverse=True)
|
||||||
if ranks and ranks[0][0] >= cls.DUPE_THRESHOLD:
|
if ranks and ranks[0][0] >= cls.DUPE_THRESHOLD:
|
||||||
score, props, poly, idx, i = ranks[0]
|
score, props, poly, idx, i = ranks[0]
|
||||||
|
|
||||||
|
existing_osm_boundaries = osm_admin_rtree.point_in_poly(lat, lon, return_all=True)
|
||||||
|
|
||||||
|
skip_node = False
|
||||||
|
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.lower() != attrs.get('name', ''.lower()):
|
||||||
|
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 != component_name and AddressFormatter.component_order[containing_component] <= AddressFormatter.component_order[AddressFormatter.CITY]:
|
||||||
|
skip_node = True
|
||||||
|
break
|
||||||
|
|
||||||
|
# Skip this element
|
||||||
|
if skip_node:
|
||||||
|
continue
|
||||||
|
|
||||||
containing_ids = [(boundary['type'], boundary['id']) for boundary in existing_osm_boundaries]
|
containing_ids = [(boundary['type'], boundary['id']) for boundary in existing_osm_boundaries]
|
||||||
component = osm_address_components.component_from_properties(country, props, containing=containing_ids)
|
component = osm_address_components.component_from_properties(country, props, containing=containing_ids)
|
||||||
attrs['component'] = component
|
attrs['component'] = component
|
||||||
|
|||||||
Reference in New Issue
Block a user