[postgis-tickets] r15105 - #3569, Incorrect coordinates returned by ST_CollectionHomogenize

Daniel Baston dbaston at gmail.com
Tue Sep 13 11:06:49 PDT 2016


Author: dbaston
Date: 2016-09-13 11:06:49 -0700 (Tue, 13 Sep 2016)
New Revision: 15105

Modified:
   trunk/liblwgeom/liblwgeom.h.in
   trunk/postgis/lwgeom_functions_basic.c
   trunk/regress/tickets.sql
   trunk/regress/tickets_expected
Log:
#3569, Incorrect coordinates returned by ST_CollectionHomogenize

Modified: trunk/liblwgeom/liblwgeom.h.in
===================================================================
--- trunk/liblwgeom/liblwgeom.h.in	2016-09-13 16:55:27 UTC (rev 15104)
+++ trunk/liblwgeom/liblwgeom.h.in	2016-09-13 18:06:49 UTC (rev 15105)
@@ -1042,7 +1042,12 @@
 
 extern int lwcollection_ngeoms(const LWCOLLECTION *col);
 
-/* Given a generic geometry/collection, return the "simplest" form. */
+/* Given a generic geometry/collection, return the "simplest" form.
+ * The elements of the homogenized collection are references to the
+ * input geometry; a deep clone is not performed.
+ * TODO: consider returning a geometry that does not reference the
+ * input
+ * */
 extern LWGEOM *lwgeom_homogenize(const LWGEOM *geom);
 
 

Modified: trunk/postgis/lwgeom_functions_basic.c
===================================================================
--- trunk/postgis/lwgeom_functions_basic.c	2016-09-13 16:55:27 UTC (rev 15104)
+++ trunk/postgis/lwgeom_functions_basic.c	2016-09-13 18:06:49 UTC (rev 15105)
@@ -2643,14 +2643,17 @@
 
 	lwoutput = lwgeom_homogenize(lwgeom);
 	lwgeom_free(lwgeom);
-	PG_FREE_IF_COPY(input, 0);
 
 	if ( ! lwoutput )
+	{
 		PG_RETURN_NULL();
+		PG_FREE_IF_COPY(input, 0);
+	}
 
 	output = geometry_serialize(lwoutput);
 	lwgeom_free(lwoutput);
 
+	PG_FREE_IF_COPY(input, 0);
 	PG_RETURN_POINTER(output);
 }
 

Modified: trunk/regress/tickets.sql
===================================================================
--- trunk/regress/tickets.sql	2016-09-13 16:55:27 UTC (rev 15104)
+++ trunk/regress/tickets.sql	2016-09-13 18:06:49 UTC (rev 15105)
@@ -966,6 +966,13 @@
 SELECT '#3470', ST_Polygonize(ARRAY[NULL]::geometry[]) IS NULL;
 SELECT '#3470b', ST_Area(ST_Polygonize(ARRAY[NULL, 'LINESTRING (0 0, 10 0, 10 10)', NULL, 'LINESTRING (0 0, 10 10)', NULL]::geometry[]));
 
+-- #3569
+WITH clustr AS (
+      SELECT ST_Polygonize(ST_MakeEnvelope(1, 2, 3, 4)) AS geom
+    )
+    SELECT '#3569', ST_CollectionHomogenize(geom)::box2d
+    FROM clustr;
+
 -- #3579
 with
         params as (

Modified: trunk/regress/tickets_expected
===================================================================
--- trunk/regress/tickets_expected	2016-09-13 16:55:27 UTC (rev 15104)
+++ trunk/regress/tickets_expected	2016-09-13 18:06:49 UTC (rev 15105)
@@ -294,6 +294,7 @@
 #3437e|5
 #3470|t
 #3470b|50
+#3569|BOX(1 2,3 4)
 #3579|f|t
 #3627a|o}~~|AdshNoSsBgd at eGoBlm@wKhj@~@?
 #3627b|t



More information about the postgis-tickets mailing list