[osm] Adding new option to control whether we drop non-city OSM boundary names that have the same name as the enclosed city
This commit is contained in:
@@ -628,6 +628,7 @@ class AddressComponents(object):
|
||||
language_suffix='',
|
||||
random_key=True,
|
||||
always_use_full_names=False,
|
||||
drop_duplicate_city_names=True,
|
||||
):
|
||||
'''
|
||||
OSM boundaries
|
||||
@@ -668,7 +669,7 @@ class AddressComponents(object):
|
||||
|
||||
for k in (key, name_key, raw_key, raw_name_key):
|
||||
name = component_value.get(k)
|
||||
if name and not (name == existing_city_name and component != AddressFormatter.CITY):
|
||||
if name and not (name == existing_city_name and component != AddressFormatter.CITY and drop_duplicate_city_names):
|
||||
break
|
||||
# if we've checked all keys without finding a valid name, leave this component out
|
||||
else:
|
||||
|
||||
@@ -429,7 +429,8 @@ class OSMAddressFormatter(object):
|
||||
address_components = {component_name: name.strip()}
|
||||
self.components.add_admin_boundaries(address_components, osm_components, country, language,
|
||||
random_key=num_references > 1,
|
||||
language_suffix=language_suffix)
|
||||
language_suffix=language_suffix,
|
||||
drop_duplicate_city_names=False)
|
||||
|
||||
place_tags.append((address_components, None, True))
|
||||
|
||||
@@ -448,7 +449,8 @@ class OSMAddressFormatter(object):
|
||||
address_components = {component_name: name.strip()}
|
||||
self.components.add_admin_boundaries(address_components, osm_components, country, language,
|
||||
random_key=is_default,
|
||||
language_suffix=language_suffix)
|
||||
language_suffix=language_suffix,
|
||||
drop_duplicate_city_names=False)
|
||||
|
||||
place_tags.append((address_components, language, is_default))
|
||||
|
||||
@@ -466,7 +468,8 @@ class OSMAddressFormatter(object):
|
||||
self.components.add_admin_boundaries(address_components, osm_components, country, language,
|
||||
random_key=False,
|
||||
non_local_language=language,
|
||||
language_suffix=language_suffix)
|
||||
language_suffix=language_suffix,
|
||||
drop_duplicate_city_names=False)
|
||||
|
||||
place_tags.append((address_components, language, False))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user