T
T
terkin2015-11-24 00:48:43
Cartography
terkin, 2015-11-24 00:48:43

How to make a backend script for a car route?

How to implement the calculation of distances, as well as taking into account the areas / city through which the route will pass from point A to point B, for example, as on the site https://www.avtodispetcher.ru/distance/?from=%D0%9... About the implementation Yandex maps is understandable, but how do they get a list of regions and cities on the back end?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Edward, 2015-11-24
@ED98

You can implement distance calculation using Graphhopper based on OpenStreetMap data:
https://graphhopper.com/api/1/docs/routing/#output - here is the documentation, you need the parameter paths[0].distance(second from the top)
About cities and regions using the same service can implement it. In the request, you need to pass a parameter points_encoded=false( documentation ), then at the output in the field you pointswill receive a list of route points. You can then find which city/region each point is in using the reverse geocoder included with Nominatim (again, based on data from OSM). Documentation on it: wiki.openstreetmap.org/wiki/Nominatim#Reverse_Geocoding

G
Grigory Vasilkov, 2015-11-24
@gzhegow

Take it ready and do it.
Do you want your own?
Well, there it was:
You create a map, create vector routes by banal assignment of each point or drawing, then you define two points - from where to. At both points, the task is to determine the minimum distance from the point to the nearest route.
Your routes are set with mileage. You measure the length of the route as a percentage of the entire route, multiply. But this is all gemorno, it’s easier to take a Googlemap and adapt it, why did you give up drawing everything again?
And in any way, why do you need to do this on the backend?
They can run on a cool "node js" thing that works in real time.
You can download the full list from somewhere else. And then how do you do it - a person has chosen a city from the list, you are trying to find it on Yandex on the frontend. You check with the frontend whether an exact match has been found.
There is somehow a tricky request system with callbacks, both in Google and Yandex. And request on puff with some curl or through file_get_contents. But why are you fooling yourself?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question