]> granicus.if.org Git - postgis/commitdiff
Clearer error on setting an geometry to an invalid one (#1774)
authorSandro Santilli <strk@keybit.net>
Tue, 12 Jun 2012 12:34:23 +0000 (12:34 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 12 Jun 2012 12:34:23 +0000 (12:34 +0000)
Include testcase

git-svn-id: http://svn.osgeo.org/postgis/trunk@9899 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/sqlmm.sql.in.c
topology/test/regress/st_changeedgegeom.sql
topology/test/regress/st_changeedgegeom_expected

index 8bb8bd31ec79cf82643b9fb81bc57a375031516b..b6d0b3110366415f4c62d284cc79082f790ac118 100644 (file)
@@ -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));
index b00239ebeb6070e176fb6f16247eafe8bcaf6f38..f995e47c4907e197373451b406d2128e5bf832ab 100644 (file)
@@ -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)');
index fb7476559ea44830c3e106d089836aa7b4519d38..34525f93fc6b18d566097a7e664504379635a88b 100644 (file)
@@ -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