Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function convertToDatabaseValue(GeometryInterface $value)
 {
     $sridSQL = null;
     if (($srid = $value->getSrid()) !== null) {
         $sridSQL = sprintf('SRID=%d;', $srid);
     }
     return sprintf('%s%s(%s)', $sridSQL, strtoupper($value->getType()), $value);
 }
Ejemplo n.º 2
0
 /**
  * {@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);
 }
Ejemplo n.º 3
0
 /**
  * @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));
 }
 /**
  * @param GeometryInterface $object
  * @param string            $type
  * @param mixed             $value
  *
  * @return InvalidValueException
  */
 public static function invalidType(GeometryInterface $object, $type, $value)
 {
     return new self(sprintf('Invalid %s %s value of type "%s"', $object->getType(), $type, is_object($value) ? get_class($value) : gettype($value)));
 }