1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Compare commits

...

3 Commits

Author SHA1 Message Date
5af3808895 Properly compute the header size
+ code cleanup
2022-06-11 10:19:14 +02:00
1f2e460c87 Silenced clang warning 2022-06-11 09:48:55 +02:00
57c524e08a Version++ 2022-06-11 09:35:01 +02:00
6 changed files with 34 additions and 35 deletions

View File

@ -1,4 +1,4 @@
version: 11.1.{build} version: 11.2.{build}
configuration: configuration:
- Release - Release

View File

@ -3,7 +3,7 @@ unix:!macx:!android {
} else { } else {
TARGET = GPXSee TARGET = GPXSee
} }
VERSION = 11.1 VERSION = 11.2
QT += core \ QT += core \
gui \ gui \

View File

@ -37,7 +37,7 @@ Unicode true
; The name of the installer ; The name of the installer
Name "GPXSee" Name "GPXSee"
; Program version ; Program version
!define VERSION "11.1" !define VERSION "11.2"
; The file to write ; The file to write
OutFile "GPXSee-${VERSION}_x64.exe" OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -87,7 +87,7 @@ Map *MapList::loadFile(const QString &path, const Projection &proj, bool *isDir)
if (!map) { if (!map) {
qWarning("Error loading map file: %s:", qPrintable(path)); qWarning("Error loading map file: %s:", qPrintable(path));
for (int i = 0; i < errors.size(); i++) for (int i = 0; i < errors.size(); i++)
qWarning(qPrintable(errors.at(i))); qWarning("%s", qPrintable(errors.at(i)));
} }
} }

View File

@ -283,45 +283,45 @@ bool MapData::readSubFiles()
return true; return true;
} }
bool MapData::readZoomInfo(SubFile &subfile) bool MapData::readZoomInfo(SubFile &hdr)
{ {
quint8 zooms; quint8 zooms;
if (!subfile.readByte(zooms)) if (!hdr.readByte(zooms))
return false; return false;
_subFiles.resize(zooms); _subFiles.resize(zooms);
for (quint8 i = 0; i < zooms; i++) { for (quint8 i = 0; i < zooms; i++) {
if (!(subfile.readByte(_subFiles[i].base) if (!(hdr.readByte(_subFiles[i].base)
&& subfile.readByte(_subFiles[i].min) && hdr.readByte(_subFiles[i].min)
&& subfile.readByte(_subFiles[i].max) && hdr.readByte(_subFiles[i].max)
&& subfile.readUInt64(_subFiles[i].offset) && hdr.readUInt64(_subFiles[i].offset)
&& subfile.readUInt64(_subFiles[i].size))) && hdr.readUInt64(_subFiles[i].size)))
return false; return false;
} }
return true; return true;
} }
bool MapData::readTagInfo(SubFile &subfile) bool MapData::readTagInfo(SubFile &hdr)
{ {
quint16 tags; quint16 tags;
QByteArray tag; QByteArray tag;
if (!subfile.readUInt16(tags)) if (!hdr.readUInt16(tags))
return false; return false;
_pointTags.resize(tags); _pointTags.resize(tags);
for (quint16 i = 0; i < tags; i++) { for (quint16 i = 0; i < tags; i++) {
if (!subfile.readString(tag)) if (!hdr.readString(tag))
return false; return false;
_pointTags[i] = tag; _pointTags[i] = tag;
} }
if (!subfile.readUInt16(tags)) if (!hdr.readUInt16(tags))
return false; return false;
_pathTags.resize(tags); _pathTags.resize(tags);
for (quint16 i = 0; i < tags; i++) { for (quint16 i = 0; i < tags; i++) {
if (!subfile.readString(tag)) if (!hdr.readString(tag))
return false; return false;
_pathTags[i] = tag; _pathTags[i] = tag;
} }
@ -329,7 +329,7 @@ bool MapData::readTagInfo(SubFile &subfile)
return true; return true;
} }
bool MapData::readMapInfo(SubFile &subfile, QByteArray &projection, bool MapData::readMapInfo(SubFile &hdr, QByteArray &projection,
bool &debugMap) bool &debugMap)
{ {
quint64 fileSize, date; quint64 fileSize, date;
@ -337,37 +337,36 @@ bool MapData::readMapInfo(SubFile &subfile, QByteArray &projection,
qint32 minLat, minLon, maxLat, maxLon; qint32 minLat, minLon, maxLat, maxLon;
quint8 flags; quint8 flags;
if (!(subfile.seek(MAGIC_SIZE + 4) if (!(hdr.seek(4) && hdr.readUInt32(version) && hdr.readUInt64(fileSize)
&& subfile.readUInt32(version) && subfile.readUInt64(fileSize) && hdr.readUInt64(date) && hdr.readInt32(minLat) && hdr.readInt32(minLon)
&& subfile.readUInt64(date) && subfile.readInt32(minLat) && hdr.readInt32(maxLat) && hdr.readInt32(maxLon)
&& subfile.readInt32(minLon) && subfile.readInt32(maxLat) && hdr.readUInt16(_tileSize) && hdr.readString(projection)
&& subfile.readInt32(maxLon) && subfile.readUInt16(_tileSize) && hdr.readByte(flags)))
&& subfile.readString(projection) && subfile.readByte(flags)))
return false; return false;
if (flags & 0x40) { if (flags & 0x40) {
qint32 startLon, startLat; qint32 startLon, startLat;
if (!(subfile.readInt32(startLat) && subfile.readInt32(startLon))) if (!(hdr.readInt32(startLat) && hdr.readInt32(startLon)))
return false; return false;
} }
if (flags & 0x20) { if (flags & 0x20) {
quint8 startZoom; quint8 startZoom;
if (!subfile.readByte(startZoom)) if (!hdr.readByte(startZoom))
return false; return false;
} }
if (flags & 0x10) { if (flags & 0x10) {
QByteArray lang; QByteArray lang;
if (!subfile.readString(lang)) if (!hdr.readString(lang))
return false; return false;
} }
if (flags & 0x08) { if (flags & 0x08) {
QByteArray comment; QByteArray comment;
if (!subfile.readString(comment)) if (!hdr.readString(comment))
return false; return false;
} }
if (flags & 0x04) { if (flags & 0x04) {
QByteArray createdBy; QByteArray createdBy;
if (!subfile.readString(createdBy)) if (!hdr.readString(createdBy))
return false; return false;
} }
@ -398,19 +397,19 @@ bool MapData::readHeader()
return false; return false;
} }
SubFile subfile(_file, 0, qFromBigEndian(hdrSize)); SubFile hdr(_file, MAGIC_SIZE, qFromBigEndian(hdrSize));
if (!readMapInfo(subfile, projection, debugMap)) { if (!readMapInfo(hdr, projection, debugMap)) {
_errorString = "Error reading map info"; _errorString = "Error reading map info";
return false; return false;
} }
if (!readTagInfo(subfile)) { if (!readTagInfo(hdr)) {
_errorString = "Error reading tags info"; _errorString = "Error reading tags info";
return false; return false;
} }
if (!readZoomInfo(subfile)) { if (!readZoomInfo(hdr)) {
_errorString = "Error reading zooms info"; _errorString = "Error reading zooms info";
return false; return false;
} }

View File

@ -131,9 +131,9 @@ private:
typedef RTree<VectorTile *, double, 2> TileTree; typedef RTree<VectorTile *, double, 2> TileTree;
bool readZoomInfo(SubFile &subfile); bool readZoomInfo(SubFile &hdr);
bool readTagInfo(SubFile &subfile); bool readTagInfo(SubFile &hdr);
bool readMapInfo(SubFile &subfile, QByteArray &projection, bool &debugMap); bool readMapInfo(SubFile &hdr, QByteArray &projection, bool &debugMap);
bool readHeader(); bool readHeader();
bool readSubFiles(); bool readSubFiles();
void clearTiles(); void clearTiles();