mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Added DEM error reporting/debug
This commit is contained in:
parent
760b7d8ec2
commit
ea92d4d817
@ -56,17 +56,22 @@ QString DEM::fileName(const Key &key) const
|
|||||||
QString basename = QString("%1%2%3%4.hgt").arg(ns)
|
QString basename = QString("%1%2%3%4.hgt").arg(ns)
|
||||||
.arg(qAbs(key.lat), 2, 10, QChar('0')).arg(ew)
|
.arg(qAbs(key.lat), 2, 10, QChar('0')).arg(ew)
|
||||||
.arg(qAbs(key.lon), 3, 10, QChar('0'));
|
.arg(qAbs(key.lon), 3, 10, QChar('0'));
|
||||||
return _dir.absoluteFilePath(basename);
|
return QDir(_dir).absoluteFilePath(basename);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal DEM::elevation(const Coordinates &c)
|
qreal DEM::elevation(const Coordinates &c)
|
||||||
{
|
{
|
||||||
|
if (_dir.isEmpty())
|
||||||
|
return NAN;
|
||||||
|
|
||||||
Key k((int)c.lon(), (int)c.lat());
|
Key k((int)c.lon(), (int)c.lat());
|
||||||
|
|
||||||
QMap<Key, QByteArray>::const_iterator it(_data.find(k));
|
QMap<Key, QByteArray>::const_iterator it(_data.find(k));
|
||||||
if (it == _data.constEnd()) {
|
if (it == _data.constEnd()) {
|
||||||
QFile file(fileName(k));
|
QFile file(fileName(k));
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
|
qWarning("%s: %s", qPrintable(file.fileName()),
|
||||||
|
qPrintable(file.errorString()));
|
||||||
_data.insert(k, QByteArray());
|
_data.insert(k, QByteArray());
|
||||||
return NAN;
|
return NAN;
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,7 +12,7 @@ class DEM
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DEM() {}
|
DEM() {}
|
||||||
DEM(const QDir &dir) : _dir(dir) {}
|
DEM(const QString &dir) : _dir(dir) {}
|
||||||
qreal elevation(const Coordinates &c);
|
qreal elevation(const Coordinates &c);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -36,7 +36,7 @@ private:
|
|||||||
|
|
||||||
QString fileName(const Key &key) const;
|
QString fileName(const Key &key) const;
|
||||||
|
|
||||||
QDir _dir;
|
QString _dir;
|
||||||
QMap<Key, QByteArray> _data;
|
QMap<Key, QByteArray> _data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
{_outlierEliminate = eliminate;}
|
{_outlierEliminate = eliminate;}
|
||||||
static void useReportedSpeed(bool use) {_useReportedSpeed = use;}
|
static void useReportedSpeed(bool use) {_useReportedSpeed = use;}
|
||||||
static void useDEMElevation(bool use) {_useDEMElevation = 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:
|
private:
|
||||||
bool discardStopPoint(int i) const;
|
bool discardStopPoint(int i) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user