[places] adding section called city_replacements to places config, for countries where something like the state_district/county, suburb or city_district should stand in for the city when one cannot be reverse geocoded (unincorporated county addresses, etc.)
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
# and standalone place queries)
|
# and standalone place queries)
|
||||||
|
|
||||||
global:
|
global:
|
||||||
|
city_replacements: []
|
||||||
# Probability of including individual components
|
# Probability of including individual components
|
||||||
components:
|
components:
|
||||||
suburb:
|
suburb:
|
||||||
@@ -61,6 +62,10 @@ countries:
|
|||||||
|
|
||||||
# Australia
|
# Australia
|
||||||
au:
|
au:
|
||||||
|
city_replacements:
|
||||||
|
- suburb
|
||||||
|
- city_district
|
||||||
|
- state_district
|
||||||
components:
|
components:
|
||||||
suburb:
|
suburb:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -84,6 +89,10 @@ countries:
|
|||||||
|
|
||||||
# Brazil
|
# Brazil
|
||||||
br:
|
br:
|
||||||
|
city_replacements:
|
||||||
|
- suburb
|
||||||
|
- city_district
|
||||||
|
- state_district
|
||||||
components:
|
components:
|
||||||
suburb:
|
suburb:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -102,6 +111,10 @@ countries:
|
|||||||
|
|
||||||
# Canada
|
# Canada
|
||||||
ca:
|
ca:
|
||||||
|
city_replacements:
|
||||||
|
- suburb
|
||||||
|
- city_district
|
||||||
|
- state_district
|
||||||
components:
|
components:
|
||||||
suburb:
|
suburb:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -130,6 +143,10 @@ countries:
|
|||||||
|
|
||||||
# United Kingdom
|
# United Kingdom
|
||||||
gb:
|
gb:
|
||||||
|
city_replacements:
|
||||||
|
- suburb
|
||||||
|
- city_district
|
||||||
|
- state_district
|
||||||
components:
|
components:
|
||||||
state_district:
|
state_district:
|
||||||
probability: 0.15
|
probability: 0.15
|
||||||
@@ -216,6 +233,9 @@ countries:
|
|||||||
|
|
||||||
# Mexico
|
# Mexico
|
||||||
mx:
|
mx:
|
||||||
|
city_replacements:
|
||||||
|
- suburb
|
||||||
|
- city_district
|
||||||
components:
|
components:
|
||||||
suburb:
|
suburb:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -258,6 +278,10 @@ countries:
|
|||||||
|
|
||||||
# United States
|
# United States
|
||||||
us:
|
us:
|
||||||
|
city_replacements:
|
||||||
|
- suburb
|
||||||
|
- city_district
|
||||||
|
- state_district
|
||||||
# Definitions
|
# Definitions
|
||||||
new_york_county: &new_york_county
|
new_york_county: &new_york_county
|
||||||
id: 2552485 # New York County (Manhattan, NY)
|
id: 2552485 # New York County (Manhattan, NY)
|
||||||
|
|||||||
@@ -159,10 +159,14 @@ class PlaceConfig(object):
|
|||||||
|
|
||||||
new_components = components.copy()
|
new_components = components.copy()
|
||||||
|
|
||||||
|
city_replacements = set()
|
||||||
|
if AddressFormatter.CITY not in components:
|
||||||
|
city_replacements = set(self.get_property(('city_replacements', ), country=country))
|
||||||
|
|
||||||
for component in admin_components:
|
for component in admin_components:
|
||||||
include = self.include_component(component, containing_ids, country=country, population=population)
|
include = self.include_component(component, containing_ids, country=country, population=population)
|
||||||
|
|
||||||
if not include:
|
if not include and component not in city_replacements:
|
||||||
# Note: this check is for cities that have the same name as their admin
|
# Note: this check is for cities that have the same name as their admin
|
||||||
# areas e.g. Luxembourg, Luxembourg. In cases like this, if we were to drop
|
# areas e.g. Luxembourg, Luxembourg. In cases like this, if we were to drop
|
||||||
# city, we don't want to include country on its own. This should help the parser
|
# city, we don't want to include country on its own. This should help the parser
|
||||||
|
|||||||
Reference in New Issue
Block a user