]> granicus.if.org Git - postgis/commitdiff
#2293: patch to throw an error for curved geoms on ST_DumpPoints rather than crash.
authorRegina Obe <lr@pcorp.us>
Sat, 4 May 2013 01:16:37 +0000 (01:16 +0000)
committerRegina Obe <lr@pcorp.us>
Sat, 4 May 2013 01:16:37 +0000 (01:16 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@11346 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_dumppoints.c
regress/dumppoints.sql
regress/dumppoints_expected

index 6e42daaec0de3d97fc8a4d1dd3d525448141ee10..9559cb100a94e9e93d8a44198ec978d56159d7d5 100644 (file)
@@ -192,18 +192,17 @@ Datum LWGEOM_dumppoints(PG_FUNCTION_ARGS) {
                                        if (state->pt == 0) lwpoint = lwgeom_as_lwpoint(lwgeom);
                                        break;
                                case LINETYPE:
-                               case CIRCSTRINGTYPE:
                                        line = lwgeom_as_lwline(lwgeom);
                                        if (line->points && state->pt <= line->points->npoints) {
                                                lwpoint = lwline_get_lwpoint((LWLINE*)lwgeom, state->pt);
                                        }
                                        break;
-                               case CURVEPOLYTYPE:
+                               case CIRCSTRINGTYPE:
+                                       ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
+                                               errmsg("Invalid Geometry type circstring passed to ST_DumpPoints()")));
                                default:
-                                       /* TODO error? */
-                                       if (--state->stacklen == 0) SRF_RETURN_DONE(funcctx);
-                                       state->pathlen--;
-                                       continue;
+                                       ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
+                                               errmsg("Invalid Geometry type passed to ST_DumpPoints()")));
                        }
 
                        /*
index 7c85f21577cc002623268057cf85854446f3b789..8ad24ded1fdecce45cd6a3b8ed357d17c564dfe6 100644 (file)
@@ -157,3 +157,23 @@ FROM (
         )'::geometry AS geom
     ) AS g
   ) j;
+
+SELECT path, ST_AsText(geom) 
+FROM (
+  SELECT (ST_DumpPoints(g.geom)).* 
+  FROM
+       (SELECT 'SRID=4326;CURVEPOLYGON(
+                       CIRCULARSTRING(-71.0821 42.3036, -71.4821 42.3036,
+                               -71.7821 42.7036, -71.0821 42.7036, -71.0821 42.3036),
+                       (-71.1821 42.4036, -71.3821 42.6036, -71.3821 42.4036, -71.1821 42.4036)
+ )'::geometry as geom
+) as g
+) j;
+
+SELECT path, ST_AsText(geom) 
+FROM (
+  SELECT (ST_DumpPoints(g.geom)).* 
+  FROM (
+SELECT 'CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0),(1 1, 3 3, 3 1, 1 1))'::geometry as geom
+) as g
+) j;
index 78b41ddbf0d9681d15d62fe0df19ec9d31d1cbfe..a2b384fa9640dc07a29ae701c2a8dbd1a27a1e46 100644 (file)
@@ -82,3 +82,5 @@
 {5,1,2,2}|POINT(5 6)
 {5,1,2,3}|POINT(6 6)
 {5,1,2,4}|POINT(5 5)
+ERROR:  Invalid Geometry type circstring passed to ST_DumpPoints()
+ERROR:  Invalid Geometry type circstring passed to ST_DumpPoints()