mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-19 04:02:09 +01:00
Code cleanup
This commit is contained in:
parent
9779d91d31
commit
467e210581
@ -232,47 +232,24 @@ static quint32 readFprsRecord(DataStream &stream)
|
|||||||
static quint32 readFileDataRecord(DataStream &stream)
|
static quint32 readFileDataRecord(DataStream &stream)
|
||||||
{
|
{
|
||||||
RecordHeader rh;
|
RecordHeader rh;
|
||||||
quint32 ds, s1;
|
quint32 ds, flags;
|
||||||
quint16 s2, s3;
|
quint16 s2, s3;
|
||||||
quint8 rs;
|
quint8 rs;
|
||||||
QList<TranslatedString> obj;
|
QList<TranslatedString> obj;
|
||||||
|
|
||||||
rs = stream.readRecordHeader(rh);
|
rs = stream.readRecordHeader(rh);
|
||||||
stream >> s1 >> s2 >> s3;
|
stream >> flags >> s2 >> s3;
|
||||||
ds = 8;
|
ds = 8;
|
||||||
|
// name
|
||||||
ds += stream.readTranslatedObjects(obj);
|
ds += stream.readTranslatedObjects(obj);
|
||||||
|
// copyright
|
||||||
ds += stream.readTranslatedObjects(obj);
|
ds += stream.readTranslatedObjects(obj);
|
||||||
|
// additional stuff depending on flags
|
||||||
if (s1 & 0x10) {
|
// ...
|
||||||
quint8 ss1, ss2;
|
|
||||||
quint16 ss3;
|
|
||||||
stream >> ss1 >> ss2 >> ss3;
|
|
||||||
ds += 4;
|
|
||||||
}
|
|
||||||
if (s1 & 0x100) {
|
|
||||||
quint32 ss1;
|
|
||||||
stream >> ss1;
|
|
||||||
if (ss1)
|
|
||||||
stream.skipRawData(ss1);
|
|
||||||
ds += ss1 + 4;
|
|
||||||
}
|
|
||||||
if (s1 & 0x400) {
|
|
||||||
QString str;
|
|
||||||
ds += stream.readString(str);
|
|
||||||
}
|
|
||||||
if (s1 & 0x400000) {
|
|
||||||
quint16 ss1;
|
|
||||||
stream >> ss1;
|
|
||||||
if (ss1)
|
|
||||||
stream.skipRawData(ss1);
|
|
||||||
ds += ss1 + 2;
|
|
||||||
}
|
|
||||||
// structure of higher fields not known
|
|
||||||
|
|
||||||
if (ds > rh.size)
|
if (ds > rh.size)
|
||||||
stream.setStatus(QDataStream::ReadCorruptData);
|
stream.setStatus(QDataStream::ReadCorruptData);
|
||||||
else if (ds < rh.size)
|
else if (ds < rh.size)
|
||||||
// skip remaining unknown fields
|
|
||||||
stream.skipRawData(rh.size - ds);
|
stream.skipRawData(rh.size - ds);
|
||||||
|
|
||||||
return rs + rh.size;
|
return rs + rh.size;
|
||||||
@ -299,18 +276,18 @@ static quint32 readDescription(DataStream &stream, Waypoint &waypoint)
|
|||||||
static quint32 readNotes(DataStream &stream, Waypoint &waypoint)
|
static quint32 readNotes(DataStream &stream, Waypoint &waypoint)
|
||||||
{
|
{
|
||||||
RecordHeader rh;
|
RecordHeader rh;
|
||||||
quint8 rs, s1;
|
quint8 rs, flags;
|
||||||
quint32 ds = 1;
|
quint32 ds = 1;
|
||||||
|
|
||||||
rs = stream.readRecordHeader(rh);
|
rs = stream.readRecordHeader(rh);
|
||||||
stream >> s1;
|
stream >> flags;
|
||||||
if (s1 & 0x1) {
|
if (flags & 0x1) {
|
||||||
QList<TranslatedString> obj;
|
QList<TranslatedString> obj;
|
||||||
ds += stream.readTranslatedObjects(obj);
|
ds += stream.readTranslatedObjects(obj);
|
||||||
if (!obj.isEmpty())
|
if (!obj.isEmpty())
|
||||||
waypoint.setComment(obj.first().str());
|
waypoint.setComment(obj.first().str());
|
||||||
}
|
}
|
||||||
if (s1 & 0x2) {
|
if (flags & 0x2) {
|
||||||
QString str;
|
QString str;
|
||||||
ds += stream.readString(str);
|
ds += stream.readString(str);
|
||||||
if (!str.isEmpty())
|
if (!str.isEmpty())
|
||||||
@ -560,7 +537,7 @@ static quint32 readPOI(DataStream &stream, QVector<Waypoint> &waypoints,
|
|||||||
quint8 rs;
|
quint8 rs;
|
||||||
quint32 ds;
|
quint32 ds;
|
||||||
qint32 lat, lon;
|
qint32 lat, lon;
|
||||||
quint16 s3;
|
quint16 s3, id;
|
||||||
QList<TranslatedString> obj;
|
QList<TranslatedString> obj;
|
||||||
|
|
||||||
rs = stream.readRecordHeader(rh);
|
rs = stream.readRecordHeader(rh);
|
||||||
@ -574,12 +551,10 @@ static quint32 readPOI(DataStream &stream, QVector<Waypoint> &waypoints,
|
|||||||
waypoints.last().setName(obj.first().str());
|
waypoints.last().setName(obj.first().str());
|
||||||
|
|
||||||
while (stream.status() == QDataStream::Ok && ds < rh.size) {
|
while (stream.status() == QDataStream::Ok && ds < rh.size) {
|
||||||
quint16 type = stream.nextHeaderType();
|
switch (stream.nextHeaderType()) {
|
||||||
switch(type) {
|
|
||||||
case 4:
|
case 4:
|
||||||
{quint16 id;
|
|
||||||
ds += readIconId(stream, id);
|
ds += readIconId(stream, id);
|
||||||
icons.append(QPair<int, quint16>(waypoints.size() - 1, id));}
|
icons.append(QPair<int, quint16>(waypoints.size() - 1, id));
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
ds += readDescription(stream, waypoints.last());
|
ds += readDescription(stream, waypoints.last());
|
||||||
@ -623,10 +598,9 @@ static quint32 readSpatialIndex(DataStream &stream, QVector<Waypoint> &waypoints
|
|||||||
ds = 22 + s6;
|
ds = 22 + s6;
|
||||||
if (rh.flags & 0x8) {
|
if (rh.flags & 0x8) {
|
||||||
while (stream.status() == QDataStream::Ok && ds < rh.size) {
|
while (stream.status() == QDataStream::Ok && ds < rh.size) {
|
||||||
switch(stream.nextHeaderType()) {
|
switch (stream.nextHeaderType()) {
|
||||||
case 2:
|
case 2:
|
||||||
ds += readPOI(stream, waypoints, fileName, imgId,
|
ds += readPOI(stream, waypoints, fileName, imgId, icons);
|
||||||
icons);
|
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
ds += readSpatialIndex(stream, waypoints, polygons,
|
ds += readSpatialIndex(stream, waypoints, polygons,
|
||||||
@ -708,8 +682,7 @@ static void readPOIDatabase(DataStream &stream, QVector<Waypoint> &waypoints,
|
|||||||
ds += readSpatialIndex(stream, waypoints, polygons, fileName, imgId, il);
|
ds += readSpatialIndex(stream, waypoints, polygons, fileName, imgId, il);
|
||||||
if (rh.flags & 0x8) {
|
if (rh.flags & 0x8) {
|
||||||
while (stream.status() == QDataStream::Ok && ds < rh.size) {
|
while (stream.status() == QDataStream::Ok && ds < rh.size) {
|
||||||
quint16 type = stream.nextHeaderType();
|
switch (stream.nextHeaderType()) {
|
||||||
switch(type) {
|
|
||||||
case 5:
|
case 5:
|
||||||
icons.append(QPixmap());
|
icons.append(QPixmap());
|
||||||
ds += readSymbol(stream, icons.last());
|
ds += readSymbol(stream, icons.last());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user