/** * {@inheritdoc} */ public function write(Geometry $geometry) { $srid = $geometry->SRID(); if ($srid === 0) { return $this->doWrite($geometry); } return 'SRID=' . $geometry->SRID() . ';' . $this->prettyPrintSpace . $this->doWrite($geometry); }
/** * @param Geometry $geometry * * @return \GEOSGeometry */ private function toGEOS(Geometry $geometry) { if ($geometry->isEmpty()) { $geosGeometry = $this->wktReader->read($geometry->asText()); $geosGeometry->setSRID($geometry->SRID()); return $geosGeometry; } if ($this->hasBinaryReadWrite) { return $this->wkbReader->read($this->ewkbWriter->write($geometry)); } return $this->wkbReader->readHEX(bin2hex($this->ewkbWriter->write($geometry))); }
/** * @param Geometry $reference * @param Geometry $culprit * * @return CoordinateSystemException */ public static function sridMix(Geometry $reference, Geometry $culprit) { return new CoordinateSystemException(sprintf('SRID mix: %s with SRID %d cannot contain %s with SRID %d.', $reference->geometryType(), $reference->SRID(), $culprit->geometryType(), $culprit->SRID())); }
/** * @param Geometry $g The Geometry to test. * @param array $coords The expected raw coordinates of the geometry. * @param boolean $hasZ Whether the geometry is expected to contain Z coordinates. * @param boolean $hasM Whether the geometry is expected to contain M coordinates. * @param integer $srid The expected SRID of the geometry. */ protected final function assertGeometryContents(Geometry $g, array $coords, $hasZ = false, $hasM = false, $srid = 0) { $this->castToFloat($coords); $this->assertSame($coords, $g->toArray()); $this->assertSame($hasZ, $g->is3D()); $this->assertSame($hasM, $g->isMeasured()); $this->assertSame($srid, $g->SRID()); }