예제 #1
0
파일: Polygon.php 프로젝트: brick/geo
 /**
  * Class constructor.
  *
  * The coordinate system of each of the rings must match the one of the Polygon.
  *
  * @param CoordinateSystem $cs       The coordinate system of the Polygon.
  * @param LineString       ...$rings The rings that compose the Polygon, the first one being the exterior ring.
  *
  * @throws InvalidGeometryException  If the resulting geometry is not valid for a sub-type of Polygon.
  * @throws CoordinateSystemException If different coordinate systems are used.
  */
 public function __construct(CoordinateSystem $cs, LineString ...$rings)
 {
     parent::__construct($cs, !$rings);
     if (!$rings) {
         return;
     }
     CoordinateSystem::check($this, ...$rings);
     $this->rings = $rings;
 }
예제 #2
0
 /**
  * Class constructor.
  *
  * The coordinate system of each of the patches must match the one of the PolyhedralSurface.
  *
  * @param CoordinateSystem $cs         The coordinate system of the PolyhedralSurface.
  * @param Polygon          ...$patches The patches that compose the PolyhedralSurface.
  *
  * @throws CoordinateSystemException If different coordinate systems are used.
  */
 public function __construct(CoordinateSystem $cs, Polygon ...$patches)
 {
     parent::__construct($cs, !$patches);
     if (!$patches) {
         return;
     }
     CoordinateSystem::check($this, ...$patches);
     $this->patches = $patches;
 }
예제 #3
0
파일: LineString.php 프로젝트: brick/geo
 /**
  * Class constructor.
  *
  * A LineString must be composed of 2 points or more, or 0 points for an empty LineString.
  * A LineString with exactly 1 point is not allowed.
  *
  * The coordinate system of each of the points must match the one of the LineString.
  *
  * @param CoordinateSystem $cs        The coordinate system of the LineString.
  * @param Point            ...$points The points that compose the LineString.
  *
  * @throws InvalidGeometryException  If only one point was given.
  * @throws CoordinateSystemException If different coordinate systems are used.
  */
 public function __construct(CoordinateSystem $cs, Point ...$points)
 {
     parent::__construct($cs, !$points);
     if (!$points) {
         return;
     }
     CoordinateSystem::check($this, ...$points);
     if (count($points) < 2) {
         throw new InvalidGeometryException('A LineString must be composed of at least 2 points.');
     }
     $this->points = $points;
 }
예제 #4
0
 /**
  * @param CoordinateSystem $cs
  * @param Point            ...$points
  *
  * @return CircularString
  *
  * @throws InvalidGeometryException  If the number of points is invalid.
  * @throws CoordinateSystemException If different coordinate systems are used.
  */
 public function __construct(CoordinateSystem $cs, Point ...$points)
 {
     parent::__construct($cs, !$points);
     if (!$points) {
         return;
     }
     CoordinateSystem::check($this, ...$points);
     $numPoints = count($points);
     if ($numPoints < 3) {
         throw new InvalidGeometryException('A CircularString must be made of at least 3 points.');
     }
     if ($numPoints % 2 === 0) {
         throw new InvalidGeometryException('A CircularString must have an odd number of points.');
     }
     $this->points = $points;
 }
예제 #5
0
 /**
  * Class constructor.
  *
  * @param CoordinateSystem $cs
  * @param Geometry         ...$geometries
  *
  * @throws CoordinateSystemException   If different coordinate systems are used.
  * @throws UnexpectedGeometryException If a geometry is not a valid type for a sub-class of GeometryCollection.
  */
 public function __construct(CoordinateSystem $cs, Geometry ...$geometries)
 {
     $isEmpty = true;
     foreach ($geometries as $geometry) {
         if (!$geometry->isEmpty()) {
             $isEmpty = false;
             break;
         }
     }
     parent::__construct($cs, $isEmpty);
     if (!$geometries) {
         return;
     }
     CoordinateSystem::check($this, ...$geometries);
     $containedGeometryType = $this->containedGeometryType();
     foreach ($geometries as $geometry) {
         if (!$geometry instanceof $containedGeometryType) {
             throw new UnexpectedGeometryException(sprintf('%s expects instance of %s, instance of %s given.', static::class, $containedGeometryType, get_class($geometry)));
         }
     }
     $this->geometries = $geometries;
 }
예제 #6
0
파일: CompoundCurve.php 프로젝트: brick/geo
 /**
  * Class constructor.
  *
  * The coordinate system of each of the curves must match the one of the CompoundCurve.
  *
  * @param CoordinateSystem $cs        The coordinate system of the CompoundCurve.
  * @param Curve            ...$curves The curves that compose the CompoundCurve.
  *
  * @throws EmptyGeometryException    If any of the input curves is empty.
  * @throws InvalidGeometryException  If the compound curve is not continuous.
  * @throws CoordinateSystemException If different coordinate systems are used.
  */
 public function __construct(CoordinateSystem $cs, Curve ...$curves)
 {
     parent::__construct($cs, !$curves);
     if (!$curves) {
         return;
     }
     CoordinateSystem::check($this, ...$curves);
     /** @var Curve|null $previousCurve */
     $previousCurve = null;
     foreach ($curves as $curve) {
         if ($previousCurve) {
             $endPoint = $previousCurve->endPoint();
             $startPoint = $curve->startPoint();
             if ($endPoint != $startPoint) {
                 // on purpose by-value comparison!
                 throw new InvalidGeometryException('Incontinuous compound curve.');
             }
         }
         $previousCurve = $curve;
     }
     $this->curves = $curves;
 }