Fix empty component return in isolines
This commit is contained in:
@@ -77,8 +77,12 @@ class HereMapsRoutingIsoline:
|
|||||||
isolines_response = parsed_response['response']['isoline']
|
isolines_response = parsed_response['response']['isoline']
|
||||||
isolines = []
|
isolines = []
|
||||||
for isoline in isolines_response:
|
for isoline in isolines_response:
|
||||||
|
if not isoline['component']:
|
||||||
|
geom_value = []
|
||||||
|
else:
|
||||||
|
geom_value = isoline['component'][0]['shape']
|
||||||
isolines.append({'range': isoline['range'],
|
isolines.append({'range': isoline['range'],
|
||||||
'geom': isoline['component'][0]['shape']})
|
'geom': geom_value})
|
||||||
|
|
||||||
return isolines
|
return isolines
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,18 @@ import plpy
|
|||||||
|
|
||||||
def geo_polyline_to_multipolygon(polyline):
|
def geo_polyline_to_multipolygon(polyline):
|
||||||
"""Convert a HERE polyline shape to a PostGIS multipolygon"""
|
"""Convert a HERE polyline shape to a PostGIS multipolygon"""
|
||||||
coordinates = []
|
# In case we receive an empty polyline from here and we don't want to
|
||||||
for point in polyline:
|
# change this kind of thing in the extension sql
|
||||||
lat, lon = point.split(',')
|
if not polyline:
|
||||||
coordinates.append("%s %s" % (lon, lat))
|
sql = "SELECT ST_MPolyFromText(NULL, 4326) as geom"
|
||||||
wkt_coordinates = ','.join(coordinates)
|
else:
|
||||||
|
coordinates = []
|
||||||
|
for point in polyline:
|
||||||
|
lat, lon = point.split(',')
|
||||||
|
coordinates.append("%s %s" % (lon, lat))
|
||||||
|
wkt_coordinates = ','.join(coordinates)
|
||||||
|
|
||||||
|
sql = "SELECT ST_MPolyFromText('MULTIPOLYGON((({0})))', 4326) as geom".format(wkt_coordinates)
|
||||||
|
|
||||||
sql = "SELECT ST_MPolyFromText('MULTIPOLYGON((({0})))', 4326) as geom".format(wkt_coordinates)
|
|
||||||
geometry = plpy.execute(sql, 1)[0]['geom']
|
geometry = plpy.execute(sql, 1)[0]['geom']
|
||||||
|
|
||||||
return geometry
|
return geometry
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from setuptools import setup, find_packages
|
|||||||
setup(
|
setup(
|
||||||
name='cartodb_services',
|
name='cartodb_services',
|
||||||
|
|
||||||
version='0.7.0',
|
version='0.7.1',
|
||||||
|
|
||||||
description='CartoDB Services API Python Library',
|
description='CartoDB Services API Python Library',
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user