搜寻点坐标:时代广场 113.323568, 23.146436
6370.996公里为地球的半径
计算球面两点坐标距离公式
C = sin(MLatA)sin(MLatB)cos(MLonA-MLonB) + cos(MLatA)cos(MLatB)
Distance = RArccos(C)*Pi180
根据计算公式得到查询语句如下:
select * from `location` where ( acos(sin(([#latitude#]*3.1415)/180) * sin((latitude*3.1415)/180) + cos(([#latitude#]*3.1415)/180) * cos((latitude*3.1415)/180) * cos(([#longitude#]*3.1415)/180 - (longitude*3.1415)/180))*6370.996)<=1;
执行查询:
mysql> select * from `location` where ( -> acos( -> sin((23.146436*3.1415)/180) * sin((latitude*3.1415)/180) + -> cos((23.146436*3.1415)/180) * cos((latitude*3.1415)/180) * cos((113.323568*3.1415)/180 - (longitude*3.1415)/180) -> )*6370.996 -> )<=1; +----+-----------+----------------+---------------+(北联网教程,专业提供视频软件下载)
……