[postgis-tickets] r14494 - #3388, ST_RemoveRepeatedPoints can change endpoint
Paul Ramsey
pramsey at cleverelephant.ca
Thu Dec 17 11:18:54 PST 2015
Author: pramsey
Date: 2015-12-17 11:18:53 -0800 (Thu, 17 Dec 2015)
New Revision: 14494
Modified:
branches/2.2/NEWS
branches/2.2/liblwgeom/ptarray.c
branches/2.2/regress/remove_repeated_points.sql
branches/2.2/regress/remove_repeated_points_expected
Log:
#3388, ST_RemoveRepeatedPoints can change endpoint
Modified: branches/2.2/NEWS
===================================================================
--- branches/2.2/NEWS 2015-12-17 19:14:55 UTC (rev 14493)
+++ branches/2.2/NEWS 2015-12-17 19:18:53 UTC (rev 14494)
@@ -17,6 +17,7 @@
- #3375, crash in repeated point removal for collection(point)
- #3378, Fix handling of hierarchical TopoGeometries with
of multiple topologies
+ - #3388, Fix missing end-points in ST_Removepoints
PostGIS 2.2.0
Modified: branches/2.2/liblwgeom/ptarray.c
===================================================================
--- branches/2.2/liblwgeom/ptarray.c 2015-12-17 19:14:55 UTC (rev 14493)
+++ branches/2.2/liblwgeom/ptarray.c 2015-12-17 19:18:53 UTC (rev 14494)
@@ -1426,18 +1426,22 @@
/* Now fill up the actual points (NOTE: could be optimized) */
opn=1;
+ /* Keep the first point */
memcpy(getPoint_internal(out, 0), getPoint_internal(in, 0), ptsize);
last_point = getPoint2d_cp(in, 0);
LWDEBUGF(3, " first point copied, out points: %d", opn);
for ( ipn = 1; ipn < in->npoints; ++ipn)
{
this_point = getPoint2d_cp(in, ipn);
- if ( (ipn >= in->npoints-minpoints+1 && opn < minpoints) ||
- (tolerance == 0 && memcmp(getPoint_internal(in, ipn-1), getPoint_internal(in, ipn), ptsize) != 0) ||
- (tolerance > 0.0 && distance2d_sqr_pt_pt(last_point, this_point) > tolsq) )
+ if ( (ipn >= in->npoints-minpoints+1 && opn < minpoints) || /* need extra points to hit minponts */
+ (ipn == in->npoints-1 && memcmp(getPoint_internal(in, ipn-1), getPoint_internal(in, ipn), ptsize) != 0) || /* last point (and not exact dupe) */
+ (tolerance == 0 && memcmp(getPoint_internal(in, ipn-1), getPoint_internal(in, ipn), ptsize) != 0) || /* not an exact dupe */
+ (tolerance > 0.0 && distance2d_sqr_pt_pt(last_point, this_point) > tolsq) ) /* not within the removal tolerance */
{
- /* The point is different from the previous,
- * we add it to output */
+ /*
+ * The point is different (see above) from the previous,
+ * so we add it to output
+ */
memcpy(getPoint_internal(out, opn++), getPoint_internal(in, ipn), ptsize);
last_point = this_point;
LWDEBUGF(3, " Point %d differs from point %d. Out points: %d", ipn, ipn-1, opn);
Modified: branches/2.2/regress/remove_repeated_points.sql
===================================================================
--- branches/2.2/regress/remove_repeated_points.sql 2015-12-17 19:14:55 UTC (rev 14493)
+++ branches/2.2/regress/remove_repeated_points.sql 2015-12-17 19:18:53 UTC (rev 14494)
@@ -21,4 +21,5 @@
SELECT 11, ST_AsText(ST_RemoveRepeatedPoints('LINESTRING(0 0, 0 0, 0 0, 0 0, 0 0)'));
SELECT 12, ST_SRID(ST_RemoveRepeatedPoints('SRID=3;LINESTRING(0 0, 0 0, 0 0, 0 0, 0 0)'));
SELECT 13, ST_AsText(ST_RemoveRepeatedPoints('LINESTRING(0 0, 1 0, 2 0, 3 0, 4 0)',1.5));
+SELECT 14, ST_AsText(ST_RemoveRepeatedPoints('LINESTRING(10 0,10 9,10 10)', 2));
Modified: branches/2.2/regress/remove_repeated_points_expected
===================================================================
--- branches/2.2/regress/remove_repeated_points_expected 2015-12-17 19:14:55 UTC (rev 14493)
+++ branches/2.2/regress/remove_repeated_points_expected 2015-12-17 19:18:53 UTC (rev 14494)
@@ -12,3 +12,4 @@
11|LINESTRING(0 0,0 0)
12|3
13|LINESTRING(0 0,2 0,4 0)
+14|LINESTRING(10 0,10 9,10 10)
More information about the postgis-tickets
mailing list