I have driven along some roads and registered some information about the state of the edge of the road. The GPS coordinates are not very precise, and I would like to smooth or snap the tracked lines to the actually edges of the road. All data is registered driving at the right direction in the right side of the road. I have three layers with data.
- Red layer is the edges of the road.
- Blue layer is the center lines of the road.
- Green layers is the tracks registered by the GPS with some attributes about the state of the side of the road. Look at the image at the bottom.
I have many of these and would like to automatically smooth or snap the points of the green lines to the right side of the road, to make them follow the red line.
How can I do that using MapInfo?
Just some mathematical description how to solve it would be nice. I am not asking for a full MapBasic script that solves it.
My initial thought is to find the nearest red line to a chosen green line. For each vertex in the green line get a vector to the nearest point on a red line segment and move the vertex by this vector. But I can see the GPS is sometimes very unstable and the green line is on the wrong side of the center line. In some way I need to find the nearest red line to the "right" of the blue center line and move the vertices to this.
I put some white arrows on the image to illustrate where to move the green lines to.
Perhaps a totally different way can be used?