Laravel, how to get the exact distance and direction between two points using osrm project

耗尽温柔 提交于 2020-07-20 06:36:57

问题


For more than a week, I have been searching for a way to find the correct distance between two areas and what Google offers is calculating the distance on the map and not directions, either using the Google matrix is very expensive especially since I have a large number of stores and every customer will search to find the closest stores that are supposed to Not more than 10 km away from him, I looked for a solution using the osrm project, but I did not find a way to run it through my site. I ask you to help me because this matter is very necessary for me and I hope that my question will not be closed.

from documentation:

curl 'http://router.project-osrm.org/route/v1/driving/13.388860,52.517037;13.397634,52.529407;13.428555,52.523219?overview=false'

even this I tried it is not working for every time, I changed the latitude and longitude also doesn't work

the error: file_get_contents(http://router.project-osrm.org/route/v1/driving/2.9860749,101.780664;2.8427795,101.79740?overview=false): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request

         $from_latlong='2.9860749,101.780664';
         $to_latlong='2.8427795,101.79740';

    $response = file_get_contents("http://router.project-osrm.org/route/v1/driving/$from_latlong;$to_latlong?overview=false");
    $data = json_decode($response);
    return $data;

来源:https://stackoverflow.com/questions/62619521/laravel-how-to-get-the-exact-distance-and-direction-between-two-points-using-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!