Given a set of points s (a set of x,y coordinates) and a path that is made up of line segments joining a set of points l, describe an efficient algorithm that can be used to find a subset of points from s that are within the specified distance d of the path l.
A practical application of this may be to find a list of restaurants within 10 miles anywhere along a road trip path between cites.
For example, in the following diagram, the points in green would be included in the search results.
Solutions would be preferred in C#, but bonus points may be given for a SQL based approach :-)
I also thought about this some time ago. I think, efficient is misleading. Just testing all line segments for each point is good enough. It is very cheap to calculate the distance. If there are many points, you can also think about refining the strategy which points to choose using a level-set approach. i.e.
that's maybe not complete, but should be fast and avoids checking points far away and quite ok.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With