mysql下gps求2两点距离

CREATE FUNCTION `NewProc`(`lat0` double,`lng0` double,`lat1` double,`lng1` double)
 RETURNS double
    NO SQL
    SQL SECURITY INVOKER
BEGIN
DECLARE rtn double;
DECLARE c double;
DECLARE  double;
DECLARE  R double;

set ANG_TO_DEG = PI()/180;
#百度算法
set R = 6370.99681;
set c = SIN(lat0 * D)*SIN(lat1 * D) + COS(lat0 * D)*COS(lat1 * D)*COS((lng0 - lng1)*D);
set rtn = R * ACOS(C) ; 

RETURN rtn;
END;


你可能感兴趣的:(mysql下gps求2两点距离)