From: Björn Harrtell Date: Thu, 5 Oct 2017 10:50:16 +0000 (+0000) Subject: ST_AsMVTGeom clarification on semantics of mvt_geom X-Git-Tag: 2.5.0alpha~461 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac0a690ff26d70b650b7b38254189205542fa446;p=postgis ST_AsMVTGeom clarification on semantics of mvt_geom git-svn-id: http://svn.osgeo.org/postgis/trunk@15893 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_out_mvt.c b/postgis/lwgeom_out_mvt.c index d3a0b7300..8dacd2d2d 100644 --- a/postgis/lwgeom_out_mvt.c +++ b/postgis/lwgeom_out_mvt.c @@ -60,11 +60,13 @@ Datum ST_AsMVTGeom(PG_FUNCTION_ARGS) extent = PG_ARGISNULL(2) ? 4096 : PG_GETARG_INT32(2); buffer = PG_ARGISNULL(3) ? 256 : PG_GETARG_INT32(3); clip_geom = PG_ARGISNULL(4) ? true : PG_GETARG_BOOL(4); + // NOTE: can both return in clone and in place modification so + // not known if lwgeom_in can be freed lwgeom_out = mvt_geom(lwgeom_in, bounds, extent, buffer, clip_geom); - lwgeom_free(lwgeom_in); if (lwgeom_out == NULL) PG_RETURN_NULL(); geom_out = geometry_serialize(lwgeom_out); + lwgeom_free(lwgeom_out); PG_FREE_IF_COPY(geom_in, 0); PG_RETURN_POINTER(geom_out); #endif diff --git a/postgis/mvt.c b/postgis/mvt.c index 018096912..6f69b0e78 100644 --- a/postgis/mvt.c +++ b/postgis/mvt.c @@ -657,6 +657,8 @@ static int max_type(LWCOLLECTION *lwcoll) * * Makes best effort to keep validity. Might collapse geometry into lower * dimension. + * + * NOTE: modifies in place if possible (not currently possible for polygons) */ LWGEOM *mvt_geom(LWGEOM *lwgeom, const GBOX *gbox, uint32_t extent, uint32_t buffer, bool clip_geom)