From 75bd388be0bf6265f9130c67c78675e170fc5f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 13 Apr 2017 20:00:27 +0200 Subject: [PATCH] Try to load maps with incorrect (windows absolute) image paths. --- src/offlinemap.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/offlinemap.cpp b/src/offlinemap.cpp index e7d623d3..eecf0c0f 100644 --- a/src/offlinemap.cpp +++ b/src/offlinemap.cpp @@ -154,14 +154,13 @@ bool OfflineMap::createProjection(const QString &datum, const QString &projection, const ProjectionSetup &setup, QList &points) { - Ellipsoid::Name ellipsoid = Ellipsoid::WGS84; - if (points.count() < 2) { qWarning("%s: insufficient number of reference points", qPrintable(_name)); return false; } + Ellipsoid::Name ellipsoid = Ellipsoid::WGS84; for (size_t i = 0; i < ARRAY_SIZE(datums); i++) { if (datum.startsWith(datums[i].name)) { ellipsoid = datums[i].ellipsoid; @@ -284,8 +283,25 @@ bool OfflineMap::computeResolution(QList &points) bool OfflineMap::getImageInfo(const QString &path) { QFileInfo ii(_imgPath); + if (ii.isRelative()) - _imgPath = path + "/" + _imgPath; + ii.setFile(path + "/" + _imgPath); + + if (!ii.exists()) { + int last = _imgPath.lastIndexOf('\\'); + if (last >= 0 && last < _imgPath.length() - 1) { + QStringRef fn(&_imgPath, last + 1, _imgPath.length() - last - 1); + ii.setFile(path + "/" + fn.toString()); + } + } + + if (ii.exists()) + _imgPath = ii.absoluteFilePath(); + else { + qWarning("%s: %s: No such image file", qPrintable(_name), + qPrintable(_imgPath)); + return false; + } QImageReader img(_imgPath); _size = img.size();