S
S
shahneff2021-12-05 03:24:20
Yandex maps
shahneff, 2021-12-05 03:24:20

How to calculate the distance from the administrative border of the city to the specified point by road?

Existing services consider the distance along public roads between two points.
Geocoding a city name to geocoordinates always gives the coordinates of that city's administrative center.

And it is necessary to consider the distance from the administrative boundaries of the city to an external point (in the case of Moscow - the distance from the Moscow Ring Road, St. Petersburg - from the Ring Road). Tell me, please, in which direction to dig, there are no ideas at all except for a head-on solution:

1) we build a route between adm. centers of two cities.
2) We have the coordinates of the polygons of all the borders of all the sending cities
3) we go to the coordinate of the intersection of the constructed route and the borders of the sending city (how?)
4) We recalculate the length of the route from this coordinate.

The problem of calculating the cost of delivery for each km outside the city is being solved, while this cannot be done after the fact of the trip.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-12-05
@freeExec

Your way of thinking is correct. And so it will have to be done. Intersection of geometries is a standard geometric operation, available in many spatial libraries (ST_Intersection). Well, then - there are only a few exits from cities, you can prepare these exits in advance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question