Ejemplo n.º 1
0
 /**
  * @dataProvider providerProxy
  *
  * @param string  $data
  * @param boolean $isBinary
  * @param boolean $is3D
  * @param boolean $isMeasured
  * @param array   $coords
  */
 public function testProxy($data, $isBinary, $is3D, $isMeasured, array $coords)
 {
     if ($isBinary) {
         $data = hex2bin($data);
     }
     $this->castToFloat($coords);
     $x = $coords ? $coords[0] : null;
     $y = $coords ? $coords[1] : null;
     $z = $coords && $is3D ? $coords[2] : null;
     $m = $coords && $isMeasured ? $coords[$is3D ? 3 : 2] : null;
     $spatialDimension = $is3D ? 3 : 2;
     $coordinateDimension = $spatialDimension + ($isMeasured ? 1 : 0);
     foreach ([0, 1] as $srid) {
         $pointProxy = new PointProxy($data, $isBinary, $srid);
         $this->assertInstanceOf(Point::class, $pointProxy);
         $this->assertSame($is3D, $pointProxy->is3D());
         $this->assertSame($isMeasured, $pointProxy->is3D());
         $this->assertSame(!$coords, $pointProxy->isEmpty());
         $this->assertSame($x, $pointProxy->x());
         $this->assertSame($y, $pointProxy->y());
         $this->assertSame($z, $pointProxy->z());
         $this->assertSame($m, $pointProxy->m());
         $this->assertSame('Point', $pointProxy->geometryType());
         $this->assertSame($coords, $pointProxy->toArray());
         $this->assertSame($srid, $pointProxy->SRID());
         $this->assertSame(0, $pointProxy->dimension());
         $this->assertSame($spatialDimension, $pointProxy->spatialDimension());
         $this->assertSame($coordinateDimension, $pointProxy->coordinateDimension());
         $asText = $isBinary ? Point::fromBinary($data)->asText() : $data;
         $this->assertSame($asText, (string) $pointProxy);
         $this->assertSame($asText, $pointProxy->asText());
         if ($coords) {
             $asBinary = $isBinary ? $data : Point::fromText($data)->asBinary();
             $this->assertSame($asBinary, $pointProxy->asBinary());
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 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 ? Point::fromBinary($this->proxyData, $this->proxySRID) : Point::fromText($this->proxyData, $this->proxySRID);
 }