Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#3410 closed defect (fixed)

ST_RemoveRepeatedPoints fails to drop second-to-last point

Reported by: strk Owned by: strk
Priority: medium Milestone: PostGIS 2.2.1
Component: postgis Version: 2.2.x
Keywords: Cc:

Description

A 3-vertices line, in which 2nd and 3rd point are at e-10 distance. Calling ST_RemoveRepeatedPoint with e-8 distance does not remove anything.

Self-contained test:

=# with inp as ( select '010200000003000000BCAABC2B192739418F7DE0E6AB96524185EB51382828394115AE47D12C96524187EB51382828394115AE47D12C965241'::geometry g ) select st_summary(g), st_summary(st_removerepeatedpoints(g,1e-8)), st_distance(st_pointn(g,2), st_pointn(g,3)) from inp;
LOG:  duration: 0.350 ms  statement: with inp as ( select '010200000003000000BCAABC2B192739418F7DE0E6AB96524185EB51382828394115AE47D12C96524187EB51382828394115AE47D12C965241'::geometry g ) select st_summary(g), st_summary(st_removerepeatedpoints(g,1e-8)), st_distance(st_pointn(g,2), st_pointn(g,3)) from inp;
-[ RECORD 1 ]----------------------------
st_summary  | LineString[B] with 3 points
st_summary  | LineString[B] with 3 points
st_distance | 4.65661287307739e-10

Change History (10)

comment:1 Changed 4 years ago by strk

Simplified testcase:

select ST_AsText(ST_RemoveRepeatedPoints(
  'LINESTRING(0 0,8 0,9 0)'
::geometry, 2));

I'm finding these cases while trying to fix topological errors as reported in #3402. Removing consecutive nearby points could help there (if it worked)

comment:2 Changed 4 years ago by strk

I think a simpler implementation would be like the one before r14494 but with an additional check for last-point being unchanged between input and output and moving of the last point if it is not the same.

comment:3 Changed 4 years ago by strk

Owner: changed from pramsey to strk
Status: newassigned

I'll take care of this

comment:4 Changed 4 years ago by strk

I see one problem is with the "minpoints" parameter. By *forcing* the presence of a minimum of points, what takes precedence between points considered equal and minimum number of points ? It's kind of easy when the minimum number of points is 2, is there any case in which it's bigger than that ?

comment:5 Changed 4 years ago by pramsey

Polygon case is 4

comment:6 Changed 4 years ago by strk

(In [14528]) Fix left over sub-tolerance last segment in ST_RemoveRepeatedPoints

See #3410

comment:7 Changed 4 years ago by strk

Paul can you see how you like r14528 before I backport it ?

comment:8 Changed 4 years ago by strk

Example output:

=# SELECT ST_AsText(ST_RemoveRepeatedPoints('MULTILINESTRING((0 0, 0 0, 0 0, 0 0, 0 0),(0 0,1 0,9 0),(0 0,8 0,9 0))', 2));
                   st_astext                    
------------------------------------------------
 MULTILINESTRING((0 0,0 0),(0 0,9 0),(0 0,9 0))
(1 row)

comment:9 Changed 4 years ago by strk

Resolution: fixed
Status: assignedclosed

(In [14529]) Fix left over sub-tolerance last segment in ST_RemoveRepeatedPoints

Closes #3410

comment:10 Changed 4 years ago by strk

Well, backported with r14529

Note: See TracTickets for help on using tickets.