]> granicus.if.org Git - postgis/commitdiff
ST_GetFaceGeometry: throw SQL/MM exception when asked for the Universal Face geometry...
authorSandro Santilli <strk@keybit.net>
Tue, 24 May 2011 13:49:18 +0000 (13:49 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 24 May 2011 13:49:18 +0000 (13:49 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7234 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/sqlmm.sql
topology/test/regress/st_getfacegeometry.sql
topology/test/regress/st_getfacegeometry_expected

index 1c444ce103633a29a1e0209a23423ee4e7ec0aa0..23f4908a63c37aebcec09b670cf26a46ea0c6665 100644 (file)
@@ -643,35 +643,42 @@ BEGIN
   -- 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;
+    RAISE EXCEPTION 'SQL/MM Spatial exception - null argument';
+  END IF;
+
+  IF toponame = '' THEN
+    RAISE EXCEPTION 'SQL/MM Spatial exception - invalid topology name';
+  END IF;
+
+  IF aface = 0 THEN
+    RAISE EXCEPTION
+      'SQL/MM Spatial exception - universal face has no geometry';
+  END IF;
+
+  --
+  -- Construct face 
+  -- 
+  BEGIN
+    FOR rec IN EXECUTE 'SELECT ST_BuildArea(ST_Collect(geom)) FROM '
+      || quote_ident(toponame)
+      || '.edge_data 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;
 
 
   --
   -- No face found
   -- 
-  RAISE EXCEPTION
-  'SQL/MM Spatial exception - non-existent face.';
+  RAISE EXCEPTION 'SQL/MM Spatial exception - non-existent face.';
 END
 $$
 LANGUAGE 'plpgsql' VOLATILE;
index 15f9d16c83911f9b7ab2e0f1484a46b24a007004..edac609424d3c0a3bcb5c938cc6002ec0377417e 100644 (file)
@@ -24,15 +24,21 @@ COPY tt.edge_data(
 3      3       3       3       3       3       -3      0       3       LINESTRING(12 2, 12 8, 18 8, 18 2, 12 2)
 \.
 
-SELECT * FROM topology.ValidateTopology('tt');
-
 -- F1 should have an hole !
 -- See http://trac.osgeo.org/postgis/ticket/726
 SELECT 'f1 (with hole)', ST_asText(topology.st_getfacegeometry('tt', 1));
 SELECT 'f2 (fill hole)', ST_asText(topology.st_getfacegeometry('tt', 2));
 
--- Universal face is the union of all faces
+-- Universal face has no geometry
 -- See http://trac.osgeo.org/postgis/ticket/973
-SELECT 'f0', ST_AsText(topology.st_getfacegeometry('tt', 0));
+SELECT topology.st_getfacegeometry('tt', 0);
+
+-- Null arguments
+SELECT topology.st_getfacegeometry(null, 1);
+SELECT topology.st_getfacegeometry('tt', null);
+
+-- Invalid topology names
+SELECT topology.st_getfacegeometry('NonExistent', 1);
+SELECT topology.st_getfacegeometry('', 1);
 
 SELECT topology.DropTopology('tt');
index 770bef25d501271a74eae339f5f1cad18bf93ee8..7bd616c77fa1d0b9a217f24cf50d5a58ec987745 100644 (file)
@@ -1,5 +1,9 @@
 t
 f1 (with hole)|POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,8 2,8 8,2 8,2 2))
 f2 (fill hole)|POLYGON((2 2,2 8,8 8,8 2,2 2))
-f0|MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((12 2,12 8,18 8,18 2,12 2)))
+ERROR:  SQL/MM Spatial exception - universal face has no geometry
+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
 Topology 'tt' dropped