[postgis-tickets] [SCM] PostGIS branch master updated. 3.3.0rc2-601-gb1b8c11bf
git at osgeo.org
git at osgeo.org
Fri Feb 10 12:56:43 PST 2023
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 b1b8c11bfe54d7756ed53719e74783dd2733d3df (commit)
via f2ae230a7717b3dff4b012ba18df6a3d316047d6 (commit)
via 710751ea6c73e39965d189d7a1982453f3b58789 (commit)
via 8b41e54f70196635697475ae48b6d096e5ab457b (commit)
via 57adfe4051304def5dc229a2dc0bbcd9173c13ab (commit)
via 09b8c222198bd6d81ca324442360d491dafcf278 (commit)
from e4e77f51438dbee0e7bb787a307f0a4bbd13e3f3 (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 b1b8c11bfe54d7756ed53719e74783dd2733d3df
Merge: f2ae230a7 e4e77f514
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Feb 10 12:56:38 2023 -0800
Merge branch 'master' of https://git.osgeo.org/gitea/postgis/postgis
commit f2ae230a7717b3dff4b012ba18df6a3d316047d6
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Feb 10 12:56:15 2023 -0800
Prefilter to check for non-finite coordinates before feeding
ST_SimplifyPreserveTopology, to avoid crash/hang.
Closes #5320
diff --git a/liblwgeom/liblwgeom.h.in b/liblwgeom/liblwgeom.h.in
index 646bb1da0..13a5fd936 100644
--- a/liblwgeom/liblwgeom.h.in
+++ b/liblwgeom/liblwgeom.h.in
@@ -898,6 +898,12 @@ extern const GBOX *lwgeom_get_bbox(const LWGEOM *lwgeom);
*/
extern int lwgeom_is_collection(const LWGEOM *lwgeom);
+/**
+* Check if a LWGEOM has any non-finite (NaN or Inf) coordinates.
+*/
+extern int lwgeom_isfinite(const LWGEOM *lwgeom);
+
+
/******************************************************************/
/* Functions that work on type numbers */
diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c
index fd8d3ae55..1a580b9d6 100644
--- a/liblwgeom/lwgeom.c
+++ b/liblwgeom/lwgeom.c
@@ -2676,3 +2676,29 @@ lwgeom_boundary(LWGEOM *lwgeom)
return NULL;
}
}
+
+int
+lwgeom_isfinite(const LWGEOM *lwgeom)
+{
+ LWPOINTITERATOR* it = lwpointiterator_create(lwgeom);
+ int hasz = lwgeom_has_z(lwgeom);
+ int hasm = lwgeom_has_m(lwgeom);
+
+ while (lwpointiterator_has_next(it))
+ {
+ POINT4D p;
+ lwpointiterator_next(it, &p);
+ int finite = isfinite(p.x) &&
+ isfinite(p.y) &&
+ (hasz ? isfinite(p.z) : 1) &&
+ (hasm ? isfinite(p.m) : 1);
+
+ if (!finite)
+ {
+ lwpointiterator_destroy(it);
+ return LW_FALSE;
+ }
+ }
+ lwpointiterator_destroy(it);
+ return LW_TRUE;
+}
diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c
index 753873772..3349c2612 100644
--- a/postgis/lwgeom_geos.c
+++ b/postgis/lwgeom_geos.c
@@ -877,23 +877,32 @@ Datum ST_SimplifyPolygonHull(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(topologypreservesimplify);
Datum topologypreservesimplify(PG_FUNCTION_ARGS)
{
- GSERIALIZED *geom1;
+ GSERIALIZED *gs1;
+ LWGEOM *lwg1;
double tolerance;
GEOSGeometry *g1, *g3;
GSERIALIZED *result;
uint32_t type;
- geom1 = PG_GETARG_GSERIALIZED_P(0);
+ gs1 = PG_GETARG_GSERIALIZED_P(0);
tolerance = PG_GETARG_FLOAT8(1);
+ lwg1 = lwgeom_from_gserialized(gs1);
/* Empty.Simplify() == Empty */
- type = gserialized_get_type(geom1);
- if ( gserialized_is_empty(geom1) || type == TINTYPE || type == TRIANGLETYPE )
- PG_RETURN_POINTER(geom1);
+ type = lwgeom_get_type(lwg1);
+ if (lwgeom_is_empty(lwg1) || type == TINTYPE || type == TRIANGLETYPE)
+ PG_RETURN_POINTER(gs1);
+
+ if (!lwgeom_isfinite(lwg1))
+ {
+ lwpgerror("Geometry contains invalid coordinates");
+ PG_RETURN_NULL();
+ }
initGEOS(lwpgnotice, lwgeom_geos_error);
- g1 = POSTGIS2GEOS(geom1);
+ g1 = LWGEOM2GEOS(lwg1, LW_TRUE);
+ lwgeom_free(lwg1);
if (!g1)
HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
@@ -904,9 +913,9 @@ Datum topologypreservesimplify(PG_FUNCTION_ARGS)
POSTGIS_DEBUGF(3, "result: %s", GEOSGeomToWKT(g3));
- GEOSSetSRID(g3, gserialized_get_srid(geom1));
+ GEOSSetSRID(g3, gserialized_get_srid(gs1));
- result = GEOS2POSTGIS(g3, gserialized_has_z(geom1));
+ result = GEOS2POSTGIS(g3, gserialized_has_z(gs1));
GEOSGeom_destroy(g3);
if (!result)
@@ -915,7 +924,7 @@ Datum topologypreservesimplify(PG_FUNCTION_ARGS)
PG_RETURN_NULL(); /* never get here */
}
- PG_FREE_IF_COPY(geom1, 0);
+ PG_FREE_IF_COPY(gs1, 0);
PG_RETURN_POINTER(result);
}
commit 710751ea6c73e39965d189d7a1982453f3b58789
Merge: 8b41e54f7 b669712b3
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Feb 10 09:59:30 2023 -0800
Merge branch 'master' of https://git.osgeo.org/gitea/postgis/postgis
commit 8b41e54f70196635697475ae48b6d096e5ab457b
Merge: 57adfe405 dd3d8a4cd
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Thu Feb 9 16:40:53 2023 -0800
Merge branch 'master' of https://git.osgeo.org/gitea/postgis/postgis
commit 57adfe4051304def5dc229a2dc0bbcd9173c13ab
Merge: 09b8c2221 84956bd9d
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Mon Feb 6 15:40:07 2023 -0800
Merge branch 'master' of https://git.osgeo.org/gitea/postgis/postgis
commit 09b8c222198bd6d81ca324442360d491dafcf278
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Fri Feb 3 20:30:15 2023 -0800
When libproj throws at error, don't just write the
message to stderr. Catch it and put it into the
PgSQL log at a DEBUG level.
We check all return values and return codes when
calling into the proj API, so the extra error messages
don't really help us.
This is in response to our calls to proj_create()
dumping messages into stderr, which confuses operators.
Our projection code has to try a bunch of possible
strings to instantiate projection objects, some of
which fail (generating a message) and then we fall
back to the next string. The proj "errors" are not
errors from our pov, so we catch them and send them
along at much lower priority.
References #5332
diff --git a/postgis/postgis_module.c b/postgis/postgis_module.c
index 1018b92ca..0b54160e3 100644
--- a/postgis/postgis_module.c
+++ b/postgis/postgis_module.c
@@ -58,6 +58,21 @@ static void interruptCallback() {
static ExecutorStart_hook_type onExecutorStartPrev = NULL;
static void onExecutorStart(QueryDesc *queryDesc, int eflags);
+/*
+* Pass proj error message out via the PostgreSQL logging
+* system instead of letting them default into the
+* stderr.
+*/
+#if POSTGIS_PROJ_VERSION > 50
+#include "proj.h"
+
+static void
+pjLogFunction(void* data, int logLevel, const char* message)
+{
+ elog(DEBUG1, "libproj threw an exception (%d): %s", logLevel, message);
+}
+#endif
+
/*
* Module load callback
*/
@@ -75,6 +90,11 @@ _PG_init(void)
/* install PostgreSQL handlers */
pg_install_lwgeom_handlers();
+ /* pass proj messages through the pgsql error handler */
+#if POSTGIS_PROJ_VERSION > 50
+ proj_log_func(NULL, NULL, pjLogFunction);
+#endif
+
/* setup hooks */
onExecutorStartPrev = ExecutorStart_hook;
ExecutorStart_hook = onExecutorStart;
-----------------------------------------------------------------------
Summary of changes:
liblwgeom/liblwgeom.h.in | 6 ++++++
liblwgeom/lwgeom.c | 26 ++++++++++++++++++++++++++
postgis/lwgeom_geos.c | 27 ++++++++++++++++++---------
postgis/postgis_module.c | 20 ++++++++++++++++++++
4 files changed, 70 insertions(+), 9 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list