From ea92d4d817df19a0d17ffefdbd7c7602a91bfbfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 7 Jan 2019 22:07:03 +0100 Subject: [PATCH] Added DEM error reporting/debug --- src/data/dem.cpp | 7 ++++++- src/data/dem.h | 4 ++-- src/data/track.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/data/dem.cpp b/src/data/dem.cpp index 218d93a0..3b538fbc 100644 --- a/src/data/dem.cpp +++ b/src/data/dem.cpp @@ -56,17 +56,22 @@ QString DEM::fileName(const Key &key) const QString basename = QString("%1%2%3%4.hgt").arg(ns) .arg(qAbs(key.lat), 2, 10, QChar('0')).arg(ew) .arg(qAbs(key.lon), 3, 10, QChar('0')); - return _dir.absoluteFilePath(basename); + return QDir(_dir).absoluteFilePath(basename); } qreal DEM::elevation(const Coordinates &c) { + if (_dir.isEmpty()) + return NAN; + Key k((int)c.lon(), (int)c.lat()); QMap::const_iterator it(_data.find(k)); if (it == _data.constEnd()) { QFile file(fileName(k)); if (!file.open(QIODevice::ReadOnly)) { + qWarning("%s: %s", qPrintable(file.fileName()), + qPrintable(file.errorString())); _data.insert(k, QByteArray()); return NAN; } else { diff --git a/src/data/dem.h b/src/data/dem.h index e5b0ba92..6cd14674 100644 --- a/src/data/dem.h +++ b/src/data/dem.h @@ -12,7 +12,7 @@ class DEM { public: DEM() {} - DEM(const QDir &dir) : _dir(dir) {} + DEM(const QString &dir) : _dir(dir) {} qreal elevation(const Coordinates &c); private: @@ -36,7 +36,7 @@ private: QString fileName(const Key &key) const; - QDir _dir; + QString _dir; QMap _data; }; diff --git a/src/data/track.h b/src/data/track.h index 12536676..63eece20 100644 --- a/src/data/track.h +++ b/src/data/track.h @@ -47,7 +47,7 @@ public: {_outlierEliminate = eliminate;} static void useReportedSpeed(bool use) {_useReportedSpeed = use;} static void useDEMElevation(bool use) {_useDEMElevation = use;} - static void setDEMDir(const QDir &dir) {_dem = DEM(dir);} + static void setDEMDir(const QString &path) {_dem = DEM(path);} private: bool discardStopPoint(int i) const;