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