[neighborhoods] components are now pre-calculated by CTH index
This commit is contained in:
@@ -430,12 +430,11 @@ class NeighborhoodReverseGeocoder(RTreePolygonIndex):
|
|||||||
if skip_node:
|
if skip_node:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
containing_ids = [(boundary['type'], boundary['id']) for boundary in existing_osm_boundaries]
|
|
||||||
component = osm_address_components.component_from_properties(country, attrs, containing=containing_ids)
|
|
||||||
attrs['component'] = component
|
|
||||||
|
|
||||||
if idx is cth:
|
if idx is cth:
|
||||||
attrs['polygon_type'] = 'neighborhood'
|
if attrs['component'] == AddressFormatter.SUBURB:
|
||||||
|
attrs['polygon_type'] = 'neighborhood'
|
||||||
|
else:
|
||||||
|
attrs['polygon_type'] = 'local_admin'
|
||||||
source = 'osm_cth'
|
source = 'osm_cth'
|
||||||
else:
|
else:
|
||||||
level = props.get(QuattroshapesReverseGeocoder.LEVEL, None)
|
level = props.get(QuattroshapesReverseGeocoder.LEVEL, None)
|
||||||
@@ -446,6 +445,10 @@ class NeighborhoodReverseGeocoder(RTreePolygonIndex):
|
|||||||
else:
|
else:
|
||||||
attrs['polygon_type'] = 'local_admin'
|
attrs['polygon_type'] = 'local_admin'
|
||||||
|
|
||||||
|
containing_ids = [(boundary['type'], boundary['id']) for boundary in existing_osm_boundaries]
|
||||||
|
component = osm_address_components.component_from_properties(country, attrs, containing=containing_ids)
|
||||||
|
attrs['component'] = component
|
||||||
|
|
||||||
attrs['source'] = source
|
attrs['source'] = source
|
||||||
index.index_polygon(poly)
|
index.index_polygon(poly)
|
||||||
index.add_polygon(poly, attrs)
|
index.add_polygon(poly, attrs)
|
||||||
@@ -462,19 +465,26 @@ class NeighborhoodReverseGeocoder(RTreePolygonIndex):
|
|||||||
if idx.matched[i]:
|
if idx.matched[i]:
|
||||||
continue
|
continue
|
||||||
props['source'] = source
|
props['source'] = source
|
||||||
if idx is cth or props.get(QuattroshapesReverseGeocoder.LEVEL, None) == 'neighborhood':
|
if idx is cth:
|
||||||
|
component = props['component']
|
||||||
|
if component == AddressFormatter.SUBURB:
|
||||||
|
props['polygon_type'] = 'neighborhood'
|
||||||
|
elif component == AddressFormatter.CITY_DISTRICT:
|
||||||
|
props['polygon_type'] = 'local_admin'
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
elif props.get(QuattroshapesReverseGeocoder.LEVEL, None) == 'neighborhood':
|
||||||
component = AddressFormatter.SUBURB
|
component = AddressFormatter.SUBURB
|
||||||
if source == 'quattroshapes':
|
name = props.get('name')
|
||||||
name = props.get('name')
|
if not name:
|
||||||
if not name:
|
continue
|
||||||
continue
|
for pattern, repl in cls.regex_replacements:
|
||||||
for pattern, repl in cls.regex_replacements:
|
name = pattern.sub(repl, name)
|
||||||
name = pattern.sub(repl, name)
|
|
||||||
|
|
||||||
props['name'] = name
|
props['name'] = name
|
||||||
|
|
||||||
if cls.quattroshapes_city_district_regex.match(name):
|
if cls.quattroshapes_city_district_regex.match(name):
|
||||||
component = AddressFormatter.CITY_DISTRICT
|
component = AddressFormatter.CITY_DISTRICT
|
||||||
|
|
||||||
props['component'] = component
|
props['component'] = component
|
||||||
props['polygon_type'] = 'neighborhood'
|
props['polygon_type'] = 'neighborhood'
|
||||||
|
|||||||
Reference in New Issue
Block a user