Fix invalid geometries due to generalize option

They add a note saying that use their simplification option could
lead to a self-intersection (which is the problem we have) and it's
creating invalid geometries

See it here https://mapzen.com/documentation/mobility/isochrone/api-reference/#other-request-parameters
This commit is contained in:
Mario de Frutos 2017-08-30 17:24:05 +02:00
parent 937440c79a
commit 475df918c7
2 changed files with 2 additions and 2 deletions

View File

@ -28,7 +28,7 @@ def coordinates_to_polygon(coordinates):
wkt_coordinates = ','.join(result_coordinates) wkt_coordinates = ','.join(result_coordinates)
try: try:
sql = "SELECT ST_MakePolygon(ST_GeomFromText('LINESTRING({0})', 4326)) as geom".format(wkt_coordinates) sql = "SELECT ST_CollectionExtract(ST_MakeValid(ST_MakePolygon(ST_GeomFromText('LINESTRING({0})', 4326))),3) as geom".format(wkt_coordinates)
geometry = plpy.execute(sql, 1)[0]['geom'] geometry = plpy.execute(sql, 1)[0]['geom']
except BaseException as e: except BaseException as e:
plpy.warning("Can't generate POLYGON from coordinates: {0}".format(e)) plpy.warning("Can't generate POLYGON from coordinates: {0}".format(e))

View File

@ -10,7 +10,7 @@ from setuptools import setup, find_packages
setup( setup(
name='cartodb_services', name='cartodb_services',
version='0.15.3', version='0.15.4',
description='CartoDB Services API Python Library', description='CartoDB Services API Python Library',