/** * Tests Countable and Traversable interfaces. */ public function testInterfaces() { $lineString = LineString::fromText('LINESTRING (1 2, 3 4, 5 6)'); $this->assertInstanceOf(\Countable::class, $lineString); $this->assertSame(3, count($lineString)); $this->assertInstanceOf(\Traversable::class, $lineString); $this->assertSame([$lineString->pointN(1), $lineString->pointN(2), $lineString->pointN(3)], iterator_to_array($lineString)); }
/** * Tests Countable and Traversable interfaces. */ public function testInterfaces() { $point = Point::fromText('POINT (1 2)'); $lineString = LineString::fromText('LINESTRING (1 2, 3 4)'); $geometryCollection = GeometryCollection::of($point, $lineString); $this->assertInstanceOf(\Countable::class, $geometryCollection); $this->assertSame(2, count($geometryCollection)); $this->assertInstanceOf(\Traversable::class, $geometryCollection); $this->assertSame([$point, $lineString], iterator_to_array($geometryCollection)); }
/** * @expectedException \Brick\Geo\Exception\InvalidGeometryException */ public function testCreateWithInteriorRings() { $exteriorRing = LineString::fromText('LINESTRING (0 0, 0 3, 3 3, 0 0)'); $interiorRing = LineString::fromText('LINESTRING (1 1, 1 2, 2 2, 1 1)'); Triangle::of($exteriorRing, $interiorRing); }
/** * @dataProvider providerOfWithCoordinateSystemMix * @expectedException \Brick\Geo\Exception\CoordinateSystemException * * @param string $outerRingWKT * @param string $innerRingWKT * @param integer $outerRingSRID * @param integer $innerRingSRID */ public function testOfWithCoordinateSystemMix($outerRingWKT, $innerRingWKT, $outerRingSRID, $innerRingSRID) { $outerRing = LineString::fromText($outerRingWKT, $outerRingSRID); $innerRing = LineString::fromText($innerRingWKT, $innerRingSRID); Polygon::of($outerRing, $innerRing); }
/** * Loads the underlying geometry. * * @return void * * @throws GeometryIOException If the proxy data is not valid. * @throws CoordinateSystemException If the resulting geometry contains mixed coordinate systems. * @throws InvalidGeometryException If the resulting geometry is not valid. * @throws UnexpectedGeometryException If the resulting geometry is not an instance of the proxied class. */ private function load() { $this->proxyGeometry = $this->proxyIsBinary ? LineString::fromBinary($this->proxyData, $this->proxySRID) : LineString::fromText($this->proxyData, $this->proxySRID); }