Answer the question
In order to leave comments, you need to log in
How to determine delivery zones by address?
The question has already appeared somewhere, but remained unanswered.
The task seems to be an easy one. Get the address, send it to the Yandex gelocator, get the coordinates. Then I see 2 ways:
1. Ask Yandex if the point belongs to a particular delivery zone.
2. Use your own algorithm to calculate whether a point is included in a polygon.
The first method rests on the fact that I failed to find a similar tool in the Yandex API. Did you look bad?
The second one goes to the list of polygon vertices. Manually rewrite the coordinates of the ring (spb), Len. somehow I don’t really want the area and the borders of the city :) Maybe they already lie somewhere, but I haven’t seen it?
There is one more problem. Calculate the distance, for example, from the roundabout to the address. The required accuracy is ~5 km, so you can not use tools for building routes, but simply calculate the distance to the nearest point on the ring. Maybe someone will come up with a better idea?
All this, of course, I want to do on the server, not on the client. Hence the questions:
1. Can Yandex tell if a point is included in a polygon? (using only xml api)
2. Where can I get the list of coordinates of the ring road, borders of St. Petersburg and Leningrad region?
3. Does anyone have an idea how best to calculate the distance from the zone boundary to the point?
Naturally, alternative implementation ideas are welcome.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
damn... getting a point into a polygon, the algorithm is primitive:
>> The algorithm is something like this: draw a ray from a point, for example, to the right. Calculate the number of intersections of the beam with the sides of the polygon. If odd, then inside, if even, outside.
Draw zones on the Yandex website, export them to yourself, paste them on the server, use them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question