]> granicus.if.org Git - postgis/commitdiff
topology.ST_ModEdgeHeal: Check for edge existance before TopoGeometry definitions...
authorSandro Santilli <strk@keybit.net>
Fri, 6 May 2011 21:21:55 +0000 (21:21 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 6 May 2011 21:21:55 +0000 (21:21 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7108 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/sqlmm.sql
topology/test/regress/st_modedgeheal.sql
topology/test/regress/st_modedgeheal_expected

index 925c42f97ebaeb49d94eb0f1f0fbcf15fb72d489..28d1b3fc3c4debbd53ecf5797f69847aa9dc1769 100644 (file)
@@ -156,6 +156,30 @@ BEGIN
         RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name';
   END;
 
+  BEGIN
+    EXECUTE 'SELECT * FROM ' || quote_ident(toponame)
+      || '.edge_data WHERE edge_id = ' || e1id
+      INTO STRICT e1rec;
+    EXCEPTION
+      WHEN NO_DATA_FOUND THEN
+        RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e1id;
+      WHEN INVALID_SCHEMA_NAME THEN
+        RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name';
+      WHEN UNDEFINED_TABLE THEN
+        RAISE EXCEPTION 'corrupted topology "%" (missing edge_data table)',
+          toponame;
+  END;
+
+  BEGIN
+    EXECUTE 'SELECT * FROM ' || quote_ident(toponame)
+      || '.edge_data WHERE edge_id = ' || e2id
+      INTO STRICT e2rec;
+    EXCEPTION
+      WHEN NO_DATA_FOUND THEN
+        RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e2id;
+    -- NOTE: checks for INVALID_SCHEMA_NAME or UNDEFINED_TABLE done before
+  END;
+
   -- NOT IN THE SPECS:
   -- check if any topo_geom is defined only by one of the
   -- input edges. In such case there would be no way to adapt
@@ -182,29 +206,6 @@ BEGIN
           e1id, e2id;
   END LOOP;
 
-  BEGIN
-    EXECUTE 'SELECT * FROM ' || quote_ident(toponame)
-      || '.edge_data WHERE edge_id = ' || e1id
-      INTO STRICT e1rec;
-    EXCEPTION
-      WHEN NO_DATA_FOUND THEN
-        RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e1id;
-      WHEN INVALID_SCHEMA_NAME THEN
-        RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name';
-      WHEN UNDEFINED_TABLE THEN
-        RAISE EXCEPTION 'corrupted topology "%" (missing edge_data table)',
-          toponame;
-  END;
-
-  BEGIN
-    EXECUTE 'SELECT * FROM ' || quote_ident(toponame)
-      || '.edge_data WHERE edge_id = ' || e2id
-      INTO STRICT e2rec;
-    EXCEPTION
-      WHEN NO_DATA_FOUND THEN
-        RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e2id;
-    -- NOTE: checks for INVALID_SCHEMA_NAME or UNDEFINED_TABLE done before
-  END;
 
   -- NOT IN THE SPECS: See if any of the two edges are closed.
   IF e1rec.start_node = e1rec.end_node THEN
index 8c872d6135969989ea2e1e109477c05200e9a9ef..830a1bbef9294275cde19e9fb75214c21a425cb6 100644 (file)
@@ -73,8 +73,12 @@ INSERT INTO t.f VALUES ('F+E1',
 
 -- This should be forbidden, as F+E1 above could not be
 -- defined w/out one of the edges
-SELECT 'MH(1,2)', topology.ST_ModEdgeHeal('t', 1, 2);
-SELECT 'MH(2,1)', topology.ST_ModEdgeHeal('t', 2, 1);
+SELECT topology.ST_ModEdgeHeal('t', 1, 2);
+SELECT topology.ST_ModEdgeHeal('t', 2, 1);
+
+-- This is for ticket #941
+SELECT topology.ST_ModEdgeHeal('t', 1, 200);
+SELECT topology.ST_ModEdgeHeal('t', 100, 2);
 
 -- Now see how signed edges are updated
 
index decb7ce74aceb40c6dad528115f71b325030aafe..547f6dfe2862dacd030965b4d967da9d03bceb90 100644 (file)
@@ -107,6 +107,8 @@ E1
 E2
 ERROR:  TopoGeom 1 in layer 1 (t.f.g) cannot be represented healing edges 1 and 2
 ERROR:  TopoGeom 1 in layer 1 (t.f.g) cannot be represented healing edges 2 and 1
+ERROR:  SQL/MM Spatial exception – non-existent edge 200
+ERROR:  SQL/MM Spatial exception – non-existent edge 100
 E3
 E4
 2|-4