/** * {@inheritdoc} */ public function getIterator() { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->getIterator(); }
/** * @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); } }
/** * 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; }
/** * @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; }
/** * @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; }
/** * 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); }
/** * @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()); }
/** * 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); }