match_types for HERE metadata

This commit is contained in:
Juan Ignacio Sánchez Lara 2018-07-16 11:52:25 +02:00
parent f2197d4b2a
commit 0b635377ef
2 changed files with 17 additions and 3 deletions

View File

@ -13,6 +13,18 @@ PRECISION_BY_MATCH_TYPE = {
'pointAddress': PRECISION_PRECISE,
'interpolated': PRECISION_INTERPOLATED
}
MATCH_TYPE_BY_MATCH_LEVEL = {
'landmark': 'point_of_interest',
'country': 'country',
'state': 'state',
'county': 'county',
'city': 'locality',
'district': 'district',
'street': 'street',
'intersection': 'intersection',
'houseNumber': 'street_number',
'postalCode': 'postal_code'
}
class HereMapsGeocoder(Traceable):
@ -135,7 +147,9 @@ class HereMapsGeocoder(Traceable):
# See https://stackoverflow.com/questions/51285622/missing-matchtype-at-here-geocoding-responses
precision = PRECISION_BY_MATCH_TYPE[
result.get('MatchType', 'pointAddress')]
match_type = MATCH_TYPE_BY_MATCH_LEVEL.get(result['MatchLevel'], None)
return {
'relevance': result['Relevance'],
'precision': precision
'precision': precision,
'match_types': [match_type] if match_type else []
}

View File

@ -78,9 +78,9 @@ class TestStreetFunctionsSetUp(TestCase):
HERE_METADATAS = {
'Plaza España, Barcelona':
{'relevance': 1, 'precision': 'precise'},
{'relevance': 1, 'precision': 'precise', 'match_types': ['street']},
'Santiago Rusiñol 123, Valladolid':
{'relevance': 0.89, 'precision': 'precise'} # Wrong. See https://stackoverflow.com/questions/51285622/missing-matchtype-at-here-geocoding-responses
{'relevance': 0.89, 'precision': 'precise', 'match_types': ['street']} # Wrong. See https://stackoverflow.com/questions/51285622/missing-matchtype-at-here-geocoding-responses
}
TOMTOM_METADATAS = {