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:
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:
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;
--
-- 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;
--
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
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