[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:
Al
2017-01-12 12:05:42 -05:00
parent f218e43adc
commit ba0f097d78
3 changed files with 19 additions and 1 deletions

View File

@@ -86,6 +86,15 @@ names:
probability: 0.09 probability: 0.09
- alternative: official_name - alternative: official_name
probability: 0.01 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 - id: 556706 # New Zealand
type: relation type: relation
default: name:en default: name:en

View File

@@ -110,6 +110,9 @@ class BoundaryNames(object):
def _string_as_regex(self, s): def _string_as_regex(self, s):
return safe_decode(s).replace(six.u('.'), six.u('\\.')) 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): def name_key_dist(self, props, component):
object_type = props.get('type') object_type = props.get('type')
object_id = safe_encode(props.get('id', '')) object_id = safe_encode(props.get('id', ''))

View File

@@ -606,7 +606,7 @@ class OSMAddressFormatter(object):
except Exception: except Exception:
return (), None return (), None
if 'name' not in tags: if 'name' not in tags and not any((t.startswith('name:') for t in tags)):
return (), None return (), None
osm_components = self.components.osm_reverse_geocoded_components(latitude, longitude) 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) 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'): 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: if more_than_one_official_language:
name = tags.get(name_tag) name = tags.get(name_tag)
language_suffix = '' language_suffix = ''