League\Geotools\Vertex\Vertex::middle PHP Метод

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

Returns the half-way point / coordinate along a great circle path between the origin and the destination coordinates.
public middle ( ) : League\Geotools\Coordinate\CoordinateInterface
Результат League\Geotools\Coordinate\CoordinateInterface
    public function middle()
    {
        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());
        $bx = cos($latB) * cos($lngB - $lngA);
        $by = cos($latB) * sin($lngB - $lngA);
        $lat3 = rad2deg(atan2(sin($latA) + sin($latB), sqrt((cos($latA) + $bx) * (cos($latA) + $bx) + $by * $by)));
        $lng3 = rad2deg($lngA + atan2($by, cos($latA) + $bx));
        return new Coordinate(array($lat3, $lng3), $this->from->getEllipsoid());
    }