[SCM] PostGIS branch master updated. 3.5.0-350-g1f7efb045
git at osgeo.org
git at osgeo.org
Thu May 29 00:49:00 PDT 2025
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 1f7efb045c38896a5d8f0393fa5dee335941f281 (commit)
from 76caa8d25b18de99c35f8f3ad4dc7561b247f57c (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 1f7efb045c38896a5d8f0393fa5dee335941f281
Author: Sandro Santilli <strk at kbt.io>
Date: Thu May 29 09:39:47 2025 +0200
Make GetFaceContainingPoint survive to NULL arguments and EMPTY points
References #5908 in master branch (3.6.0dev)
diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c
index 6d1f52770..01c8b98a2 100644
--- a/topology/postgis_topology.c
+++ b/topology/postgis_topology.c
@@ -5527,7 +5527,7 @@ Datum GetRingEdges(PG_FUNCTION_ARGS)
SRF_RETURN_NEXT(funcctx, result);
}
-/* GetFaceContainingPoint(atopology, point) */
+/* GetFaceContainingPoint(atopology, point) */
Datum GetFaceContainingPoint(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(GetFaceContainingPoint);
Datum GetFaceContainingPoint(PG_FUNCTION_ARGS)
@@ -5540,6 +5540,12 @@ Datum GetFaceContainingPoint(PG_FUNCTION_ARGS)
LWPOINT *pt;
LWT_TOPOLOGY *topo;
+ if ( PG_ARGISNULL(0) || PG_ARGISNULL(1) )
+ {
+ /* should only happen when the SQL function is not declared STRICT */
+ PG_RETURN_NULL();
+ }
+
toponame_text = PG_GETARG_TEXT_P(0);
toponame = text_to_cstring(toponame_text);
PG_FREE_IF_COPY(toponame_text, 0);
@@ -5555,6 +5561,14 @@ Datum GetFaceContainingPoint(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
+ if ( lwpoint_is_empty(pt) )
+ {
+ lwgeom_free(lwgeom);
+ PG_FREE_IF_COPY(geom, 1);
+ lwpgerror("Second argument needs be a non-empty point");
+ PG_RETURN_NULL();
+ }
+
if ( SPI_OK_CONNECT != SPI_connect() )
{
lwpgerror("Could not connect to SPI");
diff --git a/topology/sql/query/GetFaceContainingPoint.sql.in b/topology/sql/query/GetFaceContainingPoint.sql.in
index bd48bd2c8..9f84c4da5 100644
--- a/topology/sql/query/GetFaceContainingPoint.sql.in
+++ b/topology/sql/query/GetFaceContainingPoint.sql.in
@@ -27,4 +27,4 @@ CREATE OR REPLACE FUNCTION topology.GetFaceContainingPoint(
)
RETURNS INT AS
'MODULE_PATHNAME', 'GetFaceContainingPoint'
-LANGUAGE 'c' STABLE;
+LANGUAGE 'c' STABLE STRICT;
diff --git a/topology/test/regress/getfacecontainingpoint.sql b/topology/test/regress/getfacecontainingpoint.sql
index 16e80ad1a..e1a11b90c 100644
--- a/topology/test/regress/getfacecontainingpoint.sql
+++ b/topology/test/regress/getfacecontainingpoint.sql
@@ -54,7 +54,11 @@ SELECT NULL FROM topology.TopoGeo_addLineString('city_data', 'LINESTRING(43.58 8
SELECT NULL FROM topology.TopoGeo_addLineString('city_data', 'LINESTRING(45 8, 44 9)');
SELECT NULL FROM topology.TopoGeo_addLineString('city_data', 'LINESTRING(45 8, 43.58 8.2)');
-
+-- Corner case calls
+SELECT 'null1' FROM topology.GetFaceContainingPoint(null, 'POINT(0 0)');
+SELECT 'null2' FROM topology.GetFaceContainingPoint('city_data', null);
+SELECT 'null3' FROM topology.GetFaceContainingPoint(null, null);
+SELECT 'empty' FROM topology.GetFaceContainingPoint('city_data', 'POINT EMPTY');
-- Get face containing the "point on surface" of each face's geometry
diff --git a/topology/test/regress/getfacecontainingpoint_expected b/topology/test/regress/getfacecontainingpoint_expected
index 9df926e16..fe96a3245 100644
--- a/topology/test/regress/getfacecontainingpoint_expected
+++ b/topology/test/regress/getfacecontainingpoint_expected
@@ -1,3 +1,7 @@
+null1
+null2
+null3
+ERROR: Second argument needs be a non-empty point
pos|1|1
pos|2|2
pos|3|3
-----------------------------------------------------------------------
Summary of changes:
topology/postgis_topology.c | 16 +++++++++++++++-
topology/sql/query/GetFaceContainingPoint.sql.in | 2 +-
topology/test/regress/getfacecontainingpoint.sql | 6 +++++-
topology/test/regress/getfacecontainingpoint_expected | 4 ++++
4 files changed, 25 insertions(+), 3 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list