[osm/places] adding option to only format place tags for city and smaller admins, using for polygons as larger polys should be included elsewhere anyway
This commit is contained in:
@@ -544,7 +544,7 @@ class OSMAddressFormatter(object):
|
|||||||
|
|
||||||
return postal_codes
|
return postal_codes
|
||||||
|
|
||||||
def node_place_tags(self, tags):
|
def node_place_tags(self, tags, city_or_below=False):
|
||||||
try:
|
try:
|
||||||
latitude, longitude = latlon_to_decimal(tags['lat'], tags['lon'])
|
latitude, longitude = latlon_to_decimal(tags['lat'], tags['lon'])
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -582,6 +582,9 @@ class OSMAddressFormatter(object):
|
|||||||
return (), None
|
return (), None
|
||||||
component_index = self.boundary_component_priorities.get(component_name)
|
component_index = self.boundary_component_priorities.get(component_name)
|
||||||
|
|
||||||
|
if city_or_below and (not component_index or component_index <= self.boundary_component_priorities[AddressFormatter.CITY]):
|
||||||
|
return (), None
|
||||||
|
|
||||||
if component_index:
|
if component_index:
|
||||||
revised_osm_components = []
|
revised_osm_components = []
|
||||||
|
|
||||||
@@ -1255,7 +1258,7 @@ class OSMAddressFormatter(object):
|
|||||||
lon = point.x
|
lon = point.x
|
||||||
tags['lat'] = lat
|
tags['lat'] = lat
|
||||||
tags['lon'] = lon
|
tags['lon'] = lon
|
||||||
place_tags, country = self.node_place_tags(tags)
|
place_tags, country = self.node_place_tags(tags, city_or_below=True)
|
||||||
for address_components, language, is_default in place_tags:
|
for address_components, language, is_default in place_tags:
|
||||||
addresses = self.formatted_places(address_components, country, language)
|
addresses = self.formatted_places(address_components, country, language)
|
||||||
if language is None:
|
if language is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user