GPS 两点距离
https://www.cnblogs.com/thinkquan/p/3925199.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| function rad($d)
{
return $d * 3.1415926535898 / 180.0;
}
function GetDistance($lat1, $lng1, $lat2, $lng2)
{
$EARTH_RADIUS = 6378.137;
$radLat1 = $this->rad($lat1);
$radLat2 = $this->rad($lat2);
$a = $radLat1 - $radLat2;
$b = $this->rad($lng1) - $this->rad($lng2);
$s = 2 * asin(sqrt(pow(sin($a/2),2) + cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)));
$s = $s *$EARTH_RADIUS;
$s = round($s * 1000);
return $s;
}
GetDistance(26.000000, 118.000000, 25.000000, 117.000000);
|