[boundaries] adding check for valid name key in formatted places, and removing short_name from the Sao Paulo relation as well
This commit is contained in:
@@ -86,6 +86,15 @@ names:
|
||||
probability: 0.09
|
||||
- alternative: official_name
|
||||
probability: 0.01
|
||||
- id: 298285 # Sao Paulo (relation)
|
||||
type: relation
|
||||
default: name
|
||||
probability: 0.9
|
||||
alternatives:
|
||||
- alternative: alt_name
|
||||
probability: 0.09
|
||||
- alternative: official_name
|
||||
probability: 0.01
|
||||
- id: 556706 # New Zealand
|
||||
type: relation
|
||||
default: name:en
|
||||
|
||||
@@ -110,6 +110,9 @@ class BoundaryNames(object):
|
||||
def _string_as_regex(self, s):
|
||||
return safe_decode(s).replace(six.u('.'), six.u('\\.'))
|
||||
|
||||
def valid_name(self, object_type, object_id, name):
|
||||
return name in self.exceptions.get((object_type, object_id), ((), ()))[0]
|
||||
|
||||
def name_key_dist(self, props, component):
|
||||
object_type = props.get('type')
|
||||
object_id = safe_encode(props.get('id', ''))
|
||||
|
||||
@@ -606,7 +606,7 @@ class OSMAddressFormatter(object):
|
||||
except Exception:
|
||||
return (), None
|
||||
|
||||
if 'name' not in tags:
|
||||
if 'name' not in tags and not any((t.startswith('name:') for t in tags)):
|
||||
return (), None
|
||||
|
||||
osm_components = self.components.osm_reverse_geocoded_components(latitude, longitude)
|
||||
@@ -732,7 +732,13 @@ class OSMAddressFormatter(object):
|
||||
|
||||
revised_tags = self.fix_component_encodings(revised_tags)
|
||||
|
||||
object_type = tags.get('type')
|
||||
object_id = tags.get('id')
|
||||
|
||||
for name_tag in ('name', 'alt_name', 'loc_name', 'short_name', 'int_name', 'name:simple', 'official_name'):
|
||||
if not boundary_names.valid_name(object_type, object_id, name_tag):
|
||||
continue
|
||||
|
||||
if more_than_one_official_language:
|
||||
name = tags.get(name_tag)
|
||||
language_suffix = ''
|
||||
|
||||
Reference in New Issue
Block a user