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

Properly handle basemap entries with './xxx' paths

This commit is contained in:
Martin Tůma 2020-02-10 19:40:39 +01:00
parent e86f89308b
commit 2d5e11f001

View File

@ -77,15 +77,13 @@ bool GMAP::readXML(const QString &path, QString &dataDir, QString &typFile,
bool GMAP::loadTile(const QDir &dir, quint16 &id)
{
VectorTile *tile = new VectorTile();
SubFile *file;
QFileInfoList ml = dir.entryInfoList(QDir::Files);
for (int i = 0; i < ml.size(); i++) {
const QFileInfo &fi = ml.at(i);
SubFile::Type type = tileType(fi.suffix());
if (VectorTile::isTileFile(type)) {
SubFile *file = tile->addFile(fi.absoluteFilePath(), type);
if ((file = tile->addFile(fi.absoluteFilePath(), tileType(fi.suffix()))))
file->setId(id++);
}
}
if (!tile->init()) {
@ -108,8 +106,8 @@ bool GMAP::loadTile(const QDir &dir, quint16 &id)
GMAP::GMAP(const QString &fileName) : _fileName(fileName)
{
QString dataDirPath, typFile, baseMap;
if (!readXML(fileName, dataDirPath, typFile, baseMap))
QString dataDirPath, typFilePath, baseMapPath;
if (!readXML(fileName, dataDirPath, typFilePath, baseMapPath))
return;
QDir baseDir(QFileInfo(fileName).absoluteDir());
@ -121,14 +119,15 @@ GMAP::GMAP(const QString &fileName) : _fileName(fileName)
QFileInfoList ml = dataDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
quint16 id = 0;
QFileInfo baseMap(baseMapPath);
for (int i = 0; i < ml.size(); i++) {
const QFileInfo &fi = ml.at(i);
if (fi.isDir() && fi.baseName() != baseMap)
if (fi.isDir() && fi.baseName() != baseMap.baseName())
loadTile(QDir(fi.absoluteFilePath()), id);
}
if (baseDir.exists(typFile))
_typ = new SubFile(baseDir.filePath(typFile));
if (baseDir.exists(typFilePath))
_typ = new SubFile(baseDir.filePath(typFilePath));
if (!_tileTree.Count())
_errorString = "No usable map tile found";