php获取多边形GPS中心点坐标getGpsCenter
    		       		warning:
    		            这篇文章距离上次修改已过1334天,其中的内容可能已经有所变动。
    		        
        		                
                直接帖方法
    $gps_data = [
        [119.182468,34.603796],
        [119.182635,34.603347],
        [119.182743,34.603370],
        [119.182575,34.603846].
    ];
    // 获取GPS中心点坐标
    function getGpsCenter($gps_data = [])
    {
        if (!is_array($gps_data)) return false;
        $num_coords = count($gps_data);
        $X = 0.0;
        $Y = 0.0;
        $Z = 0.0;
        foreach ($gps_data as $val)
        {
            #$lon = $coord[1] * pi() / 180;
            $lng = deg2rad($val[0]);
            #$lat = $coord[0] * pi() / 180;
            $lat = deg2rad($val[1]);
            $a = cos($lat) * cos($lng);
            $b = cos($lat) * sin($lng);
            $c = sin($lat);
            $X += $a;
            $Y += $b;
            $Z += $c;
        }
        $X /= $num_coords;
        $Y /= $num_coords;
        $Z /= $num_coords;
        $lng = atan2($Y, $X);
        $hyp = sqrt($X * $X + $Y * $Y);
        $lat = atan2($Z, $hyp);
        #return array($lat * 180 / pi(), $lon * 180 / pi());
        return array(rad2deg($lng), rad2deg($lat));
    }