]> granicus.if.org Git - postgis/commitdiff
Revert "Return NULL when simplifying a line results in a line with < 2 vertices"
authorSandro Santilli <strk@keybit.net>
Thu, 13 Dec 2012 09:34:48 +0000 (09:34 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 13 Dec 2012 09:34:48 +0000 (09:34 +0000)
The correct behavior is still being discussed here:
http://trac.osgeo.org/postgis/ticket/1987
Better reduce the noise...

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

NEWS
liblwgeom/lwcollection.c
liblwgeom/lwline.c
liblwgeom/lwpoly.c

diff --git a/NEWS b/NEWS
index bcb738eb50a2f083840b1985926ed570c8e0ba7c..6375a03db378312fe6dbf5552b8d32d484728584 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,7 +13,6 @@ PostGIS 2.1.0
   - ST_Slope and ST_Aspect return pixel values in degrees instead of radians.
   - #1653, Removed srid parameter from ST_Resample(raster) and variants
     with reference raster no longer apply reference raster's SRID.
-  - ST_Simplify returns NULL on EMPTY input or single-vertex line output
 
 * Deprecated signatures
 
index d33d70901864b60e0dfefddf105702ca5f994d02..fd95b7dbd7ba788a0ea48cf0725e27fdeba149b6 100644 (file)
@@ -496,20 +496,15 @@ int lwcollection_count_vertices(LWCOLLECTION *col)
 LWCOLLECTION* lwcollection_simplify(const LWCOLLECTION *igeom, double dist)
 {
        int i;
-       LWCOLLECTION *out = NULL;
+       LWCOLLECTION *out = lwcollection_construct_empty(igeom->type, igeom->srid, FLAGS_GET_Z(igeom->flags), FLAGS_GET_M(igeom->flags));
 
        if( lwcollection_is_empty(igeom) )
-               return NULL;
+               return out; /* should we return NULL instead ? */
 
        for( i = 0; i < igeom->ngeoms; i++ )
        {
                LWGEOM *ngeom = lwgeom_simplify(igeom->geoms[i], dist);
-               if ( ngeom ) {
-                       if ( ! out ) {
-                               out = lwcollection_construct_empty(igeom->type, igeom->srid, FLAGS_GET_Z(igeom->flags), FLAGS_GET_M(igeom->flags));
-                       }
-                       out = lwcollection_add_lwgeom(out, ngeom);
-               }
+               if ( ngeom ) out = lwcollection_add_lwgeom(out, ngeom);
        }
 
        return out;
index fc378b166a49adfc9f4fece1b1d3322088f93995..30de4ad41759ce98a256782fe6fb515417dc19e1 100644 (file)
@@ -473,26 +473,15 @@ int lwline_count_vertices(LWLINE *line)
 LWLINE* lwline_simplify(const LWLINE *iline, double dist)
 {
        LWLINE *oline;
-       POINTARRAY *opts;
 
        LWDEBUG(2, "function called");
 
        /* Skip empty case */
        if( lwline_is_empty(iline) )
-               return NULL;
+               return lwline_clone(iline);
                
        static const int minvertices = 0; /* TODO: allow setting this */
-       opts = ptarray_simplify(iline->points, dist, minvertices);
-
-       /* Less points than are needed to form a line, we can't use this */
-       if ( opts->npoints < 2 )
-       {
-                       LWDEBUGF(3, "line skipped (% pts)", opts->npoints);
-                       ptarray_free(opts);
-                       return NULL;
-       }
-
-       oline = lwline_construct(iline->srid, NULL, opts);
+       oline = lwline_construct(iline->srid, NULL, ptarray_simplify(iline->points, dist, minvertices));
        oline->type = iline->type;
        return oline;
 }
index abe9e4f599f3d4b8b60d12e9e0c3f0d74e82ebb9..52c27fad987e40adfc799efb4f0bd9582cf611c0 100644 (file)
@@ -350,7 +350,7 @@ LWPOLY* lwpoly_simplify(const LWPOLY *ipoly, double dist)
        LWDEBUGF(2, "simplify_polygon3d: simplifying polygon with %d rings", ipoly->nrings);
 
        if( lwpoly_is_empty(ipoly) )
-               return NULL;
+               return opoly; /* should we return NULL instead ? */
 
        for (i = 0; i < ipoly->nrings; i++)
        {