[osm] venue names
This commit is contained in:
@@ -269,10 +269,10 @@ class AddressComponents(object):
|
|||||||
key = ''.join((raw_key, suffix)) if ':' not in raw_key else raw_key
|
key = ''.join((raw_key, suffix)) if ':' not in raw_key else raw_key
|
||||||
return key, raw_key
|
return key, raw_key
|
||||||
|
|
||||||
def all_names(self, props, languages):
|
def all_names(self, props, languages, keys=ALL_OSM_NAME_KEYS):
|
||||||
names = set()
|
names = set()
|
||||||
for k, v in six.iteritems(props):
|
for k, v in six.iteritems(props):
|
||||||
if k in self.ALL_OSM_NAME_KEYS:
|
if k in keys:
|
||||||
names.add(v)
|
names.add(v)
|
||||||
elif ':' in k:
|
elif ':' in k:
|
||||||
k, qual = k.split(':', 1)
|
k, qual = k.split(':', 1)
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class OSMAddressFormatter(object):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def venue_names(self, props):
|
def venue_names(self, props, languages):
|
||||||
'''
|
'''
|
||||||
Venue names
|
Venue names
|
||||||
-----------
|
-----------
|
||||||
@@ -201,12 +201,7 @@ class OSMAddressFormatter(object):
|
|||||||
With a certain probability, add None to the list so we drop the name
|
With a certain probability, add None to the list so we drop the name
|
||||||
'''
|
'''
|
||||||
|
|
||||||
venue_names = []
|
return self.components.all_names(props, languages, keys=('name', 'alt_name', 'loc_name', 'int_name', 'old_name'))
|
||||||
for key in ('name', 'alt_name', 'loc_name', 'int_name', 'old_name'):
|
|
||||||
venue_name = props.get(key)
|
|
||||||
if venue_name:
|
|
||||||
venue_names.append(venue_name)
|
|
||||||
return venue_names
|
|
||||||
|
|
||||||
def formatted_addresses_with_venue_names(self, address_components, venue_names, country, language=None, tag_components=True, minimal_only=False):
|
def formatted_addresses_with_venue_names(self, address_components, venue_names, country, language=None, tag_components=True, minimal_only=False):
|
||||||
# Since venue names are only one-per-record, this wrapper will try them all (name, alt_name, etc.)
|
# Since venue names are only one-per-record, this wrapper will try them all (name, alt_name, etc.)
|
||||||
@@ -326,8 +321,6 @@ class OSMAddressFormatter(object):
|
|||||||
returned.
|
returned.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
venue_names = self.venue_names(tags) or []
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
latitude, longitude = latlon_to_decimal(tags['lat'], tags['lon'])
|
latitude, longitude = latlon_to_decimal(tags['lat'], tags['lon'])
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -342,6 +335,9 @@ class OSMAddressFormatter(object):
|
|||||||
if not address_components:
|
if not address_components:
|
||||||
return None, None, None
|
return None, None, None
|
||||||
|
|
||||||
|
languages = country_languages[country].keys()
|
||||||
|
venue_names = self.venue_names(tags, languages) or []
|
||||||
|
|
||||||
# Abbreviate the street name with random probability
|
# Abbreviate the street name with random probability
|
||||||
street_name = address_components.get(AddressFormatter.ROAD)
|
street_name = address_components.get(AddressFormatter.ROAD)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user