[postgis-tickets] [SCM] PostGIS branch stable-3.2 updated. 3.2.3-25-gc2a5b06ad

git at osgeo.org git at osgeo.org
Thu Nov 3 05:52:03 PDT 2022


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.2 has been updated
       via  c2a5b06ade6968ec615ef8ee1f6e66e80b83b515 (commit)
      from  437540ccd58ba7bb398d2dac75da3f6f5dddc8ad (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 c2a5b06ade6968ec615ef8ee1f6e66e80b83b515
Author: Sandro Santilli <strk at kbt.io>
Date:   Fri Oct 28 18:35:05 2022 +0200

    Fix error in topology import of self-intersecting rings
    
    Closes #5081 in 3.2 branch (3.2.4dev)
    Includes regression testcase

diff --git a/NEWS b/NEWS
index 0be5c010a..81c07704b 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Proj 6.1+, and PostgreSQL 14+.
   - #5255, GH702, Remove forced static linking on raster2pgsql (Thomas Petazzoni)
   - #4648, Check function ownership at extension packaging time (Sandro Santilli)
   - #5241, Crash on ST_SnapToGrid with empty multis (Regina Obe)
+  - #5081, Fix error in topology import of self-intersecting rings (Sandro Santilli)
 
 
 PostGIS 3.2.3
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 97e0515eb..16d64db81 100644
--- a/liblwgeom/lwgeom_topo.c
+++ b/liblwgeom/lwgeom_topo.c
@@ -18,7 +18,7 @@
  *
  **********************************************************************
  *
- * Copyright (C) 2015-2021 Sandro Santilli <strk at kbt.io>
+ * Copyright (C) 2015-2022 Sandro Santilli <strk at kbt.io>
  *
  **********************************************************************/
 
@@ -5847,9 +5847,22 @@ _lwt_AddLine(LWT_TOPOLOGY* topo, LWLINE* line, double tol, int* nedges,
     lwgeom_free(xset);
     xset = tmp;
 
+    /*
+     * Here we union the (linemerged) intersection with
+     * the difference (new lines)
+     */
+    LWDEBUG(1, "Unioning difference and (linemerged) intersection");
+    noded = lwgeom_union(diff, xset);
+    LWDEBUGG(1, noded, "Diff-Xset Unioned");
+    lwgeom_free(xset);
+    lwgeom_free(diff);
+
+    /* will not release the geoms array */
+    lwcollection_release(col);
+
     if ( input_was_closed )
     {{
-      LWLINE *scrolled = lwgeom_as_lwline(xset);
+      LWLINE *scrolled = lwgeom_as_lwline(noded);
       if (scrolled) {
         if ( lwline_is_closed(scrolled) ) {
           ptarray_scroll_in_place(scrolled->points, &originalStartPoint);
@@ -5864,18 +5877,6 @@ _lwt_AddLine(LWT_TOPOLOGY* topo, LWLINE* line, double tol, int* nedges,
     }}
 
 
-    /*
-     * Here we union the (linemerged) intersection with
-     * the difference (new lines)
-     */
-    LWDEBUG(1, "Unioning difference and (linemerged) intersection");
-    noded = lwgeom_union(diff, xset);
-    LWDEBUGG(1, noded, "Diff-Xset Unioned");
-    lwgeom_free(xset);
-    lwgeom_free(diff);
-
-    /* will not release the geoms array */
-    lwcollection_release(col);
   }}
 
 
diff --git a/topology/test/regress/topogeo_addlinestring.sql b/topology/test/regress/topogeo_addlinestring.sql
index 60cabfe26..23587686b 100644
--- a/topology/test/regress/topogeo_addlinestring.sql
+++ b/topology/test/regress/topogeo_addlinestring.sql
@@ -467,3 +467,26 @@ AND NOT ST_Equals(
     )
   );
 SELECT NULL FROM topology.DropTopology('b4941');
+
+-- See https://trac.osgeo.org/postgis/ticket/5081
+SELECT NULL FROM CreateTopology('b5081');
+SELECT 'b5081.0', 'E' || TopoGeo_addLinestring('b5081', $$
+  LINESTRING(0 0, 10 10,10 -10,0 0)
+$$);
+
+SELECT 'b5081.1', count(*) > 1 FROM (
+  SELECT TopoGeo_addLinestring('b5081', $$
+    LINESTRING(
+      -10 0,
+      0 0, 10 10,10 -10,0 0,
+      -10 0
+    )
+  $$)
+) foo;
+SELECT 'b5081', 'dangling_edges', count(*)
+  FROM b5081.edge
+  WHERE left_face = right_face;
+SELECT 'b5081', 'faces', count(*)
+  FROM b5081.face
+  WHERE face_id > 0;
+SELECT NULL FROM topology.DropTopology('b5081');
diff --git a/topology/test/regress/topogeo_addlinestring_expected b/topology/test/regress/topogeo_addlinestring_expected
index 8b9e06aae..26b18f000 100644
--- a/topology/test/regress/topogeo_addlinestring_expected
+++ b/topology/test/regress/topogeo_addlinestring_expected
@@ -219,3 +219,7 @@ t2175.3|1
 b4941|outer_ring|1
 b4941|inner_ring|1
 b4941|crossing_line|5
+b5081.0|E1
+b5081.1|t
+b5081|dangling_edges|1
+b5081|faces|1

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

Summary of changes:
 NEWS                                               |  1 +
 liblwgeom/lwgeom_topo.c                            | 29 +++++++++++-----------
 topology/test/regress/topogeo_addlinestring.sql    | 23 +++++++++++++++++
 .../test/regress/topogeo_addlinestring_expected    |  4 +++
 4 files changed, 43 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list