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

Added DEM error reporting/debug

This commit is contained in:
Martin Tůma 2019-01-07 22:07:03 +01:00
parent 760b7d8ec2
commit ea92d4d817
3 changed files with 9 additions and 4 deletions

View File

@ -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<Key, QByteArray>::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 {

View File

@ -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<Key, QByteArray> _data;
};

View File

@ -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;