Hello guys,
I need a way to sort out the following problem.
Input:
- Lot of points expressed as (Latitude,Longitude) in a database
- A given path as an array of (Latitude,Longitude), the path is composed by the sum of all the segment formed using two subsequent points.
Output:
- The point that is closer to a path. To make it clear: the distance between this point and one of the segment composing the path must be less or equal to all the other distance between all the points and all the segments.
This is what I've been able to thought so far:
- Decompose the path in smaller paths
- For each new path compute the bounds of the concerned area.
- Make database query for all the points in the area of each path.
- Compute the distance between all the resulting points and the segments in the relative area
- Pick the smaller one
n.b. Obviously i will make each new paths calculation on a separated thread.
n.b.b. This is just the "basic idea", there are a lot of problem in this solution that i'm not showing hoping to make it simple, for example, the bounds needs to be of a proper size to be sure to include all the candidated point.
Since there are a lot of points and i would like to perform this search in the most efficent way, i'd like to hear some of your suggestion to improve my solution or to change it radically with something better.
Thanks for your time, comment if you want some clarification.