match_types for Mapbox metadata
This commit is contained in:
@@ -25,6 +25,17 @@ TYPE_POINT = 'Point'
|
|||||||
|
|
||||||
EMPTY_RESPONSE = [[], {}]
|
EMPTY_RESPONSE = [[], {}]
|
||||||
|
|
||||||
|
MATCH_TYPE_BY_MATCH_LEVEL = {
|
||||||
|
'poi': 'point_of_interest',
|
||||||
|
'poi.landmark': 'point_of_interest',
|
||||||
|
'place': 'point_of_interest',
|
||||||
|
'country': 'country',
|
||||||
|
'region': 'state',
|
||||||
|
'locality': 'locality',
|
||||||
|
'district': 'district',
|
||||||
|
'address': 'street'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class MapboxGeocoder(Traceable):
|
class MapboxGeocoder(Traceable):
|
||||||
'''
|
'''
|
||||||
@@ -80,9 +91,12 @@ class MapboxGeocoder(Traceable):
|
|||||||
else:
|
else:
|
||||||
precision = PRECISION_PRECISE
|
precision = PRECISION_PRECISE
|
||||||
|
|
||||||
|
match_types = [MATCH_TYPE_BY_MATCH_LEVEL.get(match_level, None)
|
||||||
|
for match_level in result['place_type']]
|
||||||
return {
|
return {
|
||||||
'relevance': self._normalize_relevance(float(result['relevance'])),
|
'relevance': self._normalize_relevance(float(result['relevance'])),
|
||||||
'precision': precision
|
'precision': precision,
|
||||||
|
'match_types': filter(None, match_types)
|
||||||
}
|
}
|
||||||
|
|
||||||
def _normalize_relevance(self, relevance):
|
def _normalize_relevance(self, relevance):
|
||||||
|
|||||||
@@ -92,9 +92,9 @@ class TestStreetFunctionsSetUp(TestCase):
|
|||||||
|
|
||||||
MAPBOX_METADATAS = {
|
MAPBOX_METADATAS = {
|
||||||
'Plaza España, Barcelona':
|
'Plaza España, Barcelona':
|
||||||
{'relevance': 0.666, 'precision': 'precise'},
|
{'relevance': 0.666, 'precision': 'precise', 'match_types': ['point_of_interest']},
|
||||||
'Santiago Rusiñol 123, Valladolid':
|
'Santiago Rusiñol 123, Valladolid':
|
||||||
{'relevance': 0.666, 'precision': 'precise'} # TODO: wrong
|
{'relevance': 0.666, 'precision': 'precise', 'match_types': ['point_of_interest']} # TODO: wrong
|
||||||
}
|
}
|
||||||
|
|
||||||
METADATAS = {
|
METADATAS = {
|
||||||
|
|||||||
Reference in New Issue
Block a user