From 475df918c7a751de12d53715d16ad2a9d64713fb Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 30 Aug 2017 17:24:05 +0200 Subject: [PATCH 1/2] 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 --- .../python/cartodb_services/cartodb_services/mapzen/types.py | 2 +- server/lib/python/cartodb_services/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/mapzen/types.py b/server/lib/python/cartodb_services/cartodb_services/mapzen/types.py index b29298a..19a6809 100644 --- a/server/lib/python/cartodb_services/cartodb_services/mapzen/types.py +++ b/server/lib/python/cartodb_services/cartodb_services/mapzen/types.py @@ -28,7 +28,7 @@ def coordinates_to_polygon(coordinates): wkt_coordinates = ','.join(result_coordinates) 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'] except BaseException as e: plpy.warning("Can't generate POLYGON from coordinates: {0}".format(e)) diff --git a/server/lib/python/cartodb_services/setup.py b/server/lib/python/cartodb_services/setup.py index 5c1e052..511c51f 100644 --- a/server/lib/python/cartodb_services/setup.py +++ b/server/lib/python/cartodb_services/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages setup( name='cartodb_services', - version='0.15.3', + version='0.15.4', description='CartoDB Services API Python Library', From bd63346c501617b6ea7ab5cd1272fa9e6a5028d4 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 30 Aug 2017 17:44:33 +0200 Subject: [PATCH 2/2] Updated NEWS.md --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index 4745876..c0d9295 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +August 30th, 2017 +============= +* Version `0.15.4` of the python library + * Fixed invalid geometries for isochrones due to `generalize` option. See #397 + August 24th, 2017 ============= * Improved the documentation