Find nearest latitude and longitude points

后端 未结 2 1846
猫巷女王i
猫巷女王i 2021-02-04 12:41

An question on latitude and longitude...Probably a silly one.

I have a set of latitude and longitudes for various locations.And, I have the latitude and longitude of the

相关标签:
2条回答
  • 2021-02-04 13:19

    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

    0 讨论(0)
  • 2021-02-04 13:26

    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.

    0 讨论(0)
提交回复
热议问题