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);
}
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));
+
+
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)