[GIS] I have n points, how to find the closest one from a point p by road

apiroutingsimulationweb serviceweb-mapping

I'm currently working on a map with stores and clients. I want to find the closest store by road from a given client, with the aim of simulating the creation of a new store.

Requirements:

  • precision is not an issue (low quality data is OK)
  • web based (API, some code server-side, or javascript)
  • free or cheap (no 100000$ GIS solutions…)

Of course I could use google maps api and try every store. But I have a lot of stores and clients, and I would like to run the simulation several times, so it would sent far too many queries.

Best Answer

No need for expensive proprietary solutions, this is called the Traveling Sales Person (TSP) problem and luckily for you this PostGIS extension PG Routing already has this cracked.

Better yet it's free and opensource! Just vanilla web app stuff to write some back end code to that you can run those queries over HTTP.

Happy mapping!