]> granicus.if.org Git - postgis/commitdiff
Don't consider shared nodes as edge intersections. Fixes #1428.
authorSandro Santilli <strk@keybit.net>
Tue, 3 Jan 2012 09:44:10 +0000 (09:44 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 3 Jan 2012 09:44:10 +0000 (09:44 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8648 b70326c6-7e19-0410-871a-916f4a2858ee

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

index 6e6ec7dc9375a6caadc0a261ceae819c1417f286..fda288e2419cc6303b78cbd1e0f7327643ae0172 100644 (file)
@@ -2503,16 +2503,38 @@ BEGIN
   END LOOP;
 
   --
-  -- h) Check if curve intersects any other edge
-  -- 
-  FOR rec IN EXECUTE 'SELECT * FROM '
-    || quote_ident(atopology) || '.edge_data '
-    || ' WHERE edge_id != ' || anedge
-    || ' AND ST_Intersects(geom, '
-    || quote_literal(acurve::text) || '::geometry)'
+  -- h) Check if this geometry has any interaction with any existing edge
+  --
+  FOR rec IN EXECUTE 'SELECT edge_id, ST_Relate(geom,' 
+    || quote_literal(acurve::text)
+    || '::geometry, 2) as im FROM '
+    || quote_ident(atopology)
+    || '.edge_data WHERE geom && '
+    || quote_literal(acurve::text) || '::geometry'
   LOOP
-    RAISE EXCEPTION
-    'SQL/MM Spatial exception - geometry intersects an edge';
+
+    --RAISE DEBUG 'IM=%',rec.im;
+
+    IF ST_RelateMatch(rec.im, 'F********') THEN
+      CONTINUE; -- no interior-interior intersection
+    END IF;
+
+    IF ST_RelateMatch(rec.im, '1FFF*FFF2') THEN
+      RAISE EXCEPTION
+        'SQL/MM Spatial exception - coincident edge';
+    END IF;
+
+    -- NOT IN THE SPECS: geometry touches an edge
+    IF ST_RelateMatch(rec.im, '1********') THEN
+      RAISE EXCEPTION
+        'Spatial exception - geometry intersects edge %', rec.edge_id;
+    END IF;
+
+    IF ST_RelateMatch(rec.im, 'T********') THEN
+      RAISE EXCEPTION
+        'SQL/MM Spatial exception - geometry crosses an edge';
+    END IF;
+
   END LOOP;
 
   --
index 72e2690dc284d633537bccdc1121acb9ad834b3e..cc9a5ccfac98d808945ab06882530f4df6fca2cf 100644 (file)
@@ -25,6 +25,10 @@ SELECT topology.ST_ChangeEdgeGeom('city_data', 666,
 SELECT topology.ST_ChangeEdgeGeom('city_data', 25,
  'LINESTRING(9 35, 11 40, 13 35)');
 
+-- Test change in presence of edges sharing node (#1428)
+SELECT topology.ST_ChangeEdgeGeom('city_data', 5,
+ 'LINESTRING(41 40, 57 33)');
+
 -- TODO: test changing closed edge
 -- TODO: test reverse direction of closed edge
 
index 385828afc3a3cb27078d6332f6a7b1f328cc1ca6..4fcedf1a55a86a5ce4940105e345a591734bf1a3 100644 (file)
@@ -9,5 +9,6 @@ ERROR:  SQL/MM Spatial exception - start node not geometry start point.
 ERROR:  SQL/MM Spatial exception - end node not geometry end point.
 ERROR:  SQL/MM Spatial exception - geometry crosses a node
 ERROR:  SQL/MM Spatial exception - non-existent edge 666
-ERROR:  SQL/MM Spatial exception - geometry intersects an edge
+ERROR:  SQL/MM Spatial exception - geometry crosses an edge
+Edge 5 changed
 Topology 'city_data' dropped