]> granicus.if.org Git - postgis/commitdiff
Rework edge motion range construction (#1571)
authorSandro Santilli <strk@keybit.net>
Fri, 17 Feb 2012 15:11:36 +0000 (15:11 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 17 Feb 2012 15:11:36 +0000 (15:11 +0000)
Includes a new testcase which was failing before this change

git-svn-id: http://svn.osgeo.org/postgis/trunk@9226 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/sqlmm.sql.in.c
topology/test/regress/st_changeedgegeom.sql
topology/test/regress/st_changeedgegeom_expected

index 9ddeae6514bfd73b922c009b3b985c7722ca7f8a..f78143e3e2129fe8bb2ba0d7508dfb7844d09dbc 100644 (file)
@@ -2538,6 +2538,8 @@ DECLARE
   rec RECORD;
   oldedge RECORD;
   range GEOMETRY; -- movement range
+  tmp1 GEOMETRY;
+  tmp2 GEOMETRY;
   sql TEXT;
   iscw BOOLEAN;
 BEGIN
@@ -2672,12 +2674,28 @@ BEGIN
   -- Not in the specs:
   -- Check topological isomorphism 
   --
-  range := ST_MakeLine(oldedge.geom, ST_Reverse(acurve));
-  RAISE DEBUG 'Made line: %', ST_AsText(range);
-  range := ST_MakePolygon(range);
-  RAISE DEBUG 'Made poly: %', ST_AsText(range);
-  range := ST_CollectionExtract(ST_MakeValid(range), 3);
+  tmp1 := ST_MakeLine(ST_EndPoint(oldedge.geom), ST_StartPoint(oldedge.geom));
+  RAISE DEBUG 'end-to-start: %', ST_AsText(tmp1);
+
+  tmp2 := ST_MakeLine(oldedge.geom, tmp1);
+  IF ST_NumPoints(tmp2) < 4 THEN
+    tmp2 := ST_AddPoint(tmp2, ST_StartPoint(oldedge.geom));
+  END IF;
+  RAISE DEBUG 'Old-ring: %', ST_AsText(tmp2);
+  tmp2 := ST_CollectionExtract(ST_MakeValid(ST_MakePolygon(tmp2)), 3);
+  RAISE DEBUG 'Old-ring (poly): %', ST_AsText(tmp2);
+
+  range := ST_MakeLine(acurve, tmp1);
+  IF ST_NumPoints(range) < 4 THEN
+    range := ST_AddPoint(range, ST_StartPoint(oldedge.geom));
+  END IF;
+  RAISE DEBUG 'New-ring: %', ST_AsText(range);
+  range := ST_CollectionExtract(ST_MakeValid(ST_MakePolygon(range)), 3);
+  RAISE DEBUG 'New-ring (poly): %', ST_AsText(range);
+
+  range := ST_SymDifference(range, tmp2);
   RAISE DEBUG 'Range motion: %', ST_AsText(range);
+
   sql := 'SELECT node_id, geom FROM '
     || quote_ident(atopology)
     || '.node WHERE ST_Contains('
index 4902def1b3267bf2363dcda7a6fc6a6785e8c970..f6cefdc2fc78ca52717798059ef4b4962b8d5f5f 100644 (file)
@@ -62,6 +62,10 @@ SELECT 'T7', topology.ST_ChangeEdgeGeom('city_data', 2,
 SELECT topology.ST_ChangeEdgeGeom('city_data', 2,
  'LINESTRING(25 30, 28 39, 20 39, 25 30)');
 
+-- This movement should be fine
+SELECT 'T7.1', topology.ST_ChangeEdgeGeom('city_data', 2,
+'LINESTRING(25 30, 28 39, 17 39, 25 30)');
+
 -- Test changing winding direction of closed edge
 SELECT topology.ST_ChangeEdgeGeom('city_data', 26,
  ST_Reverse('LINESTRING(4 31, 7 31, 4 34, 4 31)'));
@@ -74,6 +78,7 @@ SELECT 'T8', topology.ST_ChangeEdgeGeom('city_data', 26,
 SELECT topology.ST_ChangeEdgeGeom('city_data', 13,
  'LINESTRING(21 6, 21 2, 6 2, 6 25, 50 25, 50 2, 35 2, 35 6)');
 
+
 -- TODO: test moving closed edge into another face
 -- TODO: test face mbr update
 
index cc2e55b1c00c65bf6405fb97607a64822db9e092..74e1ce560475bc465293c46e812072914a54e9f5 100644 (file)
@@ -18,7 +18,8 @@ T5|Edge 3 changed
 T6|Edge 3 changed
 ERROR:  Edge motion collision at POINT(20 37)
 T7|Edge 2 changed
-ERROR:  Edge motion collision at POINT(25 35)
+ERROR:  Edge motion collision at POINT(20 37)
+T7.1|Edge 2 changed
 ERROR:  Edge twist at node POINT(4 31)
 T8|Edge 26 changed
 ERROR:  Edge motion collision at POINT(9 6)