From fd6d6d0f67c98c095d38c8ff1a4845ca50278844 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 12 Jun 2012 12:34:23 +0000 Subject: [PATCH] Clearer error on setting an geometry to an invalid one (#1774) Include testcase git-svn-id: http://svn.osgeo.org/postgis/trunk@9899 b70326c6-7e19-0410-871a-916f4a2858ee --- topology/sql/sqlmm.sql.in.c | 7 ++++++- topology/test/regress/st_changeedgegeom.sql | 8 ++++++++ topology/test/regress/st_changeedgegeom_expected | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/topology/sql/sqlmm.sql.in.c b/topology/sql/sqlmm.sql.in.c index 8bb8bd31e..b6d0b3110 100644 --- a/topology/sql/sqlmm.sql.in.c +++ b/topology/sql/sqlmm.sql.in.c @@ -2547,7 +2547,7 @@ BEGIN WHERE p.sequence = CASE WHEN m.sequence-1 < 1 THEN cnt ELSE m.sequence-1 END ), ( - SELECT p.edge AS prev FROM edgestar p WHERE p.sequence = ((m.sequence)%cnt)+1 + SELECT p.edge AS prev FROM edgestar p WHERE p.sequence = ((m.sequence)%cnt)+1 ) ] FROM edgestar m WHERE edge = anedge @@ -2642,7 +2642,12 @@ BEGIN -- (should be part of isomorphism checking) range := ST_MakePolygon(oldedge.geom); iscw := ST_OrderingEquals(range, ST_ForceRHR(range)); + + IF ST_NumPoints(ST_RemoveRepeatedPoints(acurve)) < 3 THEN + RAISE EXCEPTION 'Invalid edge (no two distinct vertices exist)'; + END IF; range := ST_MakePolygon(acurve); + IF iscw != ST_OrderingEquals(range, ST_ForceRHR(range)) THEN RAISE EXCEPTION 'Edge twist at node %', ST_AsText(ST_StartPoint(oldedge.geom)); diff --git a/topology/test/regress/st_changeedgegeom.sql b/topology/test/regress/st_changeedgegeom.sql index b00239ebe..f995e47c4 100644 --- a/topology/test/regress/st_changeedgegeom.sql +++ b/topology/test/regress/st_changeedgegeom.sql @@ -17,6 +17,14 @@ SELECT topology.ST_ChangeEdgeGeom('city_data', 25, SELECT topology.ST_ChangeEdgeGeom('city_data', 3, 'LINESTRING(25 30, 20 36, 20 38, 25 35)'); +-- Non-simple edge +SELECT topology.ST_ChangeEdgeGeom('city_data', 1, + 'LINESTRING(8 30, 9 30, 8 30)'); + +-- Dimensionally collapsed edge (#1774) +SELECT topology.ST_ChangeEdgeGeom('city_data', 1, + 'LINESTRING(8 30, 8 30, 8 30)'); + -- Non-existent edge (#979) SELECT topology.ST_ChangeEdgeGeom('city_data', 666, 'LINESTRING(25 30, 20 36, 20 38, 25 35)'); diff --git a/topology/test/regress/st_changeedgegeom_expected b/topology/test/regress/st_changeedgegeom_expected index fb7476559..34525f93f 100644 --- a/topology/test/regress/st_changeedgegeom_expected +++ b/topology/test/regress/st_changeedgegeom_expected @@ -8,6 +8,8 @@ T1|Edge 25 changed ERROR: SQL/MM Spatial exception - start node not geometry start point. ERROR: SQL/MM Spatial exception - end node not geometry end point. ERROR: SQL/MM Spatial exception - geometry crosses a node +ERROR: SQL/MM Spatial exception - curve not simple +ERROR: Invalid edge (no two distinct vertices exist) ERROR: SQL/MM Spatial exception - non-existent edge 666 ERROR: SQL/MM Spatial exception - geometry crosses edge 1 T2|Edge 5 changed -- 2.40.0