[openaddresses] countries are known a priori, so if the boundaries don't quite line up with OSM, use the country from the path
This commit is contained in:
@@ -16,6 +16,7 @@ from geodata.address_formatting.formatter import AddressFormatter
|
|||||||
from geodata.addresses.components import AddressComponents
|
from geodata.addresses.components import AddressComponents
|
||||||
from geodata.countries.names import country_names
|
from geodata.countries.names import country_names
|
||||||
from geodata.encoding import safe_decode, safe_encode
|
from geodata.encoding import safe_decode, safe_encode
|
||||||
|
from geodata.i18n.languages import get_country_languages
|
||||||
from geodata.language_id.disambiguation import UNKNOWN_LANGUAGE
|
from geodata.language_id.disambiguation import UNKNOWN_LANGUAGE
|
||||||
from geodata.math.sampling import cdf, weighted_choice
|
from geodata.math.sampling import cdf, weighted_choice
|
||||||
from geodata.openaddresses.config import openaddresses_config
|
from geodata.openaddresses.config import openaddresses_config
|
||||||
@@ -315,8 +316,9 @@ class OpenAddressesFormatter(object):
|
|||||||
|
|
||||||
if components:
|
if components:
|
||||||
country, candidate_languages = self.country_rtree.country_and_languages(latitude, longitude)
|
country, candidate_languages = self.country_rtree.country_and_languages(latitude, longitude)
|
||||||
if not (country and candidate_languages):
|
if not (country and candidate_languages) or country != country_dir:
|
||||||
continue
|
country = country_dir
|
||||||
|
candidate_languages = get_country_languages(country)
|
||||||
|
|
||||||
if language is None:
|
if language is None:
|
||||||
language = AddressComponents.address_language(components, candidate_languages)
|
language = AddressComponents.address_language(components, candidate_languages)
|
||||||
|
|||||||
Reference in New Issue
Block a user