1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-28 03:59:15 +02:00

Do not depend on the file extension when loading the maps

This commit is contained in:
2022-04-29 23:16:10 +02:00
parent 40febb8c0e
commit 93aadb7e74
34 changed files with 225 additions and 99 deletions

View File

@ -382,7 +382,7 @@ bool MapData::readHeader()
return true;
}
MapData::MapData(const QString &fileName) : _file(fileName)
MapData::MapData(const QString &fileName) : _file(fileName), _valid(false)
{
if (!_file.open(QFile::ReadOnly | QIODevice::Unbuffered)) {
_errorString = _file.errorString();
@ -682,19 +682,6 @@ bool MapData::readPoints(const VectorTile *tile, int zoom, QList<Point> *list)
return true;
}
bool MapData::isMapsforge(const QString &path)
{
QFile file(path);
char magic[sizeof(MAGIC) - 1];
if (!file.open(QFile::ReadOnly))
return false;
if (file.read(magic, sizeof(magic)) < (qint64)sizeof(magic))
return false;
return !memcmp(magic, MAGIC, sizeof(magic));
}
#ifndef QT_NO_DEBUG
QDebug operator<<(QDebug dbg, const Mapsforge::MapData::Tag &tag)
{

View File

@ -81,8 +81,6 @@ public:
bool isValid() const {return _valid;}
QString errorString() const {return _errorString;}
static bool isMapsforge(const QString &path);
private:
struct SubFileInfo {
quint8 base;