0

I have an app that displays maps. I would like to add a feature where the user can tap a location and have it it display information about the nearest landmark.

By landmark, I mean I have a set of predefined objects related to the app with latitude/longitude coordinates.

The app is able to convert X/Y screen coordinates to latitude/longitude.

The app already calculates the distance between two latitude/longitude coordinates.

Therefore, I could, through brute force, run through the list of landmarks and find the closest.

However, knowing this is a problem many applications have to face, I ask if there is a better technique to find the closest "landmark" to a latitude/longitude than brute force? Some kind of transform?

user3344003
  • 20,574
  • 3
  • 26
  • 62
  • 1
    I would suggest looking at [Turf.js](https://github.com/Turfjs/turf), which supports various spatial functions, either client side or server-side, as nodejs. There is also a [leaflet plugin](http://leaflet-extras.github.io/RTree/examples/map.html) which supports R-tree indexing, if you want super fast lookup. OpenLayers3 also has support for R-trees. So, you have lots of choices, but hard to give an exact answer without knowing what software you are using. – John Powell Jun 03 '15 at 07:06
  • 1
    Answered here: http://stackoverflow.com/questions/25478006/how-to-get-the-nearest-100-points-from-one-million-data-records-quickly/25813558#25813558 – Michael Diomin Jun 08 '15 at 20:58
  • No database though. Interesting solution if you can use it. – user3344003 Jun 09 '15 at 02:56

0 Answers0