]> granicus.if.org Git - postgis/commitdiff
Closer-to-iso exceptions from ST_GetFaceEdges/ST_ModEdgeHeal [RT-SIGTA]
authorSandro Santilli <strk@keybit.net>
Fri, 6 May 2011 06:46:58 +0000 (06:46 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 6 May 2011 06:46:58 +0000 (06:46 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7105 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/sqlmm.sql
topology/test/regress/st_getfaceedges.sql
topology/test/regress/st_getfaceedges_expected
topology/test/regress/st_modedgeheal_expected

index 11b92cebcb27dabcbb2e9b1dfee4a0390ad207fe..925c42f97ebaeb49d94eb0f1f0fbcf15fb72d489 100644 (file)
@@ -54,6 +54,10 @@ BEGIN
     RAISE EXCEPTION 'SQL/MM Spatial exception - null argument';
   END IF;
 
+  IF toponame = '' THEN
+        RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name';
+  END IF;
+
   n := 1;
 
   -- Construct the face geometry, then for each polygon:
@@ -149,7 +153,7 @@ BEGIN
       INTO STRICT topoid WHERE name = toponame;
     EXCEPTION
       WHEN NO_DATA_FOUND THEN
-        RAISE EXCEPTION 'unknown topology "%"', toponame;
+        RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name';
   END;
 
   -- NOT IN THE SPECS:
@@ -186,7 +190,7 @@ BEGIN
       WHEN NO_DATA_FOUND THEN
         RAISE EXCEPTION 'SQL/MM Spatial exception – non-existent edge %', e1id;
       WHEN INVALID_SCHEMA_NAME THEN
-        RAISE EXCEPTION 'non-existent topology schema "%"', toponame;
+        RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name';
       WHEN UNDEFINED_TABLE THEN
         RAISE EXCEPTION 'corrupted topology "%" (missing edge_data table)',
           toponame;
@@ -349,32 +353,39 @@ LANGUAGE 'plpgsql' VOLATILE;
 --
 --  ST_GetFaceGeometry(atopology, aface)
 -- 
-CREATE OR REPLACE FUNCTION topology.ST_GetFaceGeometry(varchar, integer)
+CREATE OR REPLACE FUNCTION topology.ST_GetFaceGeometry(toponame varchar, aface integer)
        RETURNS GEOMETRY AS
 $$
 DECLARE
-       atopology ALIAS FOR $1;
-       aface ALIAS FOR $2;
        rec RECORD;
 BEGIN
-       --
-       -- Atopology and aface are required
-       -- 
-       IF atopology IS NULL OR aface IS NULL THEN
-               RAISE EXCEPTION
-                'SQL/MM Spatial exception - null argument';
-       END IF;
 
-       --
-       -- Construct face 
-       -- 
-       FOR rec IN EXECUTE 'SELECT ST_BuildArea(ST_Collect(geom)) FROM '
-               || quote_ident(atopology)
-               || '.edge WHERE left_face = ' || aface || 
-               ' OR right_face = ' || aface 
-       LOOP
-               RETURN rec.st_buildarea;
-       END LOOP;
+  --
+  -- toponame and aface are required
+  -- 
+  IF toponame IS NULL OR aface IS NULL THEN
+  RAISE EXCEPTION
+    'SQL/MM Spatial exception - null argument';
+  END IF;
+
+    --
+    -- Construct face 
+    -- 
+    BEGIN
+      FOR rec IN EXECUTE 'SELECT ST_BuildArea(ST_Collect(geom)) FROM '
+        || quote_ident(toponame)
+        || '.edge WHERE left_face = ' || aface || 
+        ' OR right_face = ' || aface 
+      LOOP
+        RETURN rec.st_buildarea;
+      END LOOP;
+    EXCEPTION
+      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;
 
 
        --
index 408eda5be6fa36abc23fd8bdb35e2d0f3b223dde..6398bcd12792585c616da4d8062f990460478951 100644 (file)
@@ -2,6 +2,12 @@ set client_min_messages to ERROR;
 
 SELECT topology.CreateTopology('tt') > 0;
 
+SELECT topology.ST_GetFaceEdges(null, null);
+SELECT topology.ST_GetFaceEdges('tt', null);
+SELECT topology.ST_GetFaceEdges(null, 1);
+SELECT topology.ST_GetFaceEdges('', 1);
+SELECT topology.ST_GetFaceEdges('NonExistent', 1);
+
 SELECT 'E'||topology.AddEdge('tt', 'LINESTRING(2 2, 2  8)');        -- 1
 SELECT 'E'||topology.AddEdge('tt', 'LINESTRING(2  8,  8  8)');      -- 2
 SELECT 'E'||topology.AddEdge('tt', 'LINESTRING(8  8,  8 2, 2 2)');  -- 3
index 05a5109ebe7d7b3b93300346de02e9413ac2dea9..f95751d8dbf6c13a61bc21ff1a48038e2634cdee 100644 (file)
@@ -1,4 +1,9 @@
 t
+ERROR:  SQL/MM Spatial exception - null argument
+ERROR:  SQL/MM Spatial exception - null argument
+ERROR:  SQL/MM Spatial exception - null argument
+ERROR:  SQL/MM Spatial exception - invalid topology name
+ERROR:  SQL/MM Spatial exception - invalid topology name
 E1
 E2
 E3
index dc0072fddb955c7a38f72084c0782e7b60cd9eb4..decb7ce74aceb40c6dad528115f71b325030aafe 100644 (file)
@@ -7,7 +7,7 @@ COMMIT
 ERROR:  SQL/MM Spatial exception - null argument
 ERROR:  SQL/MM Spatial exception - null argument
 ERROR:  SQL/MM Spatial exception - null argument
-ERROR:  unknown topology ""
+ERROR:  SQL/MM Spatial exception - invalid topology name
 ERROR:  SQL/MM Spatial exception – non-connected edges
 ERROR:  SQL/MM Spatial exception – other edges connected (ie: 19)
 ERROR:  Edge 2 is closed, cannot heal to edge 3