League\Geotools\Coordinate\Ellipsoid::checkCoordinatesEllipsoid PHP Метод

checkCoordinatesEllipsoid() публичный статический Метод

Check if coordinates have the same ellipsoid.
public static checkCoordinatesEllipsoid ( League\Geotools\Coordinate\CoordinateInterface $a, League\Geotools\Coordinate\CoordinateInterface $b )
$a League\Geotools\Coordinate\CoordinateInterface A coordinate.
$b League\Geotools\Coordinate\CoordinateInterface A coordinate.
    public static function checkCoordinatesEllipsoid(CoordinateInterface $a, CoordinateInterface $b)
    {
        if ($a->getEllipsoid() != $b->getEllipsoid()) {
            throw new NotMatchingEllipsoidException('The ellipsoids for both coordinates must match !');
        }
    }

Usage Example

Пример #1
0
 /**
  * Returns the half-way point / coordinate along a great circle
  * path between the origin and the destination coordinates.
  *
  * @return 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());
 }
All Usage Examples Of League\Geotools\Coordinate\Ellipsoid::checkCoordinatesEllipsoid