简体   繁体   中英

How to get a Distance Matrix with the computation being made offline on my server

I am looking to get an approximation of the travel distance and time between several locations.

Ideally, I want to be able to send in the GPS coordinates of the locations, use the data of OpenStreetMap, and get as an output a distance matrix with the given locations, all of this would be done offline on my AWS server. (Using PHP or C++ would be good)

I am really new to using OpenStreetMap. I have just downloaded the ile-de-france.osm.pbf, which is the map for a region of France.

I have no clue where to start. I am not even sure if it is simple to do it. Can anyone point me in the right direction? And If OpenStreetMap is not the best solution for getting a distance matrix offline, then what is?

For calculating traveling distances you have to install a router, too. Choose one of the available online routers (many of them can be installed locally and used offline, too) or offline routers . Good choices are OSRM , GraphHopper and gosmore .

OSRM has a distance matrix call, but it's currently limited to a certain quantity of locations. I've built a script to make large distance matrices with a local OSRM server (it's really simple to compile on Ubuntu). Here it is https://github.com/sabas/OSRMdistance I've computed square matrices of more than 300 locations...

There are simple formula to calculate distance between 2 GPS coordinates. For example (you may need to pay attention to the units)

double t1 = sin(y1) * sin(y2);
double t2 = cos(y1) * cos(y2);
double t3 = cos(x1 - x2);
double t4 = t2 * t3;
double t5 = t1 + t4;
double rad_dist = atan(-t5/sqrt(-t5 * t5 +1)) + 2 * atan(1.0f);
double mile = rad_dist * 3437.74677 * 1.1508;
double meter = mile * 1609.3470878864446;

To find the walking/vehicle distance, you break the path into checkpoints by matching nearest "ways" in the database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM