Esempio n. 1
0
 /**
  * @dataProvider providerRead
  *
  * @param string $wkb The WKB to read, hex-encoded.
  * @param string $wkt The expected WKT output.
  */
 public function testRead($wkb, $wkt)
 {
     $reader = new WKBReader();
     $geometry = $reader->read(hex2bin($wkb), 4326);
     $this->assertSame($wkt, $geometry->asText());
     $this->assertSame(4326, $geometry->SRID());
 }
Esempio n. 2
0
 /**
  * Builds a Geometry from a WKB representation.
  *
  * If the resulting geometry is valid but is not an instance of the class this method is called on,
  * for example passing a Polygon WKB to Point::fromBinary(), an exception is thrown.
  *
  * @param string  $wkb  The Well-Known Binary representation.
  * @param integer $srid The optional SRID to use.
  *
  * @return static
  *
  * @throws GeometryIOException         If the given string is not a valid WKB representation.
  * @throws CoordinateSystemException   If the WKB contains mixed coordinate systems.
  * @throws InvalidGeometryException    If the WKB represents an invalid geometry.
  * @throws UnexpectedGeometryException If the resulting geometry is not an instance of the current class.
  */
 public static function fromBinary($wkb, $srid = 0)
 {
     static $wkbReader;
     if ($wkbReader === null) {
         $wkbReader = new WKBReader();
     }
     $geometry = $wkbReader->read($wkb, $srid);
     if (!$geometry instanceof static) {
         throw UnexpectedGeometryException::unexpectedGeometryType(static::class, $geometry);
     }
     return $geometry;
 }