[geos-devel] Re: [GEOS] #501: Snap operation: wrong snapping

GEOS geos-trac at osgeo.org
Fri Dec 16 05:37:44 EST 2011


#501: Snap operation: wrong snapping
------------------------+---------------------------------------------------
 Reporter:  aperi2007   |       Owner:  geos-devel@…              
     Type:  defect      |      Status:  new                       
 Priority:  major       |   Milestone:  GEOS Future               
Component:  Default     |     Version:  svn-trunk                 
 Severity:  Unassigned  |    Keywords:  jtsfail                   
------------------------+---------------------------------------------------

Comment(by strk):

 The issue is with segments snapping, not point snapping.
 Here's some debugging output:

 {{{
 Snapping segment from: (0 0, 10 0)
 Checking for a segment to snap to snapPt 0 0
  Checking segment LINESEGMENT(0 0,10 0) for snapping against point 0 0
  One of segment endpoints equal snap point, returning too_far
  No segment to snap
 Checking for a segment to snap to snapPt 9 0
  Checking segment LINESEGMENT(0 0,10 0) for snapping against point 9 0
  dist=0 minDist=3 snapTolerance=2
  Segment/snapPt distance within tolerance and closer then previous match
 (0)
  Segment to be snapped found, inserting point
 Checking for a segment to snap to snapPt 10 0
  Checking segment LINESEGMENT(0 0,9 0) for snapping against point 10 0
  dist=1 minDist=3 snapTolerance=2
  Segment/snapPt distance within tolerance and closer then previous match
 (1)
  Checking segment LINESEGMENT(9 0,10 0) for snapping against point 10 0
  One of segment endpoints equal snap point, returning too_far
  No segment to snap
 Checking for a segment to snap to snapPt 11 0
  Checking segment LINESEGMENT(0 0,9 0) for snapping against point 11 0
  dist=2 minDist=3 snapTolerance=2
  Checking segment LINESEGMENT(9 0,10 0) for snapping against point 11 0
  dist=1 minDist=3 snapTolerance=2
  Segment/snapPt distance within tolerance and closer then previous match
 (1)
  Segment to be snapped found, inserting point
  After segment snapping, srcCoors are: (0 0, 9 0, 11 0, 10 0)
 }}}

 The last run seems bogus, highlighted here:

 {{{
 Checking for a segment to snap to snapPt 11 0
  Checking segment LINESEGMENT(0 0,9 0) for snapping against point 11 0
  dist=2 minDist=3 snapTolerance=2
  Checking segment LINESEGMENT(9 0,10 0) for snapping against point 11 0
  dist=1 minDist=3 snapTolerance=2
  Segment/snapPt distance within tolerance and closer then previous match
 (1)
  Segment to be snapped found, inserting point
  After segment snapping, srcCoors are: (0 0, 9 0, 11 0, 10 0)
 }}}

 If it was second point (10, 0) snapped rather than first point (9, 0)
 there would have been no problem.
 The code says:

 {{{
     // insert must happen one-past first point (before next point)
 }}}

 So it is intentional to snap the actual segment rather than the existing
 vertices.
 Only maybe it should be avoided when one of the endpoints is the closer
 part of
 the segment to the snap point.

-- 
Ticket URL: <http://trac.osgeo.org/geos/ticket/501#comment:3>
GEOS <http://geos.refractions.net/>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).


More information about the geos-devel mailing list