League\Geotools\Distance\Distance::haversine PHP Метод

haversine() публичный Метод

Returns the approximate sea level great circle (Earth) distance between two coordinates using the Haversine formula which is accurate to around 0.3%.
См. также: http://www.movable-type.co.uk/scripts/latlong.html
public haversine ( ) : double
Результат double The distance in meters
    public function haversine()
    {
        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());
        $dLat = $latB - $latA;
        $dLon = $lngB - $lngA;
        $a = sin($dLat / 2) * sin($dLat / 2) + cos($latA) * cos($latB) * sin($dLon / 2) * sin($dLon / 2);
        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
        return $this->convertToUserUnit($this->from->getEllipsoid()->getA() * $c);
    }