[SCM] PostGIS branch stable-3.3 updated. 3.3.7-43-g44773fee5

git at osgeo.org git at osgeo.org
Sat Jul 19 01:18:26 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.3 has been updated
       via  44773fee5e183476c5537be257cf3ebaa15cbda7 (commit)
      from  3bb3801c2244baea305359e3946038b9e78f1c2d (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 44773fee5e183476c5537be257cf3ebaa15cbda7
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.3 branch (3.3.8dev)
    
    Includes regression test

diff --git a/NEWS b/NEWS
index 4f41363a4..45007df4b 100644
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,7 @@ Proj 4.9+ required.
  - #5795, [topology] Fix ST_NewEdgesSplit can cause invalid topology
           (Björn Harrtell)
  - #5677, Retain SRID during unary union (Paul Ramsey)
+ - #5925, #5946, [topology] Have GetFaceContainingPoint survive EMPTY edges (Sandro Santilli)
 
 * Enhancements *
 
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 4c1f28a26..6234d6035 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -7218,6 +7218,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