user2001613
user2001613

Reputation: 31

Find top n places that close to a route

I have lots of places data(tourist attractions) stored in database. Every place has coordination info, such as latitude and longitude. When I randomly choose a route (for example: from somewhere in New York to somewhere in Boston), how can I find the 10 closest places along the route? I guess it's relative to geography algorithms. I'm trying to find a way to minimize the total calculation time and save cell phone battery. Thank you for any suggestions!

Upvotes: 0

Views: 44

Answers (1)

numX
numX

Reputation: 850

One way would be:

  • Consider the map to be a grid eg of 1km x1km boxes
  • plot the route and see which of these grid boxes it enters.
  • for each box, find the places/landmarks in the box which is not computationally expensive if you search your database my min/max longitude/latidtude position where the grid box starts/ends

To show the top N from these, you can calculate the shortest distance for these subset of places rather than the whole dataset.

Upvotes: 1

Related Questions