mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +01:00
Added support for DEM data (SRTM HGT) elevation sources
This commit is contained in:
parent
8c8fedd7f7
commit
589c85b504
@ -147,7 +147,8 @@ HEADERS += src/common/config.h \
|
|||||||
src/data/nmeaparser.h \
|
src/data/nmeaparser.h \
|
||||||
src/data/oziparsers.h \
|
src/data/oziparsers.h \
|
||||||
src/data/locparser.h \
|
src/data/locparser.h \
|
||||||
src/data/slfparser.h
|
src/data/slfparser.h \
|
||||||
|
src/data/dem.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/common/coordinates.cpp \
|
src/common/coordinates.cpp \
|
||||||
src/common/rectc.cpp \
|
src/common/rectc.cpp \
|
||||||
@ -255,7 +256,8 @@ SOURCES += src/main.cpp \
|
|||||||
src/data/nmeaparser.cpp \
|
src/data/nmeaparser.cpp \
|
||||||
src/data/oziparsers.cpp \
|
src/data/oziparsers.cpp \
|
||||||
src/data/locparser.cpp \
|
src/data/locparser.cpp \
|
||||||
src/data/slfparser.cpp
|
src/data/slfparser.cpp \
|
||||||
|
src/data/dem.cpp
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_en.ts \
|
TRANSLATIONS = lang/gpxsee_en.ts \
|
||||||
lang/gpxsee_cs.ts \
|
lang/gpxsee_cs.ts \
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "map/ellipsoid.h"
|
#include "map/ellipsoid.h"
|
||||||
#include "map/gcs.h"
|
#include "map/gcs.h"
|
||||||
#include "map/pcs.h"
|
#include "map/pcs.h"
|
||||||
|
#include "data/track.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
@ -65,6 +66,8 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
loadDatums();
|
loadDatums();
|
||||||
loadPCSs();
|
loadPCSs();
|
||||||
|
|
||||||
|
Track::setDEMDir(ProgramPaths::demDir());
|
||||||
|
|
||||||
_gui = new GUI();
|
_gui = new GUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,6 +700,8 @@ void GUI::paths()
|
|||||||
+ QDir::cleanPath(ProgramPaths::poiDir(true)) + "</code></td></tr><tr><td>"
|
+ QDir::cleanPath(ProgramPaths::poiDir(true)) + "</code></td></tr><tr><td>"
|
||||||
+ tr("GCS/PCS directory:") + "</td><td><code>"
|
+ tr("GCS/PCS directory:") + "</td><td><code>"
|
||||||
+ QDir::cleanPath(ProgramPaths::csvDir(true)) + "</code></td></tr><tr><td>"
|
+ QDir::cleanPath(ProgramPaths::csvDir(true)) + "</code></td></tr><tr><td>"
|
||||||
|
+ tr("DEM directory:") + "</td><td><code>"
|
||||||
|
+ QDir::cleanPath(ProgramPaths::demDir(true)) + "</code></td></tr><tr><td>"
|
||||||
+ tr("Tile cache directory:") + "</td><td><code>"
|
+ tr("Tile cache directory:") + "</td><td><code>"
|
||||||
+ QDir::cleanPath(ProgramPaths::tilesDir()) + "</code></td></tr></table>"
|
+ QDir::cleanPath(ProgramPaths::tilesDir()) + "</code></td></tr></table>"
|
||||||
);
|
);
|
||||||
@ -911,6 +913,7 @@ void GUI::openOptions()
|
|||||||
SET_TRACK_OPTION(pauseSpeed, setPauseSpeed);
|
SET_TRACK_OPTION(pauseSpeed, setPauseSpeed);
|
||||||
SET_TRACK_OPTION(pauseInterval, setPauseInterval);
|
SET_TRACK_OPTION(pauseInterval, setPauseInterval);
|
||||||
SET_TRACK_OPTION(useReportedSpeed, useReportedSpeed);
|
SET_TRACK_OPTION(useReportedSpeed, useReportedSpeed);
|
||||||
|
SET_TRACK_OPTION(useDEMElevation, useDEMElevation);
|
||||||
|
|
||||||
if (options.poiRadius != _options.poiRadius)
|
if (options.poiRadius != _options.poiRadius)
|
||||||
_poi->setRadius(options.poiRadius);
|
_poi->setRadius(options.poiRadius);
|
||||||
@ -1754,6 +1757,8 @@ void GUI::writeSettings()
|
|||||||
settings.setValue(PAUSE_INTERVAL_SETTING, _options.pauseInterval);
|
settings.setValue(PAUSE_INTERVAL_SETTING, _options.pauseInterval);
|
||||||
if (_options.useReportedSpeed != USE_REPORTED_SPEED_DEFAULT)
|
if (_options.useReportedSpeed != USE_REPORTED_SPEED_DEFAULT)
|
||||||
settings.setValue(USE_REPORTED_SPEED_SETTING, _options.useReportedSpeed);
|
settings.setValue(USE_REPORTED_SPEED_SETTING, _options.useReportedSpeed);
|
||||||
|
if (_options.useDEMElevation != USE_DEM_ELEVATION_DEFAULT)
|
||||||
|
settings.setValue(USE_DEM_ELEVATION_SETTING, _options.useDEMElevation);
|
||||||
if (_options.poiRadius != POI_RADIUS_DEFAULT)
|
if (_options.poiRadius != POI_RADIUS_DEFAULT)
|
||||||
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
settings.setValue(POI_RADIUS_SETTING, _options.poiRadius);
|
||||||
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
if (_options.useOpenGL != USE_OPENGL_DEFAULT)
|
||||||
@ -1992,6 +1997,8 @@ void GUI::readSettings()
|
|||||||
PAUSE_SPEED_DEFAULT).toFloat();
|
PAUSE_SPEED_DEFAULT).toFloat();
|
||||||
_options.useReportedSpeed = settings.value(USE_REPORTED_SPEED_SETTING,
|
_options.useReportedSpeed = settings.value(USE_REPORTED_SPEED_SETTING,
|
||||||
USE_REPORTED_SPEED_DEFAULT).toBool();
|
USE_REPORTED_SPEED_DEFAULT).toBool();
|
||||||
|
_options.useDEMElevation = settings.value(USE_DEM_ELEVATION_SETTING,
|
||||||
|
USE_DEM_ELEVATION_DEFAULT).toBool();
|
||||||
_options.pauseInterval = settings.value(PAUSE_INTERVAL_SETTING,
|
_options.pauseInterval = settings.value(PAUSE_INTERVAL_SETTING,
|
||||||
PAUSE_INTERVAL_DEFAULT).toInt();
|
PAUSE_INTERVAL_DEFAULT).toInt();
|
||||||
_options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT)
|
_options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT)
|
||||||
@ -2070,6 +2077,7 @@ void GUI::readSettings()
|
|||||||
Track::setPauseSpeed(_options.pauseSpeed);
|
Track::setPauseSpeed(_options.pauseSpeed);
|
||||||
Track::setPauseInterval(_options.pauseInterval);
|
Track::setPauseInterval(_options.pauseInterval);
|
||||||
Track::useReportedSpeed(_options.useReportedSpeed);
|
Track::useReportedSpeed(_options.useReportedSpeed);
|
||||||
|
Track::useDEMElevation(_options.useDEMElevation);
|
||||||
|
|
||||||
_poi->setRadius(_options.poiRadius);
|
_poi->setRadius(_options.poiRadius);
|
||||||
|
|
||||||
|
@ -345,25 +345,59 @@ QWidget *OptionsDialog::createDataPage()
|
|||||||
pauseTab->setLayout(pauseLayout);
|
pauseTab->setLayout(pauseLayout);
|
||||||
|
|
||||||
|
|
||||||
_computed = new QRadioButton(tr("Computed from distance/time"));
|
_computedSpeed = new QRadioButton(tr("Computed from distance/time"));
|
||||||
_reported = new QRadioButton(tr("Recorded by device"));
|
_reportedSpeed = new QRadioButton(tr("Recorded by device"));
|
||||||
if (_options->useReportedSpeed)
|
if (_options->useReportedSpeed)
|
||||||
_reported->setChecked(true);
|
_reportedSpeed->setChecked(true);
|
||||||
else
|
else
|
||||||
_computed->setChecked(true);
|
_computedSpeed->setChecked(true);
|
||||||
|
|
||||||
|
QFormLayout *speedLayout = new QFormLayout();
|
||||||
|
speedLayout->addWidget(_computedSpeed);
|
||||||
|
speedLayout->addWidget(_reportedSpeed);
|
||||||
|
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
QGroupBox *speedBox = new QGroupBox(tr("Speed"));
|
||||||
|
speedBox->setLayout(speedLayout);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
|
_gpsElevation = new QRadioButton(tr("GPS data"));
|
||||||
|
_demElevation = new QRadioButton(tr("DEM data"));
|
||||||
|
if (_options->useDEMElevation)
|
||||||
|
_demElevation->setChecked(true);
|
||||||
|
else
|
||||||
|
_gpsElevation->setChecked(true);
|
||||||
|
|
||||||
|
QFormLayout *elevationLayout = new QFormLayout();
|
||||||
|
elevationLayout->addWidget(_gpsElevation);
|
||||||
|
elevationLayout->addWidget(_demElevation);
|
||||||
|
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
QGroupBox *elevationBox = new QGroupBox(tr("Elevation"));
|
||||||
|
elevationBox->setLayout(elevationLayout);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
QFormLayout *sourceLayout = new QFormLayout();
|
|
||||||
sourceLayout->addWidget(_computed);
|
|
||||||
sourceLayout->addWidget(_reported);
|
|
||||||
|
|
||||||
QWidget *sourceTab = new QWidget();
|
QWidget *sourceTab = new QWidget();
|
||||||
sourceTab->setLayout(sourceLayout);
|
QVBoxLayout *sourceTabLayout = new QVBoxLayout();
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
sourceTabLayout->addWidget(new QLabel(tr("Speed:")));
|
||||||
|
sourceTabLayout->addLayout(speedLayout);
|
||||||
|
sourceTabLayout->addWidget(line());
|
||||||
|
sourceTabLayout->addWidget(new QLabel(tr("Elevation:")));
|
||||||
|
sourceTabLayout->addLayout(elevationLayout);
|
||||||
|
#else // Q_OS_MAC
|
||||||
|
sourceTabLayout->addWidget(speedBox);
|
||||||
|
sourceTabLayout->addWidget(elevationBox);
|
||||||
|
#endif // Q_OS_MAC
|
||||||
|
sourceTabLayout->addStretch();
|
||||||
|
sourceTab->setLayout(sourceTabLayout);
|
||||||
|
|
||||||
|
|
||||||
QTabWidget *filterPage = new QTabWidget();
|
QTabWidget *filterPage = new QTabWidget();
|
||||||
filterPage->addTab(filterTab, tr("Filtering"));
|
filterPage->addTab(filterTab, tr("Filtering"));
|
||||||
|
filterPage->addTab(sourceTab, tr("Sources"));
|
||||||
filterPage->addTab(pauseTab, tr("Pause detection"));
|
filterPage->addTab(pauseTab, tr("Pause detection"));
|
||||||
filterPage->addTab(sourceTab, tr("Speed"));
|
|
||||||
|
|
||||||
return filterPage;
|
return filterPage;
|
||||||
}
|
}
|
||||||
@ -603,7 +637,8 @@ void OptionsDialog::accept()
|
|||||||
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
|
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
|
||||||
_options->pauseSpeed = pauseSpeed;
|
_options->pauseSpeed = pauseSpeed;
|
||||||
_options->pauseInterval = _pauseInterval->value();
|
_options->pauseInterval = _pauseInterval->value();
|
||||||
_options->useReportedSpeed = _reported->isChecked();
|
_options->useReportedSpeed = _reportedSpeed->isChecked();
|
||||||
|
_options->useDEMElevation = _demElevation->isChecked();
|
||||||
|
|
||||||
qreal poiRadius = (_options->units == Imperial)
|
qreal poiRadius = (_options->units == Imperial)
|
||||||
? _poiRadius->value() * MIINM : (_options->units == Nautical)
|
? _poiRadius->value() * MIINM : (_options->units == Nautical)
|
||||||
|
@ -48,6 +48,7 @@ struct Options {
|
|||||||
qreal pauseSpeed;
|
qreal pauseSpeed;
|
||||||
int pauseInterval;
|
int pauseInterval;
|
||||||
bool useReportedSpeed;
|
bool useReportedSpeed;
|
||||||
|
bool useDEMElevation;
|
||||||
// POI
|
// POI
|
||||||
int poiRadius;
|
int poiRadius;
|
||||||
// System
|
// System
|
||||||
@ -122,8 +123,10 @@ private:
|
|||||||
QCheckBox *_outlierEliminate;
|
QCheckBox *_outlierEliminate;
|
||||||
QDoubleSpinBox *_pauseSpeed;
|
QDoubleSpinBox *_pauseSpeed;
|
||||||
QSpinBox *_pauseInterval;
|
QSpinBox *_pauseInterval;
|
||||||
QRadioButton *_computed;
|
QRadioButton *_computedSpeed;
|
||||||
QRadioButton *_reported;
|
QRadioButton *_reportedSpeed;
|
||||||
|
QRadioButton *_gpsElevation;
|
||||||
|
QRadioButton *_demElevation;
|
||||||
// POI
|
// POI
|
||||||
QDoubleSpinBox *_poiRadius;
|
QDoubleSpinBox *_poiRadius;
|
||||||
// System
|
// System
|
||||||
|
@ -126,6 +126,8 @@
|
|||||||
#define PAUSE_INTERVAL_DEFAULT 10 /* s */
|
#define PAUSE_INTERVAL_DEFAULT 10 /* s */
|
||||||
#define USE_REPORTED_SPEED_SETTING "useReportedSpeed"
|
#define USE_REPORTED_SPEED_SETTING "useReportedSpeed"
|
||||||
#define USE_REPORTED_SPEED_DEFAULT false
|
#define USE_REPORTED_SPEED_DEFAULT false
|
||||||
|
#define USE_DEM_ELEVATION_SETTING "useReportedSpeed"
|
||||||
|
#define USE_DEM_ELEVATION_DEFAULT false
|
||||||
#define POI_RADIUS_SETTING "poiRadius"
|
#define POI_RADIUS_SETTING "poiRadius"
|
||||||
#define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM)
|
#define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM)
|
||||||
#define USE_OPENGL_SETTING "useOpenGL"
|
#define USE_OPENGL_SETTING "useOpenGL"
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define MAP_DIR "maps"
|
#define MAP_DIR "maps"
|
||||||
#define POI_DIR "POI"
|
#define POI_DIR "POI"
|
||||||
#define CSV_DIR "csv"
|
#define CSV_DIR "csv"
|
||||||
|
#define DEM_DIR "DEM"
|
||||||
#define TILES_DIR "tiles"
|
#define TILES_DIR "tiles"
|
||||||
#define TRANSLATIONS_DIR "translations"
|
#define TRANSLATIONS_DIR "translations"
|
||||||
#define ELLIPSOID_FILE "ellipsoids.csv"
|
#define ELLIPSOID_FILE "ellipsoids.csv"
|
||||||
@ -73,6 +74,11 @@ QString ProgramPaths::csvDir(bool writable)
|
|||||||
return dir(CSV_DIR, writable);
|
return dir(CSV_DIR, writable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::demDir(bool writable)
|
||||||
|
{
|
||||||
|
return dir(DEM_DIR, writable);
|
||||||
|
}
|
||||||
|
|
||||||
QString ProgramPaths::tilesDir()
|
QString ProgramPaths::tilesDir()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
@ -141,6 +147,16 @@ QString ProgramPaths::csvDir(bool writable)
|
|||||||
CSV_DIR, QStandardPaths::LocateDirectory);
|
CSV_DIR, QStandardPaths::LocateDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::demDir(bool writable)
|
||||||
|
{
|
||||||
|
if (writable)
|
||||||
|
return QDir(QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::AppDataLocation)).filePath(DEM_DIR);
|
||||||
|
else
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
DEM_DIR, QStandardPaths::LocateDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
QString ProgramPaths::tilesDir()
|
QString ProgramPaths::tilesDir()
|
||||||
{
|
{
|
||||||
return QDir(QStandardPaths::writableLocation(
|
return QDir(QStandardPaths::writableLocation(
|
||||||
|
@ -8,6 +8,7 @@ namespace ProgramPaths
|
|||||||
QString mapDir(bool writable = false);
|
QString mapDir(bool writable = false);
|
||||||
QString poiDir(bool writable = false);
|
QString poiDir(bool writable = false);
|
||||||
QString csvDir(bool writable = false);
|
QString csvDir(bool writable = false);
|
||||||
|
QString demDir(bool writable = false);
|
||||||
QString tilesDir();
|
QString tilesDir();
|
||||||
QString translationsDir();
|
QString translationsDir();
|
||||||
QString ellipsoidsFile();
|
QString ellipsoidsFile();
|
||||||
|
58
src/data/dem.cpp
Normal file
58
src/data/dem.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#include <QtEndian>
|
||||||
|
#include "common/coordinates.h"
|
||||||
|
#include "dem.h"
|
||||||
|
|
||||||
|
#define SRTM3_SAMPLES 1201
|
||||||
|
#define SRTM1_SAMPLES 3601
|
||||||
|
|
||||||
|
#define SRTM_SIZE(samples) \
|
||||||
|
((samples) * (samples) * 2)
|
||||||
|
|
||||||
|
|
||||||
|
static qreal height(const Coordinates &c, const QByteArray data)
|
||||||
|
{
|
||||||
|
int samples;
|
||||||
|
|
||||||
|
if (data.size() == SRTM_SIZE(SRTM3_SAMPLES))
|
||||||
|
samples = SRTM3_SAMPLES;
|
||||||
|
else if (data.size() == SRTM_SIZE(SRTM1_SAMPLES))
|
||||||
|
samples = SRTM1_SAMPLES;
|
||||||
|
else
|
||||||
|
return NAN;
|
||||||
|
|
||||||
|
int lat = int(qRound((c.lat() - int(c.lat())) * (samples - 1)));
|
||||||
|
int lon = int(qRound((c.lon() - int(c.lon())) * (samples - 1)));
|
||||||
|
|
||||||
|
int pos = ((samples - 1 - lat) * samples + lon) * 2;
|
||||||
|
qint16 val = qFromBigEndian(*((const qint16*)(data.constData() + pos)));
|
||||||
|
|
||||||
|
return (val == -32768) ? NAN : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DEM::fileName(const Key &key) const
|
||||||
|
{
|
||||||
|
const char ns = (key.lat >= 0) ? 'N' : 'S';
|
||||||
|
const char ew = (key.lon >= 0) ? 'E' : 'W';
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal DEM::elevation(const Coordinates &c)
|
||||||
|
{
|
||||||
|
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))
|
||||||
|
return NAN;
|
||||||
|
else {
|
||||||
|
it = _data.insert(k, file.readAll());
|
||||||
|
return height(c, *it);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
return height(c, *it);
|
||||||
|
}
|
43
src/data/dem.h
Normal file
43
src/data/dem.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#ifndef DEM_H
|
||||||
|
#define DEM_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
class QDir;
|
||||||
|
class Coordinates;
|
||||||
|
|
||||||
|
class DEM
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DEM() {}
|
||||||
|
DEM(const QDir &dir) : _dir(dir) {}
|
||||||
|
qreal elevation(const Coordinates &c);
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Key {
|
||||||
|
int lon;
|
||||||
|
int lat;
|
||||||
|
|
||||||
|
Key(int lon, int lat) : lon(lon), lat(lat) {}
|
||||||
|
|
||||||
|
bool operator<(const Key &other) const
|
||||||
|
{
|
||||||
|
if (lon < other.lon)
|
||||||
|
return true;
|
||||||
|
else if (lon > other.lon)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return (lat < other.lat);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
QString fileName(const Key &key) const;
|
||||||
|
|
||||||
|
QDir _dir;
|
||||||
|
QMap<Key, QByteArray> _data;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEM_H
|
@ -1,5 +1,7 @@
|
|||||||
|
#include "dem.h"
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
|
|
||||||
|
|
||||||
int Track::_elevationWindow = 3;
|
int Track::_elevationWindow = 3;
|
||||||
int Track::_speedWindow = 5;
|
int Track::_speedWindow = 5;
|
||||||
int Track::_heartRateWindow = 3;
|
int Track::_heartRateWindow = 3;
|
||||||
@ -11,6 +13,9 @@ int Track::_pauseInterval = 10;
|
|||||||
|
|
||||||
bool Track::_outlierEliminate = true;
|
bool Track::_outlierEliminate = true;
|
||||||
bool Track::_useReportedSpeed = false;
|
bool Track::_useReportedSpeed = false;
|
||||||
|
bool Track::_useDEMElevation = false;
|
||||||
|
|
||||||
|
DEM Track::_dem;
|
||||||
|
|
||||||
|
|
||||||
static qreal median(QVector<qreal> &v)
|
static qreal median(QVector<qreal> &v)
|
||||||
@ -147,10 +152,19 @@ Graph Track::elevation() const
|
|||||||
{
|
{
|
||||||
Graph raw;
|
Graph raw;
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++)
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
if (_data.at(i).hasElevation() && !_outliers.contains(i))
|
if (_outliers.contains(i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (_data.at(i).hasElevation() && !_useDEMElevation)
|
||||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||||
_data.at(i).elevation()));
|
_data.at(i).elevation()));
|
||||||
|
else {
|
||||||
|
qreal elevation = _dem.elevation(_data.at(i).coordinates());
|
||||||
|
if (!std::isnan(elevation))
|
||||||
|
raw.append(GraphPoint(_distance.at(i), _time.at(i), elevation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return filter(raw, _elevationWindow);
|
return filter(raw, _elevationWindow);
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QDir>
|
||||||
#include "trackdata.h"
|
#include "trackdata.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
#include "dem.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
|
|
||||||
@ -44,6 +46,8 @@ public:
|
|||||||
static void setOutlierElimination(bool eliminate)
|
static void setOutlierElimination(bool eliminate)
|
||||||
{_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 setDEMDir(const QDir &dir) {_dem = DEM(dir);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool discardStopPoint(int i) const;
|
bool discardStopPoint(int i) const;
|
||||||
@ -68,6 +72,8 @@ private:
|
|||||||
static qreal _pauseSpeed;
|
static qreal _pauseSpeed;
|
||||||
static int _pauseInterval;
|
static int _pauseInterval;
|
||||||
static bool _useReportedSpeed;
|
static bool _useReportedSpeed;
|
||||||
|
static bool _useDEMElevation;
|
||||||
|
static DEM _dem;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACK_H
|
#endif // TRACK_H
|
||||||
|
Loading…
Reference in New Issue
Block a user