R
R
rmfalx2018-04-03 18:55:59
Python
rmfalx, 2018-04-03 18:55:59

How to find the nearest offices to you if you know your location?

A question. The organization has 300 offices in Russia. I get from the user his coordinates in the form - "You are here: latitude 29.937549, longitude 40.265032"
Then I can use these coordinates. The company's offices are crowded on the yandex map and on the google map.
Can you please tell me how can I return the nearest office to the user?
I found the formula - gis-lab.info/qa/great-circles.html
But maybe it's already in the api googl map or yandex map.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
awesomer, 2018-04-03
@awesomer

In terms of user convenience, you need more than one nearest office.
A few nearby offices. Pieces 2-3 at least. And then - let him decide.
You never know - maybe by one of these several offices he will have incidental business.
And when you give away only one single office, you deprive the user of the opportunity to optimize his route.
Therefore, a rough formula is quite sufficient.

V
Vladimir, 2018-04-04
@vintello

I think you are not the first to solve such problems,
so you need to go to Google with this question, there are a lot of answers.
I don’t know what you use on the back to store the coordinates of offices, but for example, if it lives in mongo, then you can use the functionality out of the box,
if it’s a postress with its rich inner world, then you can look here

X
Xander017, 2018-04-04
@Xander017

Why not use haversine ?
link
For 300 offices, quickly calculate the distance in kilometers and select the minimum.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question