[fix] make city more likely, eliminate admin components from the set if they don't have names

This commit is contained in:
Al
2016-12-22 22:56:48 -05:00
parent 5ed4f35eac
commit 481bc248a1

View File

@@ -810,13 +810,14 @@ class AddressComponents(object):
for props, lat, lon, dist in self.places_index.nearest_points(latitude, longitude):
component = self.categorize_osm_component(country, props, containing_components)
have_sub_city = AddressFormatter.SUBURB in grouped_components or AddressFormatter.CITY_DISTRICT in grouped_components
have_sub_city = any((key in grouped_components and key in city_replacements for key in (AddressFormatter.SUBURB, AddressFormatter.CITY_DISTRICT)))
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)):
grouped_components[component].append(props)
def add_admin_boundaries(self, address_components,
osm_components,
country, language,
@@ -853,6 +854,9 @@ class AddressComponents(object):
for i, props in enumerate(osm_components):
containing_components = osm_components[i + 1:]
if 'name' not in props:
continue
component = self.categorize_osm_component(country, props, containing_components)
if component is None:
continue