[addresses] only add village as city component if no city can be found in the area

This commit is contained in:
Al
2016-12-29 13:41:05 -05:00
parent 8080e16791
commit 21a2a7419a

View File

@@ -912,6 +912,8 @@ class AddressComponents(object):
is_japan = country == JAPAN
checked_first_suburb = False
first_village = None
for props, lat, lon, dist in self.places_index.nearest_points(latitude, longitude):
component = self.categorize_osm_component(country, props, containing_components)
@@ -919,9 +921,14 @@ class AddressComponents(object):
have_city = AddressFormatter.CITY in grouped_components
if (component == AddressFormatter.CITY or (component in city_replacements and not have_city)) and component not in grouped_components and (not have_sub_city or not self.osm_component_is_village(props)):
is_village = self.osm_component_is_village(props)
if (component == AddressFormatter.CITY or (component in city_replacements and not have_city)) and component not in grouped_components and not is_village:
grouped_components[component].append(props)
if is_village:
first_village = props
if is_japan and component == AddressFormatter.SUBURB and not checked_first_suburb:
existing = grouped_components[component]
for p in existing:
@@ -935,6 +942,11 @@ class AddressComponents(object):
grouped_components[component].append(props)
checked_first_suburb = True
have_city = AddressFormatter.CITY in grouped_components
if not have_city and first_village:
grouped_components[AddressFormatter.CITY].append(first_village)
def add_admin_boundaries(self, address_components,
osm_components,
country, language,