1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Fixed broken points(points labels) parsing

This commit is contained in:
Martin Tůma 2022-02-06 04:17:08 +01:00
parent 5d6970c7ee
commit f1e9983a58
4 changed files with 29 additions and 28 deletions

View File

@ -180,7 +180,7 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
Shield(shieldType, _codec.toString(shieldLabel)));
}
Label LBLFile::label6b(const SubFile *file, Handle &hdl, bool capitalize,
Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, bool capitalize,
bool convert) const
{
Shield::Type shieldType = Shield::None;
@ -191,8 +191,8 @@ Label LBLFile::label6b(const SubFile *file, Handle &hdl, bool capitalize,
int split = -1;
while (true) {
if (!(file->readByte(hdl, &b1) && file->readByte(hdl, &b2)
&& file->readByte(hdl, &b3)))
if (!(file->readByte(fileHdl, &b1) && file->readByte(fileHdl, &b2)
&& file->readByte(fileHdl, &b3)))
return Label();
int c[]= {b1>>2, (b1&0x3)<<4|b2>>4, (b2&0xF)<<2|b3>>6, b3&0x3F};
@ -244,14 +244,14 @@ Label LBLFile::label6b(const SubFile *file, Handle &hdl, bool capitalize,
}
}
Label LBLFile::label8b(const SubFile *file, Handle &hdl, bool capitalize,
Label LBLFile::label8b(const SubFile *file, Handle &fileHdl, bool capitalize,
bool convert) const
{
QVector<quint8> str;
quint8 c;
do {
if (!file->readByte(hdl, &c))
if (!file->readByte(fileHdl, &c))
return Label();
str.append(c);
} while (c);
@ -259,13 +259,12 @@ Label LBLFile::label8b(const SubFile *file, Handle &hdl, bool capitalize,
return str2label(str, capitalize, convert);
}
Label LBLFile::labelHuffman(const SubFile *file, Handle &hdl, bool capitalize,
bool convert) const
Label LBLFile::labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
bool capitalize, bool convert) const
{
QVector<quint8> str;
quint32 end = _offset + _size;
if (!_huffmanText->decode(file, hdl, end - pos(hdl), str))
if (!_huffmanText->decode(file, fileHdl, 0xFFFFFFFF, str))
return Label();
if (!_table)
return str2label(str, capitalize, convert);
@ -284,7 +283,7 @@ Label LBLFile::labelHuffman(const SubFile *file, Handle &hdl, bool capitalize,
else if (str2.size())
str2.append(' ');
if (!_huffmanText->decode(file, hdl, end - off, str2))
if (!_huffmanText->decode(this, hdl, _offset + _size - off, str2))
return Label();
} else {
if (str.at(i) == 7) {
@ -320,20 +319,20 @@ Label LBLFile::label(Handle &hdl, quint32 offset, bool poi, bool capitalize,
if (!seek(hdl, labelOffset))
return Label();
return label(this, hdl, capitalize, convert);
return label(hdl, this, hdl, capitalize, convert);
}
Label LBLFile::label(const SubFile *file, Handle &hdl, bool capitalize,
bool convert) const
Label LBLFile::label(Handle &hdl, const SubFile *file, Handle &fileHdl,
bool capitalize, bool convert) const
{
switch (_encoding) {
case 6:
return label6b(file, hdl, capitalize, convert);
return label6b(file, fileHdl, capitalize, convert);
case 9:
case 10:
return label8b(file, hdl, capitalize, convert);
return label8b(file, fileHdl, capitalize, convert);
case 11:
return labelHuffman(file, hdl, capitalize, convert);
return labelHuffman(hdl, file, fileHdl, capitalize, convert);
default:
return Label();
}

View File

@ -33,8 +33,8 @@ public:
Label label(Handle &hdl, quint32 offset, bool poi = false,
bool capitalize = true, bool convert = false) const;
Label label(const SubFile *file, Handle &hdl, bool capitalize = true,
bool convert = false) const;
Label label(Handle &hdl, const SubFile *file, Handle &fileHdl,
bool capitalize = true, bool convert = false) const;
quint8 imageIdSize() const {return _imgOffsetIdSize;}
QPixmap image(Handle &hdl, quint32 id) const;
@ -47,12 +47,12 @@ private:
Label str2label(const QVector<quint8> &str, bool capitalize,
bool convert) const;
Label label6b(const SubFile *file, Handle &hdl, bool capitalize,
Label label6b(const SubFile *file, Handle &fileHdl, bool capitalize,
bool convert) const;
Label label8b(const SubFile *file, Handle &hdl, bool capitalize,
bool convert) const;
Label labelHuffman(const SubFile *file, Handle &hdl, bool capitalize,
Label label8b(const SubFile *file, Handle &fileHdl, bool capitalize,
bool convert) const;
Label labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
bool capitalize, bool convert) const;
bool loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
quint32 recordSize);

View File

@ -33,7 +33,7 @@ RGNFile::~RGNFile()
}
bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
void *object, const LBLFile *lbl) const
void *object, const LBLFile *lbl, Handle &lblHdl) const
{
quint8 flags;
quint32 rs;
@ -83,10 +83,11 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
if (point && (flags & 1) && lbl) {
quint32 p = pos(hdl);
point->label = lbl->label(this, hdl);
point->label = lbl->label(lblHdl, this, hdl);
point->classLabel = true;
rs -= (pos(hdl) - p);
Q_ASSERT(pos(hdl) - p <= rs + 4);
rs -= pos(hdl) - p;
}
return seek(hdl, pos(hdl) + rs);
@ -356,7 +357,8 @@ bool RGNFile::extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift,
if (subtype & 0x20 && !readUInt24(hdl, labelPtr))
return false;
if (subtype & 0x80 && !readClassFields(hdl, segmentType, &poly, lbl))
if (subtype & 0x80 && !readClassFields(hdl, segmentType, &poly, lbl,
lblHdl))
return false;
if (subtype & 0x40 && !skipLclFields(hdl, segmentType == Line
? _linesLclFlags : _polygonsLclFlags))
@ -446,7 +448,7 @@ bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv,
if (subtype & 0x20 && !readUInt24(hdl, labelPtr))
return false;
if (subtype & 0x80 && !readClassFields(hdl, Point, &point, lbl))
if (subtype & 0x80 && !readClassFields(hdl, Point, &point, lbl, lblHdl))
return false;
if (subtype & 0x40 && !skipLclFields(hdl, _pointsLclFlags))
return false;

View File

@ -63,7 +63,7 @@ public:
private:
bool segments(Handle &hdl, SubDiv *subdiv, SubDiv::Segment seg[5]) const;
bool readClassFields(Handle &hdl, SegmentType segmentType, void *object,
const LBLFile *lbl) const;
const LBLFile *lbl, Handle &lblHdl) const;
bool skipLclFields(Handle &hdl, const quint32 flags[3]) const;
bool skipGblFields(Handle &hdl, quint32 flags) const;