]> granicus.if.org Git - postgis/commitdiff
Allow changing a closed edge (but w/out fixing linking, see #892)
authorSandro Santilli <strk@keybit.net>
Tue, 7 Feb 2012 10:14:37 +0000 (10:14 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 7 Feb 2012 10:14:37 +0000 (10:14 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9063 b70326c6-7e19-0410-871a-916f4a2858ee

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

index 6ab4ee3e7f2cecea5e58a4accba753d6f69a9e4c..8f8dfb93c40e56b9206f3b1d6976e7f9c48b3d90 100644 (file)
@@ -2605,14 +2605,18 @@ BEGIN
 
   --
   -- g) Check if curve crosses any node
-  -- _within_ used to let endpoints out
   -- 
-  FOR rec IN EXECUTE 'SELECT node_id FROM '
-    || quote_ident(atopology) || '.node
-    WHERE ST_Within(geom, ' || quote_literal(acurve::text) || '::geometry)'
+  FOR rec IN EXECUTE
+    'SELECT node_id, ST_Relate(geom, '
+    || quote_literal(acurve::text) || '::geometry, 2) as relate FROM '
+    || quote_ident(atopology)
+    || '.node WHERE geom && '
+    || quote_literal(acurve::text)
+    || '::geometry'
   LOOP
-    RAISE EXCEPTION
-    'SQL/MM Spatial exception - geometry crosses a node';
+    IF ST_RelateMatch(rec.relate, 'T********') THEN
+      RAISE EXCEPTION 'SQL/MM Spatial exception - geometry crosses a node';
+    END IF;
   END LOOP;
 
   --
@@ -2657,6 +2661,13 @@ BEGIN
     || ' SET geom = ' || quote_literal(acurve::text) 
     || ' WHERE edge_id = ' || anedge;
 
+  --
+  -- TODO: Check if we need to update linking
+  -- We do if:
+  --   o edge is closed and we changed direction)
+  --   o edge moved to another face
+  -- 
+
   RETURN 'Edge ' || anedge || ' changed';
 
 END
index c0e2bcc57424f438c195fdd408fc434cf5b60d9b..d2278492f38927c5c1ff4fe87b2f9c078f324913 100644 (file)
@@ -33,7 +33,10 @@ SELECT topology.ST_ChangeEdgeGeom('city_data', 5,
 SELECT topology.ST_ChangeEdgeGeom('city_data', 5,
  'LINESTRING(41 40, 49 40, 49 34, 57 33)');
 
--- TODO: test changing closed edge
+-- Change a closed edge
+SELECT topology.ST_ChangeEdgeGeom('city_data', 26,
+ 'LINESTRING(4 31, 7 31, 4 34, 4 31)');
+
 -- TODO: test reverse direction of closed edge
 
 SELECT topology.DropTopology('city_data');
index a6a94142ca72013c0cd10c415ade93249df677ac..3de3f8e57ae2fcaeeb75b4719751a81428aa4bd9 100644 (file)
@@ -12,4 +12,5 @@ ERROR:  SQL/MM Spatial exception - non-existent edge 666
 ERROR:  SQL/MM Spatial exception - geometry crosses an edge
 Edge 5 changed
 Edge 5 changed
+Edge 26 changed
 Topology 'city_data' dropped