Algorithm to calculate nearest location based on longitude & latitude

淺唱寂寞╮ 提交于 2019-12-02 22:46:36
hsz

There is a Distance Matrix API. This API allows you to calculate distances between some given positions.

You can do this also by your own with a haversine formula

1st idea: If your "100 known locations" remain mostly the same, you could partition the known locations to smaller groups and maintain the structure. Then just play with the closest group.

More mathematical approaches here

Try to implement k-d tree algorithm with Nearest neighbor search.

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