-- 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;
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');
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