mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Some more error checking improvements/fixes
This commit is contained in:
parent
288aa195c0
commit
b14dd23224
@ -1,6 +1,5 @@
|
|||||||
#include "deltastream.h"
|
#include "deltastream.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace IMG;
|
using namespace IMG;
|
||||||
|
|
||||||
static int bitSize(quint8 baseSize, bool variableSign, bool extraBit)
|
static int bitSize(quint8 baseSize, bool variableSign, bool extraBit)
|
||||||
@ -19,21 +18,21 @@ static int bitSize(quint8 baseSize, bool variableSign, bool extraBit)
|
|||||||
return bits;
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeltaStream::DeltaStream(const SubFile &file, SubFile::Handle &hdl,
|
bool DeltaStream::init(quint8 info, bool extraBit, bool extended)
|
||||||
quint32 length, quint8 info, bool extraBit, bool extended)
|
|
||||||
: BitStream1(file, hdl, length), _readBits(0xFFFFFFFF)
|
|
||||||
{
|
{
|
||||||
_extraBit = extraBit ? 1 : 0;
|
_extraBit = extraBit ? 1 : 0;
|
||||||
if (!(sign(_lonSign) && sign(_latSign)))
|
if (!(sign(_lonSign) && sign(_latSign)))
|
||||||
return;
|
return false;
|
||||||
if (extended) {
|
if (extended) {
|
||||||
quint32 b;
|
quint32 b;
|
||||||
if (!read(1, b))
|
if (!read(1, b))
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
_lonBits = bitSize(info & 0x0F, !_lonSign, extraBit);
|
_lonBits = bitSize(info & 0x0F, !_lonSign, extraBit);
|
||||||
_latBits = bitSize(info >> 4, !_latSign, false);
|
_latBits = bitSize(info >> 4, !_latSign, false);
|
||||||
_readBits = _lonBits + _latBits;
|
_readBits = _lonBits + _latBits;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeltaStream::readDelta(int bits, int sign, int extraBit,
|
bool DeltaStream::readDelta(int bits, int sign, int extraBit,
|
||||||
|
@ -7,9 +7,10 @@ namespace IMG {
|
|||||||
|
|
||||||
class DeltaStream : public BitStream1 {
|
class DeltaStream : public BitStream1 {
|
||||||
public:
|
public:
|
||||||
DeltaStream(const SubFile &file, SubFile::Handle &hdl, quint32 length,
|
DeltaStream(const SubFile &file, SubFile::Handle &hdl, quint32 length)
|
||||||
quint8 info, bool extraBit, bool extended);
|
: BitStream1(file, hdl, length), _readBits(0xFFFFFFFF) {}
|
||||||
|
|
||||||
|
bool init(quint8 info, bool extraBit, bool extended);
|
||||||
bool readNext(qint32 &lonDelta, qint32 &latDelta)
|
bool readNext(qint32 &lonDelta, qint32 &latDelta)
|
||||||
{
|
{
|
||||||
return hasNext()
|
return hasNext()
|
||||||
|
@ -218,8 +218,9 @@ bool RGNFile::polyObjects(Handle &hdl, const SubDiv *subdiv,
|
|||||||
poly.points.append(QPointF(c.lon(), c.lat()));
|
poly.points.append(QPointF(c.lon(), c.lat()));
|
||||||
|
|
||||||
qint32 lonDelta, latDelta;
|
qint32 lonDelta, latDelta;
|
||||||
DeltaStream stream(*this, hdl, len, bitstreamInfo, labelPtr & 0x400000,
|
DeltaStream stream(*this, hdl, len);
|
||||||
false);
|
if (!stream.init(bitstreamInfo, labelPtr & 0x400000, false))
|
||||||
|
return false;
|
||||||
while (stream.readNext(lonDelta, latDelta)) {
|
while (stream.readNext(lonDelta, latDelta)) {
|
||||||
pos.rx() += LS(lonDelta, (24-subdiv->bits()));
|
pos.rx() += LS(lonDelta, (24-subdiv->bits()));
|
||||||
if (pos.rx() >= 0x800000 && subdiv->lon() >= 0)
|
if (pos.rx() >= 0x800000 && subdiv->lon() >= 0)
|
||||||
@ -325,8 +326,9 @@ bool RGNFile::extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
qint32 lonDelta, latDelta;
|
qint32 lonDelta, latDelta;
|
||||||
DeltaStream stream(*this, hdl, len - 1, bitstreamInfo, false, true);
|
DeltaStream stream(*this, hdl, len - 1);
|
||||||
|
if (!stream.init(bitstreamInfo, false, true))
|
||||||
|
return false;
|
||||||
while (stream.readNext(lonDelta, latDelta)) {
|
while (stream.readNext(lonDelta, latDelta)) {
|
||||||
pos.rx() += LS(lonDelta, 24-subdiv->bits());
|
pos.rx() += LS(lonDelta, 24-subdiv->bits());
|
||||||
if (pos.rx() >= 0x800000 && subdiv->lon() >= 0)
|
if (pos.rx() >= 0x800000 && subdiv->lon() >= 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user