1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 11:52:08 +01:00

Improved error handling

This commit is contained in:
Martin Tůma 2017-03-27 10:31:41 +02:00
parent c1844f9557
commit 7fd30bbda3
2 changed files with 17 additions and 8 deletions

View File

@ -177,14 +177,8 @@ bool OfflineMap::getImageInfo(const QString &path)
return true;
}
bool OfflineMap::getTileInfo(const QStringList &tiles,
const QString &path)
bool OfflineMap::getTileInfo(const QStringList &tiles, const QString &path)
{
if (!_size.isValid()) {
qWarning("%s: missing total image size (IWH)", qPrintable(_name));
return false;
}
if (tiles.isEmpty()) {
qWarning("%s: empty tile set", qPrintable(_name));
return false;
@ -235,6 +229,15 @@ bool OfflineMap::mapLoaded(int res)
return true;
}
bool OfflineMap::totalSizeSet()
{
if (!_size.isValid()) {
qWarning("%s: missing total image size (IWH)", qPrintable(_name));
return false;
} else
return true;
}
OfflineMap::OfflineMap(const QString &path, QObject *parent) : Map(parent)
{
int errorLine = -2;
@ -280,11 +283,15 @@ OfflineMap::OfflineMap(const QString &path, QObject *parent) : Map(parent)
computeResolution(points);
if (_tar.isOpen()) {
if (!totalSizeSet())
return;
if (!getTileInfo(_tar.files()))
return;
} else {
QDir set(fi.absoluteFilePath() + "/" + "set");
if (set.exists()) {
if (!totalSizeSet())
return;
if (!getTileInfo(set.entryList(), set.canonicalPath()))
return;
_imgPath = QString();
@ -322,7 +329,8 @@ OfflineMap::OfflineMap(Tar &tar, const QString &path, QObject *parent)
}
if (!mapLoaded(errorLine))
return;
if (!totalSizeSet())
return;
if (!computeTransformation(points))
return;
computeResolution(points);

View File

@ -42,6 +42,7 @@ private:
int parseMapFile(QIODevice &device, QList<ReferencePoint> &points);
bool mapLoaded(int res);
bool totalSizeSet();
bool computeTransformation(const QList<ReferencePoint> &points);
bool computeResolution(QList<ReferencePoint> &points);
bool getTileInfo(const QStringList &tiles, const QString &path = QString());