Opened 6 years ago

Last modified 10 months ago

#760 new defect

Snapping leaves segments below tolerance

Reported by: strk Owned by: geos-devel@…
Priority: major Milestone: 3.10.0
Component: Default Version: 3.5.0
Severity: Unassigned Keywords:
Cc:

Description

Snapping a geometry to another should result in an output that does not move again on subsequent snapping to the same geometry. At least, I'd think such behaviour would be to be preferred, for stability.

In the following case it takes two iterations to reach that point:

WITH inp AS (                                                                   
 SELECT                                                                         
   0.001 as tol,                                                                
   'LINESTRING(599671.37338031 4889182.65265274,599671.369855744 4889982.62878372)'
    ::geometry as src,                                                          
   'LINESTRING(599671.37 4889664.32,599665.52 4889680.18,599671.37 4889683.4,599671.37 4889781.87)'
    ::geometry as tgt                                                           
)                                                                               
SELECT                                                                          
 ST_AsText(ST_Snap(src , tgt , tol)),                                           
 ST_AsText(ST_Snap(ST_Snap(src , tgt , tol), tgt, tol)),                        
 ST_AsText(ST_Snap(ST_Snap(ST_Snap(src , tgt , tol), tgt, tol), tgt, tol))
FROM inp;

Change History (6)

comment:1 Changed 6 years ago by strk

I shell note the problem is dependent on order of vertices in the target point set. Here's a simpler input:

src: LINESTRING(0 0,0 20)
tgt: LINESTRING(0.5 19,1 18,1.5 17)

Take the target in the given order and snapping is final after first iteration. Reverse the target and it takes 3 iterations to fully snap:

 SELECT
   0.8 as tol,
   
   'LINESTRING(0 0,0 20)'
    ::geometry as src,
   
   'LINESTRING(0.5 19,1 18,1.5 17)'
    ::geometry as tgt
)
SELECT
 ST_AsText(src) src,
 ST_AsText(ST_Snap(src , tgt , tol)) snap1,
 ST_AsText(ST_Snap(ST_Snap(src , tgt , tol), tgt, tol)) snap2,
 ST_AsText(ST_Snap(ST_Snap(ST_Snap(src , tgt , tol), tgt, tol), tgt, tol)) snap3,
 ST_AsText(ST_Snap(src , ST_Reverse(tgt) , tol)) snap1r,
 ST_AsText(ST_Snap(ST_Snap(src , ST_Reverse(tgt) , tol), ST_Reverse(tgt), tol)) snap2r,
 ST_AsText(ST_Snap(ST_Snap(ST_Snap(src , ST_Reverse(tgt) , tol), ST_Reverse(tgt), tol), ST_Reverse(tgt), tol)) snap3r,
 ST_Distance(src, ST_EndPoint(tgt)) dist_end,
 ST_Distance(src, ST_StartPoint(tgt)) dist_start,
 ST_Distance(src, ST_PointN(tgt,2)) dist_p2,
 ST_Distance(src, ST_PointN(tgt,3)) dist_p3
FROM inp;
-[ RECORD 1 ]---------------------------------------
src        | LINESTRING(0 0,0 20)
snap1      | LINESTRING(0 0,1.5 17,1 18,0.5 19,0 20)
snap2      | LINESTRING(0 0,1.5 17,1 18,0.5 19,0 20)
snap3      | LINESTRING(0 0,1.5 17,1 18,0.5 19,0 20)
snap1r     | LINESTRING(0 0,0.5 19,0 20)
snap2r     | LINESTRING(0 0,1 18,0.5 19,0 20)
snap3r     | LINESTRING(0 0,1.5 17,1 18,0.5 19,0 20)
dist_end   | 1.5
dist_start | 0.5
dist_p2    | 1
dist_p3    | 1.5

comment:3 Changed 5 years ago by strk

Milestone: 3.5.13.5.2

Ticket retargeted after milestone closed

comment:4 Changed 3 years ago by robe

Milestone: 3.5.23.8.0

comment:5 Changed 2 years ago by pramsey

Milestone: 3.8.03.9.0

comment:6 Changed 10 months ago by pramsey

Milestone: 3.9.03.10.0
Note: See TracTickets for help on using tickets.