[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0rc1-27-gdd5c269

git at osgeo.org git at osgeo.org
Sat Jan 2 15:25:09 PST 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  dd5c269d888cfae30e67a42a7ccdd3add595a137 (commit)
      from  27cd95caf3cf16ab27dcb908c5b786c6ab36bafd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dd5c269d888cfae30e67a42a7ccdd3add595a137
Author: Sandro Santilli <strk at kbt.io>
Date:   Sun Jan 3 00:24:04 2021 +0100

    Avoid listing the same geometry in different collections
    
    References #4823 in master branch (3.2.0dev)

diff --git a/liblwgeom/lwgeom_geos_clean.c b/liblwgeom/lwgeom_geos_clean.c
index 878d91b..3c12e25 100644
--- a/liblwgeom/lwgeom_geos_clean.c
+++ b/liblwgeom/lwgeom_geos_clean.c
@@ -322,7 +322,10 @@ lwcollection_make_geos_friendly(LWCOLLECTION* g)
 	uint32_t i, new_ngeoms = 0;
 	LWCOLLECTION* ret;
 
-	if ( ! g->ngeoms ) return lwcollection_as_lwgeom(g);
+	if ( ! g->ngeoms ) {
+		LWDEBUG(3, "lwcollection_make_geos_friendly: returning input untouched");
+		return lwcollection_as_lwgeom(g);
+	}
 
 	/* enough space for all components */
 	new_geoms = lwalloc(sizeof(LWGEOM*) * g->ngeoms);
@@ -334,7 +337,12 @@ lwcollection_make_geos_friendly(LWCOLLECTION* g)
 	for (i = 0; i < g->ngeoms; i++)
 	{
 		LWGEOM* newg = lwgeom_make_geos_friendly(g->geoms[i]);
-		if (newg) new_geoms[new_ngeoms++] = newg;
+		if (!newg) continue;
+		if ( newg != g->geoms[i] ) {
+			new_geoms[new_ngeoms++] = newg;
+		} else {
+			new_geoms[new_ngeoms++] = lwgeom_clone(newg);
+		}
 	}
 
 	ret->bbox = NULL; /* recompute later... */
@@ -908,28 +916,20 @@ lwgeom_make_valid(LWGEOM* lwgeom_in)
 	lwgeom_out = lwgeom_make_geos_friendly(lwgeom_in);
 	if (!lwgeom_out) lwerror("Could not make a geos friendly geometry out of input");
 
+	LWDEBUGF(4, "Input geom %p made GEOS-valid as %p", lwgeom_in, lwgeom_out);
+
 	geosgeom = LWGEOM2GEOS(lwgeom_out, 1);
+	if ( lwgeom_in != lwgeom_out ) {
+		lwgeom_free(lwgeom_out);
+	}
 	if (!geosgeom)
 	{
-		LWDEBUGF(4,
-			 "Original geom can't be converted to GEOS (%s)"
-			 " - will try cleaning that up first",
-			 lwgeom_geos_errmsg);
-
-
-		/* try again as we did cleanup now */
-		/* TODO: invoke LWGEOM2GEOS directly with autoclean ? */
-		geosgeom = LWGEOM2GEOS(lwgeom_out, 0);
-		if (!geosgeom)
-		{
-			lwerror("Couldn't convert POSTGIS geom to GEOS: %s", lwgeom_geos_errmsg);
-			return NULL;
-		}
+		lwerror("Couldn't convert POSTGIS geom to GEOS: %s", lwgeom_geos_errmsg);
+		return NULL;
 	}
 	else
 	{
-		LWDEBUG(4, "original geom converted to GEOS");
-		lwgeom_out = lwgeom_in;
+		LWDEBUG(4, "geom converted to GEOS");
 	}
 
 #if POSTGIS_GEOS_VERSION < 38

-----------------------------------------------------------------------

Summary of changes:
 liblwgeom/lwgeom_geos_clean.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list