[SCM] PostGIS branch stable-3.4 updated. 3.4.4-36-g747ca50d9
git at osgeo.org
git at osgeo.org
Sat Jul 19 01:09:08 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, stable-3.4 has been updated
via 747ca50d90c2070ac363401bff9bc74bfa12d5be (commit)
from db90a308888415cd40964bf77d6326b4f01a7289 (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 747ca50d90c2070ac363401bff9bc74bfa12d5be
Author: Sandro Santilli <strk at kbt.io>
Date: Sat Jul 19 09:47:42 2025 +0200
Have GetFaceContainingPoint catch EMPTY edges in corrupted topology
Fixes #5925, #5946 in 3.4 branch (3.4.5dev)
Includes regression test
diff --git a/NEWS b/NEWS
index d650a42d5..aeb6b5d4e 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ Proj 6.1+ required.
* Bug Fixes *
+ - #5925, #5946, [topology] Have GetFaceContainingPoint survive EMPTY edges (Sandro Santilli)
- #5936, [topology] Do script-based upgrade in a single transaction (Sandro Santilli)
- #5922, [topology] Fix crash in TopoGeo_AddLinestring with EMPTY input (Sandro Santilli)
- #5908, [topology] Fix crash in GetFaceContainingPoint (Sandro Santilli)
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 8beda2f44..b582baff4 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -7217,6 +7217,30 @@ lwt_GetFaceContainingPoint(LWT_TOPOLOGY* topo, const LWPOINT* pt)
return 0;
}
+ if ( closestEdge->face_left < 0 )
+ {
+ lwerror("Closest edge %" LWTFMT_ELEMID " has invalid face %" LWTFMT_ELEMID
+ " on its left side", closestEdge->edge_id, closestEdge->face_left);
+ _lwt_release_edges(closestEdge, 1);
+ return -1;
+ }
+
+ if ( closestEdge->face_right < 0 )
+ {
+ lwerror("Closest edge %" LWTFMT_ELEMID " has invalid face %" LWTFMT_ELEMID
+ " on its right side", closestEdge->edge_id, closestEdge->face_right);
+ _lwt_release_edges(closestEdge, 1);
+ return -1;
+ }
+
+ if ( closestEdge->geom->points->npoints < 2 )
+ {
+ lwerror("Corrupted topology: geometry of edge %" LWTFMT_ELEMID " is EMPTY",
+ closestEdge->edge_id);
+ _lwt_release_edges(closestEdge, 1);
+ return -1;
+ }
+
LWDEBUGGF(2, lwline_as_lwgeom(closestEdge->geom), "Closest edge %" LWTFMT_ELEMID, closestEdge->edge_id);
/* Find closest segment of edge to the point */
diff --git a/topology/test/regress/getfacebypoint.sql b/topology/test/regress/getfacebypoint.sql
index 7c67bf944..842394cb8 100644
--- a/topology/test/regress/getfacebypoint.sql
+++ b/topology/test/regress/getfacebypoint.sql
@@ -57,4 +57,11 @@ SELECT 'e1', topology.GetFaceByPoint('topo','POINT(1 5)', 0);
-- Ask for a Point with a tollerance too high (2 or more faces)
SELECT 'e2', topology.GetFaceByPoint('topo','POINT(6 13)', 1);
+-- Empty edge geometries should not make the function choke
+-- See https://trac.osgeo.org/postgis/ticket/5946
+BEGIN;
+UPDATE topo.edge_data SET geom = 'LINESTRING EMPTY';
+SELECT 't5946', topology.GetFaceByPoint('topo','POINT(6 13)', 0);
+ROLLBACK;
+
SELECT NULL FROM topology.DropTopology('topo');
diff --git a/topology/test/regress/getfacebypoint_expected b/topology/test/regress/getfacebypoint_expected
index 5dfc9116f..471eeafd7 100644
--- a/topology/test/regress/getfacebypoint_expected
+++ b/topology/test/regress/getfacebypoint_expected
@@ -10,3 +10,4 @@ t4|0
t5|t
ERROR: Two or more faces found
ERROR: Two or more faces found
+ERROR: Corrupted topology: geometry of edge 9 is EMPTY
diff --git a/topology/test/regress/topogeo_addpoint.sql b/topology/test/regress/topogeo_addpoint.sql
index 1d5ad1894..2d8325ca4 100644
--- a/topology/test/regress/topogeo_addpoint.sql
+++ b/topology/test/regress/topogeo_addpoint.sql
@@ -78,3 +78,19 @@ SELECT 't5698', 'E', TopoGeo_addLinestring('t', 'LINESTRING( 15.796760167740288
SELECT 't5698', 'N', TopoGeo_addPoint( 't', 'POINT(15.796760167739626 69.05714853429157)');
SELECT 't5698', 'V', * FROM ValidateTopology('t');
SELECT NULL FROM DropTopology('t');
+
+-- See https://trac.osgeo.org/postgis/ticket/5794
+BEGIN;
+SELECT NULL FROM topology.CreateTopology ('t');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t', 'LINESTRING(0 0, 10 0)');
+SELECT 't5794', 'N', topology.TopoGeo_addPoint('t', 'POINT(9 5)', 5);
+SELECT 't5794', 'V', * FROM ValidateTopology('t');
+ROLLBACK;
+
+-- See https://trac.osgeo.org/postgis/ticket/5925
+BEGIN;
+SELECT NULL FROM topology.CreateTopology ('t');
+SELECT NULL FROM topology.TopoGeo_addLinestring('t', 'LINESTRING(0 0, 10 0)');
+UPDATE t.edge_data SET geom = 'LINESTRING EMPTY';
+SELECT 't5925.1', topology.TopoGeo_addPoint('t', 'POINT(5 5)', 0);
+ROLLBACK;
diff --git a/topology/test/regress/topogeo_addpoint_expected b/topology/test/regress/topogeo_addpoint_expected
index bf28121eb..787fd746c 100644
--- a/topology/test/regress/topogeo_addpoint_expected
+++ b/topology/test/regress/topogeo_addpoint_expected
@@ -32,3 +32,8 @@ tt5394|E2|2
tt5394|N|3
t5698|E|1
t5698|N|3
+<<<<<<< HEAD
+=======
+t5794|N|3
+ERROR: Corrupted topology: geometry of edge 1 is EMPTY
+>>>>>>> 39304ca29 (Have GetFaceContainingPoint catch EMPTY edges in corrupted topology)
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
liblwgeom/lwgeom_topo.c | 24 ++++++++++++++++++++++++
topology/test/regress/getfacebypoint.sql | 7 +++++++
topology/test/regress/getfacebypoint_expected | 1 +
topology/test/regress/topogeo_addpoint.sql | 16 ++++++++++++++++
topology/test/regress/topogeo_addpoint_expected | 5 +++++
6 files changed, 54 insertions(+)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list