postgis.git / summary / log / commit / refs

commit    ef4e85d475a4fd790ce0ecfbc5d6e70bbde6012b
Author:   Sandro Santilli <strk@kbt.io>
Date:     Fri Oct 28 16:35:05 2022 +0000

    Fix bogus target of closed linestring scroll in TopoGeo_addLineString
    
    References #5081 in master branch (3.4.0dev)
    Includes regression testcase


liblwgeom/lwgeom_topo.c | 29 +++++++++++----------- topology/test/regress/topogeo_addlinestring.sql | 23 +++++++++++++++++ .../test/regress/topogeo_addlinestring_expected | 4 +++ 3 files changed, 42 insertions(+), 14 deletions(-) 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@kbt.io> + * Copyright (C) 2015-2022 Sandro Santilli <strk@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 [parent: 2405b53478cd]