Find nearest latitude and longitude points

雨燕双飞 提交于 2019-12-03 01:24:46

It depends on how the points are placed.

For example - if most of the points are in a parking lot, then Euclidean Distance should work well.

In other cases - Geodesic Distance needs to be computed. This link should help you with more information.

Here is the conversion from Decimal format to Degree-Minute-Second format and vice versa.

cheers

You can use this SQL. it will select then nearest Lat, Lng from your DB entries.

SELECT id,lat,lng, ((ACOS(SIN(your_lat * PI() / 180) * SIN(lat * PI() / 180) + COS(your_lat * PI() / 180) * COS(lat * PI() / 180) * COS((your_long - lng) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance FROM your_table_name HAVING distance <='10' ORDER BY distance ASC LIMIT 0,10

Hope this will help.

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