Example #1
0
 /**
  * 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));
 }
Example #2
0
 /**
  * @dataProvider providerPrettyPrint
  *
  * @param boolean $is3D        Whether to use Z coordinates.
  * @param boolean $prettyPrint Whether to set the prettyPrint parameter.
  * @param string  $wkt         The expected result WKT.
  */
 public function testPrettyPrint($is3D, $prettyPrint, $wkt)
 {
     $writer = new WKTWriter();
     $writer->setPrettyPrint($prettyPrint);
     $cs = new CoordinateSystem($is3D, false);
     $one = $is3D ? [1, 2, 3] : [1, 2];
     $two = $is3D ? [2, 3, 4] : [2, 3];
     $four = $is3D ? [4, 5, 6] : [4, 5];
     $five = $is3D ? [5, 6, 7] : [5, 6];
     $point = $this->createPoint($one, $cs);
     $lineString1 = $this->createLineString([$one, $four], $cs);
     $lineString2 = $this->createLineString([$two, $five], $cs);
     $multiLineString = MultiLineString::of($lineString1, $lineString2);
     $geometryCollection = GeometryCollection::of($point, $multiLineString);
     $this->assertSame($wkt, $writer->write($geometryCollection));
 }