/** * @dataProvider providerRead * * @param string $ewkb The EWKB to read, hex-encoded. * @param string $ewkt The expected EWKT output. */ public function testRead($ewkb, $ewkt) { $reader = new EWKBReader(); $writer = new EWKTWriter(); $geometry = $reader->read(hex2bin($ewkb)); $this->assertSame($ewkt, $writer->write($geometry)); }
/** * @dataProvider providerGeometryCollectionWKT * * @param string $wkt The expected WKT. * @param array $coords The GeometryCollection coordinates. * @param boolean $is3D Whether the GeometryCollection has Z coordinates. * @param boolean $isMeasured Whether the GeometryCollection has M coordinates. */ public function testWriteGeometryCollection($wkt, array $coords, $is3D, $isMeasured) { $writer = new EWKTWriter(); $writer->setPrettyPrint(false); $cs = new CoordinateSystem($is3D, $isMeasured, 4326); if ($coords) { $point = $this->createPoint($coords[0], $cs); $lineString = $this->createLineString($coords[1], $cs); $geometries = [$point, $lineString]; } else { $geometries = []; } $geometryCollection = new GeometryCollection($cs, ...$geometries); $this->assertSame($this->toEWKT($wkt, 4326), $writer->write($geometryCollection)); }