可以在MySQL层面使用自定义计算函数来使用
CREATE DEFINER=`xxx`@`%` FUNCTION `get_distance`( lat1 float,lon1 float,lat2 float,lon2 float) RETURNS float SQL SECURITY INVOKER BEGIN RETURN 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(( lon1 * PI() / 180 - lon2 * PI() / 180 ) / 2),2))),2); END
标签:lat1,经纬度,lat2,float,距离,180,MySQL,PI From: https://www.cnblogs.com/xingxia/p/mysql_get_distance.html