Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getIterator()
 {
     if ($this->proxyGeometry === null) {
         $this->load();
     }
     return $this->proxyGeometry->getIterator();
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider providerCreate
  *
  * @param string[] $curvesWKT        The WKT of the Curves that compose the CompoundCurve.
  * @param boolean  $is3D             Whether the curves have Z coordinates.
  * @param boolean  $isMeasured       Whether the curves have M coordinates.
  * @param string   $compoundCurveWKT The WKT of the expected CompoundCurve.
  */
 public function testCreate(array $curvesWKT, $is3D, $isMeasured, $compoundCurveWKT)
 {
     foreach ([0, 1] as $srid) {
         $instantiateCurve = function ($curve) use($srid) {
             return Curve::fromText($curve, $srid);
         };
         $cs = new CoordinateSystem($is3D, $isMeasured, $srid);
         $compoundCurve = new CompoundCurve($cs, ...array_map($instantiateCurve, $curvesWKT));
         $this->assertWktEquals($compoundCurve, $compoundCurveWKT, $srid);
     }
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 5
0
 /**
  * @param Curve $curve
  *
  * @return string
  */
 private function packCurve(Curve $curve)
 {
     $wkb = $this->packUnsignedInteger($curve->count());
     foreach ($curve as $point) {
         $wkb .= $this->packPoint($point);
     }
     return $wkb;
 }
Ejemplo n.º 6
0
 /**
  * Creates a non-empty CurvePolygon composed of the given rings.
  *
  * @param Curve    $exteriorRing  The exterior ring.
  * @param Curve ...$interiorRings The interior rings, if any.
  *
  * @return CurvePolygon
  *
  * @throws CoordinateSystemException If the rings use different coordinate systems.
  */
 public static function of(Curve $exteriorRing, Curve ...$interiorRings)
 {
     return new static($exteriorRing->coordinateSystem(), $exteriorRing, ...$interiorRings);
 }
Ejemplo n.º 7
0
 /**
  * @dataProvider providerIsRing
  *
  * @param string  $curve  The WKT of the Curve to test.
  * @param boolean $isRing Whether the Curve is a ring.
  */
 public function testIsRing($curve, $isRing)
 {
     $this->requiresGeometryEngine();
     $curve = Curve::fromText($curve);
     $this->skipIfUnsupportedGeometry($curve);
     if ($curve->isClosed() && $this->isMariaDB('< 10.1.4')) {
         // @see https://mariadb.atlassian.net/browse/MDEV-7510
         $this->markTestSkipped('A bug in MariaDB returns the wrong result.');
     }
     $this->assertSame($isRing, $curve->isRing());
 }
Ejemplo n.º 8
0
 /**
  * Creates a non-empty CompoundCurve composed of the given curves.
  *
  * @param Curve    $curve1 The first curve.
  * @param Curve ...$curveN The subsequent curves, if any.
  *
  * @return CompoundCurve
  *
  * @throws EmptyGeometryException    If any of the input curves is empty.
  * @throws InvalidGeometryException  If the compound curve is not continuous.
  * @throws CoordinateSystemException If the curves use different coordinate systems.
  */
 public static function of(Curve $curve1, Curve ...$curveN)
 {
     return new CompoundCurve($curve1->coordinateSystem(), $curve1, ...$curveN);
 }