]> granicus.if.org Git - postgis/commitdiff
Cleanup lines after (bad) snapping (#1714)
authorSandro Santilli <strk@keybit.net>
Wed, 11 Apr 2012 12:37:18 +0000 (12:37 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 11 Apr 2012 12:37:18 +0000 (12:37 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9625 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/populate.sql.in.c
topology/test/regress/topogeo_addlinestring.sql
topology/test/regress/topogeo_addlinestring_expected
topology/test/regress/topogeo_addpolygon_expected

index cdae2ed275c9ad9f256db4e0eccf0d968c67a74d..54e6bdc42ea614509f5c873dc4a370b7ed0ba0e3 100644 (file)
@@ -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
index 73a22db935374d22d3c15c2dc0ecd7968eaf86f4..06ae4d1942a6be576c9c9269dace0402edd1d6e6 100644 (file)
@@ -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');
index 90ced32c6658682133a6e8f3f2f8b390126c8487..eac9fe62a4d38e95be49ab3611fa32c0a311ed11 100644 (file)
@@ -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
index 40a37a8d1dda39d4f2f98ffc70a022cd168e2f83..75e316d7419a3b4b7433287a151a821323353abe 100644 (file)
@@ -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