From f94c1a3de44e444e7d6d752b887a2ac25db032db Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 23 May 2011 12:33:12 +0000 Subject: [PATCH] Put tests for ST_AddIsoEdge in their own file. Fix use of ! rather than "not" for negating booleans in pl/pgsql. git-svn-id: http://svn.osgeo.org/postgis/trunk@7211 b70326c6-7e19-0410-871a-916f4a2858ee --- topology/sql/sqlmm.sql | 2 +- topology/test/Makefile | 1 + topology/test/regress/sqlmm.sql | 6 +-- topology/test/regress/sqlmm_expected | 2 +- topology/test/regress/st_addisoedge.sql | 54 ++++++++++++++++++++ topology/test/regress/st_addisoedge_expected | 23 +++++++++ 6 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 topology/test/regress/st_addisoedge.sql create mode 100644 topology/test/regress/st_addisoedge_expected diff --git a/topology/sql/sqlmm.sql b/topology/sql/sqlmm.sql index c1e4aa5e8..c397c13ea 100644 --- a/topology/sql/sqlmm.sql +++ b/topology/sql/sqlmm.sql @@ -1611,7 +1611,7 @@ BEGIN -- -- Check acurve to be within face -- - IF ! ST_Within(acurve, face) THEN + IF NOT ST_Within(acurve, face) THEN RAISE EXCEPTION 'SQL/MM Spatial exception - geometry not within face.'; END IF; diff --git a/topology/test/Makefile b/topology/test/Makefile index 51c0e539a..1779ab394 100644 --- a/topology/test/Makefile +++ b/topology/test/Makefile @@ -28,6 +28,7 @@ TESTS = regress/legacy_validate.sql regress/legacy_predicate.sql \ regress/addedge.sql regress/addface.sql \ regress/addface2.5d.sql \ regress/polygonize.sql \ + regress/st_addisoedge.sql \ regress/st_addedgenewfaces.sql \ regress/st_getfacegeometry.sql \ regress/st_getfaceedges.sql \ diff --git a/topology/test/regress/sqlmm.sql b/topology/test/regress/sqlmm.sql index 2af11f62c..08a61f45d 100644 --- a/topology/test/regress/sqlmm.sql +++ b/topology/test/regress/sqlmm.sql @@ -1,9 +1,5 @@ set client_min_messages to WARNING; --- --- -SELECT topology.DropTopology('sqlmm_topology'); - -- -- ST_InitTopoGeo -- @@ -158,3 +154,5 @@ SELECT topology.ST_RemoveIsoEdge('sqlmm_topology', 1); SELECT '-- ST_NewEdgesSplit ---------------------'; SELECT topology.ST_NewEdgesSplit('sqlmm_topology', 2, 'POINT(10 2)'); + +SELECT topology.DropTopology('sqlmm_topology'); diff --git a/topology/test/regress/sqlmm_expected b/topology/test/regress/sqlmm_expected index d75b5870d..a3472bc7f 100644 --- a/topology/test/regress/sqlmm_expected +++ b/topology/test/regress/sqlmm_expected @@ -1,4 +1,3 @@ -Topology 'sqlmm_topology' dropped Topology-Geometry 'sqlmm_topology' (id:4) created. -- ST_AddIsoNode ------------------------ ERROR: SQL/MM Spatial exception - null argument @@ -54,3 +53,4 @@ ERROR: SQL/MM Spatial exception - invalid point Isolated edge 1 removed -- ST_NewEdgesSplit --------------------- 9 +Topology 'sqlmm_topology' dropped diff --git a/topology/test/regress/st_addisoedge.sql b/topology/test/regress/st_addisoedge.sql new file mode 100644 index 000000000..fe4484935 --- /dev/null +++ b/topology/test/regress/st_addisoedge.sql @@ -0,0 +1,54 @@ +set client_min_messages to WARNING; + +SELECT topology.CreateTopology('sqlmm_topology') > 0; + +-- Put some points in +INSERT INTO sqlmm_topology.node (containing_face, geom) VALUES + (0, 'POINT(0 0)') RETURNING 'N' || node_id; -- 1 +INSERT INTO sqlmm_topology.node (containing_face, geom) VALUES + (0, 'POINT(10 0)') RETURNING 'N' || node_id; -- 2 +INSERT INTO sqlmm_topology.node (containing_face, geom) VALUES + (0, 'POINT(5 0)') RETURNING 'N' || node_id; -- 3 +INSERT INTO sqlmm_topology.node (containing_face, geom) VALUES + (0, 'POINT(5 10)') RETURNING 'N' || node_id; -- 4 +INSERT INTO sqlmm_topology.node (containing_face, geom) VALUES + (0, 'POINT(10 10)') RETURNING 'N' || node_id; -- 5 +INSERT INTO sqlmm_topology.node (containing_face, geom) VALUES + (0, 'POINT(20 10)') RETURNING 'N' || node_id; -- 6 + +-- null input +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, 2, NULL); +SELECT topology.ST_AddIsoEdge(NULL, 1, 2, 'LINESTRING(0 0, 1 1)'); +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, NULL, 'LINESTRING(0 0, 1 1)'); +SELECT topology.ST_AddIsoEdge('sqlmm_topology', NULL, 2, 'LINESTRING(0 0, 1 1)'); + +-- invalid curve +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, 2, 'POINT(0 0)'); + +-- non-simple curve +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, 2, 'LINESTRING(0 0, 10 0, 5 5, 5 -5)'); + +-- non-existing nodes +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 10000, 2, 'LINESTRING(0 0, 1 1)'); + +-- Curve endpoints mismatch +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, 2, 'LINESTRING(0 0, 1 1)'); +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, 2, 'LINESTRING(0 1, 10 0)'); + +-- Node crossing +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, 2, 'LINESTRING(0 0, 10 0)'); + +-- Good ones +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 4, 5, 'LINESTRING(5 10, 5 9, 10 10)'); +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, 2, 'LINESTRING(0 0, 2 1, 10 5, 10 0)'); + +-- Not isolated edge (shares endpoint with previous) +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 4, 6, 'LINESTRING(5 10, 10 9, 20 10)'); +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 5, 6, 'LINESTRING(10 10, 20 10)'); + +-- Edge intersection (geometry intersects an edge) +SELECT topology.ST_AddIsoEdge('sqlmm_topology', 1, 2, 'LINESTRING(0 0, 2 20, 10 0)'); + +-- on different faces (TODO req. nodes contained in face) + +SELECT topology.DropTopology('sqlmm_topology'); diff --git a/topology/test/regress/st_addisoedge_expected b/topology/test/regress/st_addisoedge_expected new file mode 100644 index 000000000..16963d864 --- /dev/null +++ b/topology/test/regress/st_addisoedge_expected @@ -0,0 +1,23 @@ +t +N1 +N2 +N3 +N4 +N5 +N6 +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 - null argument +ERROR: SQL/MM Spatial exception - invalid curve +ERROR: SQL/MM Spatial exception - curve not simple +ERROR: SQL/MM Spatial exception - non-existent node +ERROR: SQL/MM Spatial exception - end node not geometry end point. +ERROR: SQL/MM Spatial exception - start node not geometry start point. +ERROR: SQL/MM Spatial exception - geometry crosses a node +1 +2 +ERROR: SQL/MM Spatial exception - not isolated node +ERROR: SQL/MM Spatial exception - not isolated node +ERROR: SQL/MM Spatial exception - not isolated node +Topology 'sqlmm_topology' dropped -- 2.50.1