]> granicus.if.org Git - postgis/commitdiff
Catch invalid topology name passed to topogeo_add* (#1867)
authorSandro Santilli <strk@keybit.net>
Thu, 14 Jun 2012 16:06:54 +0000 (16:06 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 14 Jun 2012 16:06:54 +0000 (16:06 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9908 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/populate.sql.in.c
topology/test/regress/topogeo_addlinestring.sql
topology/test/regress/topogeo_addlinestring_expected
topology/test/regress/topogeo_addpoint.sql
topology/test/regress/topogeo_addpoint_expected
topology/test/regress/topogeo_addpolygon.sql
topology/test/regress/topogeo_addpolygon_expected

index 70953b6b894a3c612899340dd90fbb995d2a505d..492e3606edf3463f28f8ef10b1f71979777181a4 100644 (file)
@@ -42,18 +42,27 @@ $$ LANGUAGE 'sql' IMMUTABLE STRICT;
 
 -- {
 -- Get tolerance for a given topology
--- and if zero the min for a given topology
+-- and if zero the minimum for the given geometry
 --
 -- }{
 CREATE OR REPLACE FUNCTION topology._st_mintolerance(atopology varchar, ageom Geometry)
   RETURNS float8
 AS $$
+DECLARE
+  ret FLOAT8;
+BEGIN
   SELECT COALESCE(
     NULLIF(precision, 0),
     topology._st_mintolerance($2))
   FROM topology.topology
-  WHERE name = $1;
-$$ LANGUAGE 'sql' STABLE STRICT;
+  WHERE name = $1 INTO ret;
+  IF NOT FOUND THEN
+    RAISE EXCEPTION
+      'No topology with name "%" in topology.topology', atopology;
+  END IF;
+  return ret;
+END;
+$$ LANGUAGE 'plpgsql' STABLE STRICT;
 -- }
 
 --{
index 06ae4d1942a6be576c9c9269dace0402edd1d6e6..cd1d410eb7914a77906a5cd47417d3ddcb9220bf 100644 (file)
@@ -58,6 +58,7 @@ $$ LANGUAGE 'plpgsql';
 -- Invalid calls
 SELECT 'invalid', TopoGeo_addLineString('city_data', 'MULTILINESTRING((36 26, 38 30))');
 SELECT 'invalid', TopoGeo_addLineString('city_data', 'POINT(36 26)');
+SELECT 'invalid', TopoGeo_addLineString('invalid', 'LINESTRING(36 26, 0 0)');
 
 -- Isolated edge in universal face
 SELECT 'iso_uni', TopoGeo_addLineString('city_data', 'LINESTRING(36 26, 38 30)');
index eac9fe62a4d38e95be49ab3611fa32c0a311ed11..4d799644869762abd43f7445f3f01987da7e8454 100644 (file)
@@ -8,6 +8,7 @@ max|node|22
 max|edge|26
 ERROR:  Invalid geometry type (MULTILINESTRING) passed to TopoGeo_AddLinestring, expected LINESTRING
 ERROR:  Invalid geometry type (POINT) passed to TopoGeo_AddLinestring, expected LINESTRING
+ERROR:  No topology with name "invalid" in topology.topology
 iso_uni|27
 N|23||POINT(36 26)
 N|24||POINT(38 30)
index 5a93771361010752d8da6179fd8e68758c9195fd..7ea45693d6609bff3f870483a60bfddde87aaad2 100644 (file)
@@ -6,6 +6,7 @@ set client_min_messages to ERROR;
 -- Invalid calls
 SELECT 'invalid', TopoGeo_addPoint('city_data', 'LINESTRING(36 26, 38 30)');
 SELECT 'invalid', TopoGeo_addPoint('city_data', 'MULTIPOINT((36 26))');
+SELECT 'invalid', TopoGeo_addPoint('invalid', 'POINT(36 26)');
 
 -- Save max node id
 select 'node'::text as what, max(node_id) INTO city_data.limits FROM city_data.node;
index 026d2dbfaddc01a4d464da6d73e2968b16a5db27..a48f496dc338746348f17edd8bcfa6340fcf69a9 100644 (file)
@@ -6,6 +6,7 @@ t
 COMMIT
 ERROR:  Invalid geometry type (LINESTRING) passed to TopoGeo_AddPoint, expected POINT
 ERROR:  Invalid geometry type (MULTIPOINT) passed to TopoGeo_AddPoint, expected POINT
+ERROR:  No topology with name "invalid" in topology.topology
 iso_uni|23
 iso_f3|24
 iso_ex|23
index 4e415e9a7073ee926cbf7ae14985e5ca08e8eec9..7722b16c8b94d6ad7251739afab59d4acdad906c 100644 (file)
@@ -74,6 +74,7 @@ $$ LANGUAGE 'plpgsql';
 -- Invalid calls
 SELECT 'invalid', TopoGeo_addPolygon('city_data', 'MULTILINESTRING((36 26, 38 30))');
 SELECT 'invalid', TopoGeo_addPolygon('city_data', 'POINT(36 26)');
+SELECT 'invalid', TopoGeo_addPolygon('invalid', 'POLYGON((36 26, 40 24, 40 30, 36 26))');
 
 -- Isolated face in universal face
 SELECT 'iso_uni', TopoGeo_addPolygon('city_data', 'POLYGON((36 26, 38 30, 43 26, 36 26))');
index 75e316d7419a3b4b7433287a151a821323353abe..f0059eb497b66ba3f568e3ac1c6ae40289d6d50d 100644 (file)
@@ -9,6 +9,7 @@ max|edge|26
 max|face|9
 ERROR:  Invalid geometry type (MULTILINESTRING) passed to TopoGeo_AddPolygon, expected POLYGON
 ERROR:  Invalid geometry type (POINT) passed to TopoGeo_AddPolygon, expected POLYGON
+ERROR:  No topology with name "invalid" in topology.topology
 iso_uni|10
 N|23||POINT(36 26)
 E|27|sn23|en23