CREATE DEFINER=`root`@`localhost` FUNCTION `getdistance`(latitude1 decimal(18,10), longitude1 decimal(18,10), latitude2 decimal(18,10), longitude2 decimal(18,10)) RETURNS decimal(18,2)
BEGIN
#Routine body goes here...
RETURN ROUND(
6378.138 * 2 * ASIN(
SQRT(
POW(
SIN(
(
latitude1 * PI() / 180 - latitude2 * PI() / 180
) / 2
),
2
) + COS(latitude1 * PI() / 180) * COS(latitude2 * PI() / 180) * POW(
SIN(
(
longitude1 * PI() / 180 - longitude2 * PI() / 180
) / 2
),
2
)
)
) * 1000
);
END
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交