[postgis-tickets] r15637 - #3670, Tolerance silently ignored in ST_RemoveRepeatedPoint for multipoint
Paul Ramsey
pramsey at cleverelephant.ca
Wed Sep 6 09:20:19 PDT 2017
Author: pramsey
Date: 2017-09-06 09:20:19 -0700 (Wed, 06 Sep 2017)
New Revision: 15637
Modified:
trunk/liblwgeom/lwmpoint.c
trunk/regress/remove_repeated_points.sql
trunk/regress/remove_repeated_points_expected
Log:
#3670, Tolerance silently ignored in ST_RemoveRepeatedPoint for multipoint
Modified: trunk/liblwgeom/lwmpoint.c
===================================================================
--- trunk/liblwgeom/lwmpoint.c 2017-09-06 05:39:59 UTC (rev 15636)
+++ trunk/liblwgeom/lwmpoint.c 2017-09-06 16:20:19 UTC (rev 15637)
@@ -94,28 +94,31 @@
uint32_t nnewgeoms;
uint32_t i, j;
LWGEOM **newgeoms;
-
+ LWGEOM *lwpt1, *lwpt2;
+
newgeoms = lwalloc(sizeof(LWGEOM *)*mpoint->ngeoms);
nnewgeoms = 0;
for (i=0; i<mpoint->ngeoms; ++i)
{
+ lwpt1 = (LWGEOM*)mpoint->geoms[i];
/* Brute force, may be optimized by building an index */
int seen=0;
for (j=0; j<nnewgeoms; ++j)
{
- if ( lwpoint_same((LWPOINT*)newgeoms[j],
- (LWPOINT*)mpoint->geoms[i]) )
+ lwpt2 = (LWGEOM*)newgeoms[j];
+ if ( lwgeom_mindistance2d(lwpt1, lwpt2) <= tolerance )
{
seen=1;
break;
}
}
if ( seen ) continue;
- newgeoms[nnewgeoms++] = (LWGEOM*)lwpoint_clone(mpoint->geoms[i]);
+ newgeoms[nnewgeoms++] = lwgeom_clone_deep(lwpt1);
}
return (LWGEOM*)lwcollection_construct(mpoint->type,
- mpoint->srid, mpoint->bbox ? gbox_copy(mpoint->bbox) : NULL,
+ mpoint->srid,
+ mpoint->bbox ? gbox_copy(mpoint->bbox) : NULL,
nnewgeoms, newgeoms);
}
Modified: trunk/regress/remove_repeated_points.sql
===================================================================
--- trunk/regress/remove_repeated_points.sql 2017-09-06 05:39:59 UTC (rev 15636)
+++ trunk/regress/remove_repeated_points.sql 2017-09-06 16:20:19 UTC (rev 15637)
@@ -23,3 +23,9 @@
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));
+-- #3670
+SELECT 15, ST_AsText(ST_RemoveRepeatedPoints('MULTIPOINT(0 0, 0 0, 1 1, 2 2)'::geometry));
+SELECT 16, ST_AsText(ST_RemoveRepeatedPoints('MULTIPOINT(0 0, 0 0, 1 1, 2 2)'::geometry,0.1));
+SELECT 17, ST_AsText(ST_RemoveRepeatedPoints('MULTIPOINT(0 0, 0 0, 1 1, 4 4)'::geometry,2));
+
+
Modified: trunk/regress/remove_repeated_points_expected
===================================================================
--- trunk/regress/remove_repeated_points_expected 2017-09-06 05:39:59 UTC (rev 15636)
+++ trunk/regress/remove_repeated_points_expected 2017-09-06 16:20:19 UTC (rev 15637)
@@ -13,3 +13,6 @@
12|3
13|LINESTRING(0 0,2 0,4 0)
14|LINESTRING(10 0,10 10)
+15|MULTIPOINT(0 0,1 1,2 2)
+16|MULTIPOINT(0 0,1 1,2 2)
+17|MULTIPOINT(0 0,4 4)
More information about the postgis-tickets
mailing list