根據經緯度查詢附近企業 | SQL
阿新 • • 發佈:2017-08-18
cos asi font sel jdbc 附近 sin top blog
--第一種
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) DESClimit 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}
根據經緯度查詢附近企業 | SQL