/** * {@inheritdoc} */ public function coordinateSystem() { if ($this->proxyGeometry === null) { $this->load(); } return $this->proxyGeometry->coordinateSystem(); }
/** * @dataProvider providerCreate * * @param string[] $patchesWKT The WKT of the patches (polygons) that compose the PolyhedralSurface. * @param boolean $is3D Whether the patches have Z coordinates. * @param boolean $isMeasured Whether the patches have M coordinates. * @param string $polyhedralSurfaceWKT The WKT of the expected PolyhedralSurface. */ public function testCreate(array $patchesWKT, $is3D, $isMeasured, $polyhedralSurfaceWKT) { foreach ([0, 1] as $srid) { $instantiatePolygon = function ($patch) use($srid) { return Polygon::fromText($patch, $srid); }; $cs = new CoordinateSystem($is3D, $isMeasured, $srid); $polyhedralSurface = new PolyhedralSurface($cs, ...array_map($instantiatePolygon, $patchesWKT)); $this->assertWktEquals($polyhedralSurface, $polyhedralSurfaceWKT, $srid); } }
/** * {@inheritdoc} */ function load(ObjectManager $manager) { $point1 = Point::xy(0, 0); $point2 = Point::xy(1, 0); $point3 = Point::xy(1, 1); $point4 = Point::xy(0, 1); $point5 = Point::xy(0, 0); $ring = LineString::of($point1, $point2, $point3, $point4, $point5); $poly1 = new PolygonEntity(); $poly1->setPolygon(Polygon::of($ring)); $manager->persist($poly1); $manager->flush(); }
/** * {@inheritdoc} */ public function __construct(CoordinateSystem $cs, LineString ...$rings) { parent::__construct($cs, ...$rings); if ($this->isEmpty) { return; } if ($this->exteriorRing()->numPoints() !== 4) { throw new InvalidGeometryException('A triangle must have exactly 4 (3 + 1) points.'); } if ($this->numInteriorRings() !== 0) { throw new InvalidGeometryException('A triangle must not have interior rings.'); } }
/** * {@inheritdoc} */ function load(ObjectManager $manager) { $point1 = Point::xy(0, 0); $point2 = Point::xy(1, 0); $point3 = Point::xy(1, 1); $point4 = Point::xy(0, 1); $point5 = Point::xy(0, 0); $ring1 = LineString::of($point1, $point2, $point3, $point4, $point5); $poly1 = Polygon::of($ring1); $point6 = Point::xy(2, 2); $point7 = Point::xy(3, 2); $point8 = Point::xy(3, 3); $point9 = Point::xy(2, 3); $point10 = Point::xy(2, 2); $ring2 = LineString::of($point6, $point7, $point8, $point9, $point10); $poly2 = Polygon::of($ring2); $multiPoly1 = new MultiPolygonEntity(); $multiPoly1->setMultiPolygon(MultiPolygon::of($poly1, $poly2)); $manager->persist($multiPoly1); $manager->flush(); }
/** * Creates a non-empty PolyhedralSurface composed of the given patches. * * @param Polygon $patch1 The first patch. * @param Polygon ...$patchN The subsequent patches, if any. * * @return PolyhedralSurface * * @throws CoordinateSystemException If the patches use different coordinate systems. */ public static function of(Polygon $patch1, Polygon ...$patchN) { return new static($patch1->coordinateSystem(), $patch1, ...$patchN); }
/** * @dataProvider providerInteriorRingN * * @param string $polygon The WKT of the Polygon to test. * @param integer $n The ring number. * @param string|null $interiorRingN The WKT of the expected interior ring, or NULL if an exception is expected. * @param integer $srid The SRID of the geometries. */ public function testInteriorRingN($polygon, $n, $interiorRingN, $srid) { if ($interiorRingN === null) { $this->setExpectedException(NoSuchGeometryException::class); } $ring = Polygon::fromText($polygon, $srid)->interiorRingN($n); $this->assertWktEquals($ring, $interiorRingN, $srid); }
/** * @param array $coords The expected coordinates of the Polygon as returned by toArray(). * @param boolean $is3D Whether the Polygon is expected to contain Z coordinates. * @param boolean $isMeasured Whether the Polygon is expected to contain M coordinates. * @param Polygon $polygon The Polygon to test. */ protected final function assertPolygonEquals(array $coords, $is3D, $isMeasured, Polygon $polygon) { $this->castToFloat($coords); $this->assertSame($coords, $polygon->toArray()); $this->assertSame($is3D, $polygon->is3D()); $this->assertSame($isMeasured, $polygon->isMeasured()); }