Search code examples
ruby-on-rails-3performancegpsgeometrygeokit

Find locations in radius of path between 2 other locations


I have a large database of locations, all with lat/long. I use GeoKit and Rails to trivially get locations within a set radius of any other location. All that works great.

My goal is to specify 2 locations (say, A and B), and find all other locations within a radius of Xmi on the path between A and B.

What are some ways in which you could approach this issue? I thought about performing my nearby search at some regular interval on the path, but then I am concerned about performance and the flip-side--missing locations near to the path just because I chose a poor interval.

Thoughts?


Solution

  • I didn't find an elegant answer here, but sadiqxs was on the right track I suppose. GeoKit doesn't support non-rectangular searches, so I ended up with a solution similar to sadiqxs's but optimized to apply a maximum number of searches based on distance.