コード例 #1
0
ファイル: GEOSEngine.php プロジェクト: brick/geo
 /**
  * @param \GEOSGeometry $geometry
  *
  * @return Geometry
  */
 private function fromGEOS(\GEOSGeometry $geometry)
 {
     if ($geometry->isEmpty()) {
         return Geometry::fromText($this->wktWriter->write($geometry), $geometry->getSRID());
     }
     if ($this->hasBinaryReadWrite) {
         return $this->ewkbReader->read($this->wkbWriter->write($geometry));
     }
     return $this->ewkbReader->read(hex2bin($this->wkbWriter->writeHEX($geometry)));
 }
コード例 #2
0
ファイル: GeometryConverter.php プロジェクト: brick/brick
 /**
  * {@inheritdoc}
  */
 public function expand($className, $value, array $options = [])
 {
     if ($className == Geometry::class || is_subclass_of($className, Geometry::class)) {
         try {
             $geometry = Geometry::fromText($value);
             if (!$geometry instanceof $className) {
                 throw new ObjectNotConvertibleException(sprintf('Expected instance of %s, got instance of %s.', $className, get_class($geometry)));
             }
             return $geometry;
         } catch (GeometryException $e) {
             throw new ObjectNotConvertibleException($e->getMessage(), $e->getCode(), $e);
         }
     }
     return null;
 }
コード例 #3
0
ファイル: GeometryProxy.php プロジェクト: brick/geo
 /**
  * Loads the underlying geometry.
  *
  * @return void
  *
  * @throws GeometryIOException         If the proxy data is not valid.
  * @throws CoordinateSystemException   If the resulting geometry contains mixed coordinate systems.
  * @throws InvalidGeometryException    If the resulting geometry is not valid.
  * @throws UnexpectedGeometryException If the resulting geometry is not an instance of the proxied class.
  */
 private function load()
 {
     $this->proxyGeometry = $this->proxyIsBinary ? Geometry::fromBinary($this->proxyData, $this->proxySRID) : Geometry::fromText($this->proxyData, $this->proxySRID);
 }
コード例 #4
0
ファイル: GeometryTest.php プロジェクト: brick/geo
 /**
  * @dataProvider providerToArray
  *
  * @param string $geometry The WKT of the geometry to test.
  * @param array  $array    The expected result array.
  */
 public function testToArray($geometry, $array)
 {
     $this->castToFloat($array);
     $this->assertSame($array, Geometry::fromText($geometry)->toArray());
 }