From 821a1f41bf2eaebfc33ba1f5fee11911f278ec7f Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 11 Apr 2012 12:37:18 +0000 Subject: [PATCH] Cleanup lines after (bad) snapping (#1714) git-svn-id: http://svn.osgeo.org/postgis/trunk@9625 b70326c6-7e19-0410-871a-916f4a2858ee --- topology/sql/populate.sql.in.c | 8 +++++++ .../test/regress/topogeo_addlinestring.sql | 17 ++++++++++++++ .../regress/topogeo_addlinestring_expected | 23 +++++++++++-------- .../test/regress/topogeo_addpolygon_expected | 4 ++-- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/topology/sql/populate.sql.in.c b/topology/sql/populate.sql.in.c index cdae2ed27..54e6bdc42 100644 --- a/topology/sql/populate.sql.in.c +++ b/topology/sql/populate.sql.in.c @@ -902,6 +902,14 @@ BEGIN #ifdef POSTGIS_TOPOLOGY_DEBUG RAISE DEBUG 'Split: %', ST_AsText(noded); #endif + + -- re-node to account for ST_Snap introduced self-intersections + -- See http://trac.osgeo.org/postgis/ticket/1714 + -- TODO: consider running UnaryUnion once after all noding + noded := ST_UnaryUnion(noded); +#ifdef POSTGIS_TOPOLOGY_DEBUG + RAISE DEBUG 'Self-unioned again: %', ST_AsText(noded); +#endif END IF; -- } -- 3. For each (now-noded) segment, insert an edge diff --git a/topology/test/regress/topogeo_addlinestring.sql b/topology/test/regress/topogeo_addlinestring.sql index 73a22db93..06ae4d194 100644 --- a/topology/test/regress/topogeo_addlinestring.sql +++ b/topology/test/regress/topogeo_addlinestring.sql @@ -238,6 +238,23 @@ SELECT check_changes(); -- Consistency check SELECT * FROM ValidateTopology('city_data'); +-- Test noding after snap +-- See http://trac.osgeo.org/postgis/ticket/1714 + +DELETE FROM city_data.edge_data; DELETE FROM city_data.node; +DELETE FROM city_data.face where face_id > 0; + +SELECT '#1714.1', 'N', AddNode('city_data', 'POINT(10 0)'); +SELECT check_changes(); + +SELECT '#1714.2', 'E*', TopoGeo_addLineString('city_data', + 'LINESTRING(10 0, 0 20, 0 0, 10 0)' +, 12) ORDER BY 3; +SELECT check_changes(); + +-- Consistency check +SELECT * FROM ValidateTopology('city_data'); + -- Cleanups DROP FUNCTION check_changes(); SELECT DropTopology('city_data'); diff --git a/topology/test/regress/topogeo_addlinestring_expected b/topology/test/regress/topogeo_addlinestring_expected index 90ced32c6..eac9fe62a 100644 --- a/topology/test/regress/topogeo_addlinestring_expected +++ b/topology/test/regress/topogeo_addlinestring_expected @@ -43,7 +43,7 @@ E|33|sn32|en19 E|34|sn31|en32 E|35|sn32|en33 snap|36 -snap|38 +snap|39 snap|40 N|34||POINT(18 22) N|35||POINT(22.4 22) @@ -53,12 +53,12 @@ E|7|sn17|en35 E|19|sn14|en36 E|36|sn34|en17 E|37|sn35|en18 -E|38|sn17|en35 -E|39|sn36|en17 -E|40|sn35|en36 +E|38|sn36|en17 +E|39|sn35|en36 +E|40|sn17|en35 snap_again|7 snap_again|36 -snap_again|40 +snap_again|39 crossover|43 crossover|45 crossover|46 @@ -85,10 +85,10 @@ crossover_again|47 contains|25 contains|48 contains|49 -N|42||POINT(14 34) -N|43||POINT(7 36) -E|48|sn42|en22 -E|49|sn21|en43 +N|42||POINT(7 36) +N|43||POINT(14 34) +E|48|sn21|en42 +E|49|sn43|en22 nodecross|50 nodecross|51 N|44||POINT(18 37) @@ -169,4 +169,9 @@ N|73||POINT(9 12) E|70|sn70|en73 E|71|sn73|en71 E|72|sn72|en73 +#1714.1|N|74 +N|74||POINT(10 0) +#1714.2|E*|73 +N|75||POINT(0 20) +E|73|sn74|en75 Topology 'city_data' dropped diff --git a/topology/test/regress/topogeo_addpolygon_expected b/topology/test/regress/topogeo_addpolygon_expected index 40a37a8d1..75e316d74 100644 --- a/topology/test/regress/topogeo_addpolygon_expected +++ b/topology/test/regress/topogeo_addpolygon_expected @@ -31,8 +31,8 @@ split|13 N|26||POINT(28 18) E|30|sn14|en26 E|31|sn26|en18 -E|32|sn17|en26 -E|33|sn26|en13 +E|32|sn26|en13 +E|33|sn17|en26 F|14 F|15 ex_hole|3 -- 2.50.1