From dee57bfb5f0c121d0a41e4d7f3d1416bc74a94d5 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 13 Dec 2012 09:34:48 +0000 Subject: [PATCH] Revert "Return NULL when simplifying a line results in a line with < 2 vertices" 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 | 1 - liblwgeom/lwcollection.c | 11 +++-------- liblwgeom/lwline.c | 15 ++------------- liblwgeom/lwpoly.c | 2 +- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/NEWS b/NEWS index bcb738eb5..6375a03db 100644 --- 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 diff --git a/liblwgeom/lwcollection.c b/liblwgeom/lwcollection.c index d33d70901..fd95b7dbd 100644 --- a/liblwgeom/lwcollection.c +++ b/liblwgeom/lwcollection.c @@ -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; diff --git a/liblwgeom/lwline.c b/liblwgeom/lwline.c index fc378b166..30de4ad41 100644 --- a/liblwgeom/lwline.c +++ b/liblwgeom/lwline.c @@ -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; } diff --git a/liblwgeom/lwpoly.c b/liblwgeom/lwpoly.c index abe9e4f59..52c27fad9 100644 --- a/liblwgeom/lwpoly.c +++ b/liblwgeom/lwpoly.c @@ -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++) { -- 2.50.1