# Geometry :

Subject: [ggl] Snapping
From: Mateusz Loskot (mateusz)
Date: 2009-12-01 14:01:19

Stephen Leary wrote:
> On Tue, Dec 1, 2009 at 9:34 AM, Barend Gehrels wrote:
>> 3) I don't understand this: "Line to Vertex (LV). It is rare to want
>> to do this. But occasionally this is the right answer when a Vertex
>> has a higher positional accuracy.", what do you mean by higher
>> positional accuracy? You mean that the vertex is more precise, that
>> you know that before, and therefore want to snap the line to that?
>> So there probably must be a parameter (or more) to influence the
>> behaviour of the algorithm?
>
>
> Imagine i have people out capturing data. One captures a point where he
> thinks it is on a map, the other captures the point using GPS. The
> capture method will generally get stored with the data in a database and
> the positional accuracy will be estimated. Some points are never allowed
> to move so the algorithms have to be able to snap lines to points as
> well as points to lines.

Let's say I'm developing UML drawing software, with SVG as data format
and GGL for geometry. I want to have configurable snapping.
What would be the positional accuracy?

IOW, I'd suggest to increase the altitude of this analysis to more
generic level, than the domain-specific about GIS. Or we are
talking about extensions::gis::snap, then I'm fine & well
with what Stephen is proposing.

> The four algorithms are separate ways of snapping. More complex "high
> level" uses of these algorithms may be created and implemented later.
> For now I wanted to highlight some of the use cases so that we didnt
> produce an over-simplistic way of snapping that couldnt be used for
> these cases.

OK, I'm clear now.

>> 5) What will happen if two vertices are within the snap tolerance,
>> but a segment is even closer?

Barend, I imagine this decision belongs to end-user, application,
which one is preferred.

>> 6) what will happen if a point is close to a polygon (with holes),
>> closer to one of the holes than to the boundary? Will it first
>> detect the best-vertex-to-snap-to
>
> It should always snap to the nearest ring. A test will be made early on
> to find the nearest ring and discard the others from the test.

I think there is a confusion here.
Both, exterior ring and interior ring, according to OGC, define
polygon boundaries.
Given that, snapping works as "snap-to-boundary", thus it does not
matter if point is snapped to vertex/segment of exterior ring or
interior ring, in both cases it's snapped to polygon boundary
and never crosses polygon interior.

Correct me if I'm wrong.

Best regards,

```--
Mateusz Loskot, http://mateusz.loskot.net
```

Geometry list run by mateusz at loskot.net