[postgis-tickets] [SCM] PostGIS branch stable-3.3 updated. 3.3.1-23-g1936ac744

git at osgeo.org git at osgeo.org
Thu Nov 3 05:48:48 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.3 has been updated
       via  1936ac744c6ae35599e7cfa71da6a48404538b96 (commit)
      from  0e8ff740ec27fa89a8583adc717ea48b14515510 (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 1936ac744c6ae35599e7cfa71da6a48404538b96
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
    
    References #5081 in 3.3 branch (3.3.2dev)
    Includes regression testcase

diff --git a/NEWS b/NEWS
index 4a176df3a..d8318649f 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ xxxx/xx/xx
   - #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.3.1
diff --git a/liblwgeom/lwgeom_topo.c b/liblwgeom/lwgeom_topo.c
index 479a65386..a4ca8532f 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>
  *
  **********************************************************************/
 
@@ -5819,9 +5819,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);
@@ -5836,18 +5849,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 7a9a871ca..e9f4b6f95 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