/** * @param string $wkb The WKB to read. * @param integer $srid The optional SRID of the geometry. * * @return Geometry * * @throws GeometryIOException */ public function read($wkb, $srid = 0) { $buffer = new WKBBuffer($wkb); $geometry = $this->readGeometry($buffer, $srid); if (!$buffer->isEndOfStream()) { throw GeometryIOException::invalidWKB('unexpected data at end of stream'); } return $geometry; }
/** * Reads the machine byte order from the buffer and stores the result to act accordingly. * * @throws GeometryIOException */ public function readByteOrder() { $byteOrder = $this->readUnsignedChar(); if ($byteOrder !== WKBTools::BIG_ENDIAN && $byteOrder !== WKBTools::LITTLE_ENDIAN) { throw GeometryIOException::invalidWKB('unknown byte order: ' . $byteOrder); } $this->invert = $byteOrder !== $this->machineByteOrder; }