protected function assertGeometry($geometry, $type = null) { if (!$geometry instanceof Geometry) { throw InvalidGeometryException::create($geometry); } if (null !== $type && !$geometry instanceof $type) { throw InvalidGeometryTypeException::create($type, $geometry); } if ($geometry->getDimension() !== $this->getDimension()) { throw MixedDimensionalityException::create($this, $geometry); } if (null !== ($srid = $geometry->getSrid()) && $srid !== $this->getSrid()) { throw MixedSridsException::create($this, $geometry); } }
public function extractType($geometry) { switch (true) { case $geometry instanceof Point: return ExtractorInterface::TYPE_POINT; case $geometry instanceof LineString: return ExtractorInterface::TYPE_LINESTRING; case $geometry instanceof Polygon: return ExtractorInterface::TYPE_POLYGON; case $geometry instanceof MultiPoint: return ExtractorInterface::TYPE_MULTIPOINT; case $geometry instanceof MultiLineString: return ExtractorInterface::TYPE_MULTILINESTRING; case $geometry instanceof MultiPolygon: return ExtractorInterface::TYPE_MULTIPOLYGON; case $geometry instanceof GeometryCollection: return ExtractorInterface::TYPE_GEOMETRYCOLLECTION; default: throw InvalidGeometryException::create($geometry); } }