League\Geotools\Distance\Distance::greatCircle PHP Method

greatCircle() public method

Returns the approximate distance between two coordinates using the spherical trigonometry called Great Circle Distance.
See also: http://www.ga.gov.au/earth-monitoring/geodesy/geodetic-techniques/distance-calculation-algorithms.html#circle
See also: http://en.wikipedia.org/wiki/Cosine_law
public greatCircle ( ) : double
return double The distance in meters
    public function greatCircle()
    {
        Ellipsoid::checkCoordinatesEllipsoid($this->from, $this->to);
        $latA = deg2rad($this->from->getLatitude());
        $lngA = deg2rad($this->from->getLongitude());
        $latB = deg2rad($this->to->getLatitude());
        $lngB = deg2rad($this->to->getLongitude());
        $degrees = acos(sin($latA) * sin($latB) + cos($latA) * cos($latB) * cos($lngB - $lngA));
        return $this->convertToUserUnit($degrees * $this->from->getEllipsoid()->getA());
    }