Fastest Way to Find Distance Between Two Lat/Long Points

后端 未结 15 1024
时光说笑
时光说笑 2020-11-21 10:12

I currently have just under a million locations in a mysql database all with longitude and latitude information.

I am trying to find the distance between one point a

15条回答
  •  我寻月下人不归
    2020-11-21 10:32

       select
       (((acos(sin(('$latitude'*pi()/180)) * sin((`lat`*pi()/180))+cos(('$latitude'*pi()/180)) 
        * cos((`lat`*pi()/180)) * cos((('$longitude'- `lng`)*pi()/180))))*180/pi())*60*1.1515) 
        AS distance
        from table having distance<22;
    

提交回复
热议问题