Solved data conversion issues
This commit is contained in:
@@ -92,7 +92,7 @@ class MapboxIsolines():
|
||||
|
||||
return self.calculate_isochrone(origin=origin,
|
||||
time_ranges=[time_range],
|
||||
profile=profile)
|
||||
profile=profile)[0].coordinates
|
||||
|
||||
def calculate_isoline(self, origin, isorange, upper_rmax,
|
||||
cost_method=_calculate_matrix_cost,
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
MODE_TO_MAPBOX_PROFILE = {
|
||||
'car': 'driving',
|
||||
'walk': 'walking',
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import plpy
|
||||
|
||||
|
||||
def country_to_iso3(country):
|
||||
""" Convert country to its iso3 code """
|
||||
if not country:
|
||||
return None
|
||||
|
||||
try:
|
||||
country_plan = plpy.prepare("SELECT adm0_a3 as iso3 FROM admin0_synonyms WHERE lower(regexp_replace($1, " \
|
||||
"'[^a-zA-Z\u00C0-\u00ff]+', '', 'g'))::text = name_; ", ['text'])
|
||||
country_result = plpy.execute(country_plan, [country], 1)
|
||||
if country_result:
|
||||
return country_result[0]['iso3']
|
||||
else:
|
||||
return None
|
||||
except BaseException as e:
|
||||
plpy.warning("Can't get the iso3 code from {0}: {1}".format(country, e))
|
||||
return None
|
||||
@@ -24,3 +24,8 @@ class MapboxGeocoderTestCase(unittest.TestCase):
|
||||
|
||||
self.assertEqual(place[0], WELL_KNOWN_LONGITUDE)
|
||||
self.assertEqual(place[1], WELL_KNOWN_LATITUDE)
|
||||
|
||||
def test_valid_request_namedplace(self):
|
||||
place = self.geocoder.geocode(searchtext='Barcelona')
|
||||
|
||||
assert place
|
||||
|
||||
Reference in New Issue
Block a user