mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Fixed broken extended objects segment fetching
This commit is contained in:
parent
a339706293
commit
473d03cf1f
@ -122,6 +122,33 @@ bool TREFile::init()
|
|||||||
return (_firstLevel >= 0);
|
return (_firstLevel >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TREFile::readExtEntry(Handle &hdl, quint32 &polygons, quint32 &lines,
|
||||||
|
quint32 &points)
|
||||||
|
{
|
||||||
|
int rb = 0;
|
||||||
|
|
||||||
|
if (_flags & 1) {
|
||||||
|
if (!readUInt32(hdl, polygons))
|
||||||
|
return -1;
|
||||||
|
rb += 4;
|
||||||
|
} else
|
||||||
|
polygons = 0;
|
||||||
|
if (_flags & 2) {
|
||||||
|
if (!readUInt32(hdl, lines))
|
||||||
|
return -1;
|
||||||
|
rb += 4;
|
||||||
|
} else
|
||||||
|
lines = 0;
|
||||||
|
if (_flags & 4) {
|
||||||
|
if (!readUInt32(hdl, points))
|
||||||
|
return -1;
|
||||||
|
rb += 4;
|
||||||
|
} else
|
||||||
|
points = 0;
|
||||||
|
|
||||||
|
return rb;
|
||||||
|
}
|
||||||
|
|
||||||
bool TREFile::load(int idx)
|
bool TREFile::load(int idx)
|
||||||
{
|
{
|
||||||
Handle hdl(this);
|
Handle hdl(this);
|
||||||
@ -196,25 +223,11 @@ bool TREFile::load(int idx)
|
|||||||
if (!seek(hdl, _extended.offset + (skip - diff) * _extended.itemSize))
|
if (!seek(hdl, _extended.offset + (skip - diff) * _extended.itemSize))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
quint32 polygons = 0, lines = 0, points = 0;
|
quint32 polygons, lines, points;
|
||||||
|
int rb;
|
||||||
for (int i = 0; i < sl.size(); i++) {
|
for (int i = 0; i < sl.size(); i++) {
|
||||||
quint32 rb = 0;
|
if ((rb = readExtEntry(hdl, polygons, lines, points)) < 0)
|
||||||
|
|
||||||
if (_flags & 1) {
|
|
||||||
if (!readUInt32(hdl, polygons))
|
|
||||||
goto error;
|
goto error;
|
||||||
rb += 4;
|
|
||||||
}
|
|
||||||
if (_flags & 2) {
|
|
||||||
if (!readUInt32(hdl, lines))
|
|
||||||
goto error;
|
|
||||||
rb += 4;
|
|
||||||
}
|
|
||||||
if (_flags & 4) {
|
|
||||||
if (!readUInt32(hdl, points))
|
|
||||||
goto error;
|
|
||||||
rb += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
sl.at(i)->setExtOffsets(polygons, lines, points);
|
sl.at(i)->setExtOffsets(polygons, lines, points);
|
||||||
if (i)
|
if (i)
|
||||||
@ -225,8 +238,7 @@ bool TREFile::load(int idx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (idx != _levels.size() - 1) {
|
if (idx != _levels.size() - 1) {
|
||||||
if (!(readUInt32(hdl, polygons) && readUInt32(hdl, lines)
|
if (readExtEntry(hdl, polygons, lines, points) < 0)
|
||||||
&& readUInt32(hdl, points)))
|
|
||||||
goto error;
|
goto error;
|
||||||
sl.last()->setExtEnds(polygons, lines, points);
|
sl.last()->setExtEnds(polygons, lines, points);
|
||||||
}
|
}
|
||||||
|
@ -46,9 +46,8 @@ private:
|
|||||||
|
|
||||||
bool load(int idx);
|
bool load(int idx);
|
||||||
int level(int bits, bool baseMap);
|
int level(int bits, bool baseMap);
|
||||||
bool parsePoly(Handle hdl, quint32 pos, const QMap<int, int> &level2bits,
|
int readExtEntry(Handle &hdl, quint32 &polygons, quint32 &lines,
|
||||||
QMap<quint32, int> &map);
|
quint32 &points);
|
||||||
bool parsePoints(Handle hdl, quint32 pos, const QMap<int, int> &level2bits);
|
|
||||||
|
|
||||||
friend QDebug operator<<(QDebug dbg, const MapLevel &level);
|
friend QDebug operator<<(QDebug dbg, const MapLevel &level);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user