locLongitude--当前经度, locLatitude--当前纬度;longitude -- 数据库经度字段名 latitude --数据库纬度字段名
传入当前坐标,查询数据库中距离最近的两个单位。
select * from t_depot order by ACOS(SIN((#{locLatitude} * 3.1415) / 180 ) *SIN((latitude * 3.1415) / 180 ) +COS((#{locLatitude} * 3.1415) / 180 ) * COS((latitude * 3.1415) / 180 ) *COS((#{locLongitude} * 3.1415) / 180 - (longitude * 3.1415) / 180 ) ) * 6380 asc limit 2;