/**
* 获取两个经纬度间距离
* author AarthiModoo
* date 2020-12-10 19:19
*
* @param $fromLng
* @param $fromLat
* @param $toLng
* @param $toLat
* @return float|int|米
*/
public static function computeDistance($fromLng, $fromLat, $toLng, $toLat)
{
// 将角度转为狐度 deg2rad()函数将角度转换为弧度
$fromRadLat = deg2rad($fromLat);
$toRadLat = deg2rad($toLat);
$fromRadLng = deg2rad($fromLng);
$toRadLng = deg2rad($toLng);
$a = $fromRadLat - $toRadLat;
$b = $fromRadLng - $toRadLng;
return 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($fromRadLat) * cos($toRadLat) * pow(sin($b / 2), 2))) * 6378.137 * 1000;
}