mysql 距离函数
要有超级权限
SET GLOBAL log_bin_trust_function_creators = 1;
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `CALC_DIST`(lng1 double(15,9), lat1 double(15, 9), lng2 double(15,9), lat2 double(15,9)) RETURNS int(11)
BEGIN
DECLARE dist int;
SET dist = round(6378.138*2*asin(sqrt(pow(sin((lat1*pi()/180-lat2*pi()/180)/2),2)+cos(lat1*pi()/180)*cos(lat2*pi()/180)* pow(sin((lng1*pi()/180-lng2*pi()/180)/2),2)))*1000);
RETURN (dist);
END$$
DELIMITER ;