--第一种
SELECT ent_id, ent_name, longitude, latitude, ROUND( 6378.138 * 2 * ASIN( SQRT( POW( SIN( ( 40.042307 * PI() / 180 - latitude * PI() / 180 ) / 2 ), 2 ) + COS(40.042307 * PI() / 180) * COS(latitude * PI() / 180) * POW( SIN( ( 116.317205 * PI() / 180 - longitude * PI() / 180 ) / 2 ), 2 ) ) ) * 1000 ) AS juli FROM ent ORDER BY juli DESC limit 0,100;
--第二种
SELECT ent_id, ent_name, longitude, latitude FROM ent ORDER BY POWER(MOD(ABS(longitude-116.317205),360),2) + POWER(ABS(latitude-40.042307),2) DESC limit 0,100;
--根据右上角经纬度和左下角经纬度查询范围内企业
select ent_id, ent_name, longitude, latitude from ent where #{topRightLatitude,jdbcType=DECIMAL}>latitude and latitude>#{leftLowerLatitude,jdbcType=DECIMAL} and #{topRightLongitude,jdbcType=DECIMAL}>longitude and longitude>#{leftLowerLongitude,jdbcType=DECIMAL}
时间: 2024-10-11 04:20:24