/** * {@inheritdoc} */ public function convertToDatabaseValue(GeometryInterface $value) { if (!$value instanceof GeographyInterface) { throw InvalidValueException::invalidValueNotGeography(); } if ($value->getSrid() === null) { $value->setSrid(self::DEFAULT_SRID); } return sprintf('SRID=%d;%s(%s)', $value->getSrid(), strtoupper($value->getType()), $value); }
/** * @param AbstractGeometryType $type * @param GeometryInterface $value * * @return string */ public function convertToDatabaseValue(AbstractGeometryType $type, GeometryInterface $value) { $sridSQL = null; if ($type instanceof GeographyType && null === $value->getSrid()) { $value->setSrid(self::DEFAULT_SRID); } if (($srid = $value->getSrid()) !== null || $type instanceof GeographyType) { $sridSQL = sprintf('SRID=%d;', $srid); } return sprintf('%s%s', $sridSQL, parent::convertToDatabaseValue($type, $value)); }