League\Geotools\Distance\Distance::flat PHP Method

flat() public method

Returns the approximate flat distance between two coordinates using Pythagoras’ theorem which is not very accurate.
See also: http://en.wikipedia.org/wiki/Pythagorean_theorem
See also: http://en.wikipedia.org/wiki/Equirectangular_projection
public flat ( ) : double
return double The distance in meters
    public function flat()
    {
        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());
        $x = ($lngB - $lngA) * cos(($latA + $latB) / 2);
        $y = $latB - $latA;
        $d = sqrt($x * $x + $y * $y) * $this->from->getEllipsoid()->getA();
        return $this->convertToUserUnit($d);
    }