[Geoserver-devel] Snap to line or Snap to Vertex

Hi all!

We finally got our points (vehicles) plotted and refreshing properly. Not
always the points are over the streets lines, and we would like to know how
to snap the points to the nearest line. (someone mentioned some type of
"snap to line" or "snap to vertex". Wich is the correct approach?

This is so we can position the points over the correct line (street) and
then generate a report that will output the "street name" where the vehicles
are / were...

Any ideas?

Thanks
--
View this message in context: http://www.nabble.com/Snap-to-line-or-Snap-to-Vertex-tf1956738.html#a5367066
Sent from the GeoServer - Dev forum at Nabble.com.

SenTnel wrote:

Hi all!

We finally got our points (vehicles) plotted and refreshing properly. Not
always the points are over the streets lines, and we would like to know how
to snap the points to the nearest line. (someone mentioned some type of
"snap to line" or "snap to vertex". Wich is the correct approach?

This is so we can position the points over the correct line (street) and
then generate a report that will output the "street name" where the vehicles
are / were...

I know mapbender has some line snapping code. You may ask on their list how they wrote it, or you may be able to just use something they wrote.

I don't think there's any filters that return the road that's _the_ nearest, though it could be a very cool filter to write. One thing you can do is a 'distance' filter - I imagine that there's some error difference that it should be within, so if you do a filter of the point of the car within a distance of the max error then you should get the closest street back.

I imagine a more robust way would be to have the processing take place in GeoServer, you may be able to get away with justwriting a new filter function in GeoTools (which can drop straight in to GeoServer) called snap to line or snap to vertex which takes the point geometry and finds the feature with the nearest geometry. Or you may need to make a new plug-in on GeoServer 1.4 which does a little processing - takes the geometry, runs a distance filter to get those in range, and then figure out which is actually the closest. Actually if you did that you could combine it with a WFS-T 'update' - pass the featureid of the point to snap, it'd process it and adjust the database accordingly.

If you'd like I can try to sketch out a bit more how you might go about that. But as far as I know there's nothing in GeoServer that does it yet, but it'd be a fairly easy module to write.

best regards,

Chris

Any ideas?

Thanks

--
Chris Holmes
The Open Planning Project
http://topp.openplans.org