Opened 7 years ago

Closed 7 years ago

#3843 closed defect (fixed)

st_RemoveRepeatedPoints misses duplicate in polygon

Reported by: crispond Owned by: pramsey
Priority: medium Milestone: PostGIS 2.4.3
Component: postgis Version: 2.4.x
Keywords: st_RemoveRepeatedPoints Cc:

Description

Apologies if this has already been fixed. I couldn't find a reference to it.

st_RemoveRepeatedPoints appears to be removing the first duplicate in a polygon, but not the second. The function works correctly in a linestring, and correctly if you add a third duplicate.

Perhaps, it is due to the small size of the geometry.

--Does not remove point (2 3):
select st_astext(st_RemoveRepeatedPoints('POLYGON((0 0,1 1,1 1,2 3,2 3,1 34,0 0))'::geometry));

--Works correctly:
select st_astext(st_RemoveRepeatedPoints('LINESTRING(0 0,1 1,1 1,2 3,2 3,1 34,0 0)'::geometry));

--Adding a third repetition also works correctly:
select st_astext(st_RemoveRepeatedPoints('POLYGON((0 0,1 1,1 1,2 3,2 3,1 34,1 34,0 0))'::geometry));

Thanks!

-cris

Change History (9)

comment:1 by pramsey, 7 years ago

Yes, its definitely a function of the minpoints protection for polygons, I'm just not 100% sure why I'm protecting at 5 instead of four, I need think long and hard before I decrement it…

comment:2 by pramsey, 7 years ago

Resolution: fixed
Status: newclosed

In 15840:

Find all duplicates, even within very short polygons/lines (Closes #3843)

comment:4 by robe, 7 years ago

Resolution: fixed
Status: closedreopened

Paul,

Were you going to back port this to 2.3.4? Or it will just be a 2.4.0 fix?

comment:5 by pramsey, 7 years ago

It was a big enough change and a small enough issue that I wasn't going to back-port it.

comment:6 by robe, 7 years ago

Milestone: PostGIS 2.3.4PostGIS 2.4.0
Resolution: fixed
Status: reopenedclosed

comment:7 by zimirrr, 7 years ago

Resolution: fixed
Status: closedreopened
Version: 2.2.x2.4.x

We've found same problem with ST_RemoveRepeatedPoints. This sql fails to drop duplicated node 90.352327 23.79429:

SELECT ST_AsText(ST_RemoveRepeatedPoints('POLYGON((90.352399 23.794183,90.352332 23.79418,90.352327 23.79429,90.352327 23.79429,90.352399 23.794183))'))

But on linestring it works:

SELECT ST_AsText(ST_RemoveRepeatedPoints('LINESTRING(90.352399 23.794183,90.352332 23.79418,90.352327 23.79429,90.352327 23.79429,90.352399 23.794183)'))

Was tested it on:

  1. "POSTGIS="2.4.1 r16012" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.2, released 2017/09/15" LIBXML="2.7.8" LIBJSON="0.12" LIBPROTOBUF="1.2.1" RASTER"
  1. "POSTGIS="2.3.3 r15473" GEOS="3.6.1-CAPI-1.10.1 r4317" PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.2.1, released 2017/06/23" LIBXML="2.7.8" LIBJSON="0.12" RASTER"
  1. "POSTGIS="2.3.2 r15302" GEOS="3.6.1-CAPI-1.10.1 r0" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.0, released 2017/04/28" LIBXML="2.9.4" LIBJSON="0.12.1" RASTER"

comment:8 by pramsey, 7 years ago

I'm seeing it working right on my system on svn trunk

postgis25=# SELECT ST_AsText(ST_RemoveRepeatedPoints('POLYGON((90.352399 23.794183,90.352332 23.79418,90.352327 23.79429,90.352327 23.79429,90.352399 23.794183))'));
                                        st_astext                                         
------------------------------------------------------------------------------------------
 POLYGON((90.352399 23.794183,90.352332 23.79418,90.352327 23.79429,90.352399 23.794183))
(1 row)

postgis25=# SELECT ST_AsText(ST_RemoveRepeatedPoints('LINESTRING(90.352399 23.794183,90.352332 23.79418,90.352327 23.79429,90.352327 23.79429,90.352399 23.794183)'));
                                         st_astext                                         
-------------------------------------------------------------------------------------------
 LINESTRING(90.352399 23.794183,90.352332 23.79418,90.352327 23.79429,90.352399 23.794183)
(1 row)

comment:9 by pramsey, 7 years ago

Milestone: PostGIS 2.4.0PostGIS 2.4.3

comment:10 by pramsey, 7 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.