diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index 6159bf79..f47f4642 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -860,6 +860,7 @@ void GUI::openOptions() SET_TRACK_OPTION(outlierEliminate, setOutlierElimination); SET_TRACK_OPTION(pauseSpeed, setPauseSpeed); SET_TRACK_OPTION(pauseInterval, setPauseInterval); + SET_TRACK_OPTION(useReportedSpeed, useReportedSpeed); if (options.poiRadius != _options.poiRadius) _poi->setRadius(options.poiRadius); @@ -1631,6 +1632,8 @@ void GUI::writeSettings() settings.setValue(PAUSE_SPEED_SETTING, _options.pauseSpeed); if (_options.pauseInterval != PAUSE_INTERVAL_DEFAULT) settings.setValue(PAUSE_INTERVAL_SETTING, _options.pauseInterval); + if (_options.useReportedSpeed != USE_REPORTED_SPEED_DEFAULT) + settings.setValue(USE_REPORTED_SPEED_SETTING, _options.useReportedSpeed); if (_options.poiRadius != POI_RADIUS_DEFAULT) settings.setValue(POI_RADIUS_SETTING, _options.poiRadius); if (_options.useOpenGL != USE_OPENGL_DEFAULT) @@ -1859,6 +1862,8 @@ void GUI::readSettings() OUTLIER_ELIMINATE_DEFAULT).toBool(); _options.pauseSpeed = settings.value(PAUSE_SPEED_SETTING, PAUSE_SPEED_DEFAULT).toFloat(); + _options.useReportedSpeed = settings.value(USE_REPORTED_SPEED_SETTING, + USE_REPORTED_SPEED_DEFAULT).toBool(); _options.pauseInterval = settings.value(PAUSE_INTERVAL_SETTING, PAUSE_INTERVAL_DEFAULT).toInt(); _options.poiRadius = settings.value(POI_RADIUS_SETTING, POI_RADIUS_DEFAULT) @@ -1924,6 +1929,7 @@ void GUI::readSettings() Track::setOutlierElimination(_options.outlierEliminate); Track::setPauseSpeed(_options.pauseSpeed); Track::setPauseInterval(_options.pauseInterval); + Track::useReportedSpeed(_options.useReportedSpeed); _poi->setRadius(_options.poiRadius); diff --git a/src/GUI/optionsdialog.cpp b/src/GUI/optionsdialog.cpp index f233d8bf..b80f9334 100644 --- a/src/GUI/optionsdialog.cpp +++ b/src/GUI/optionsdialog.cpp @@ -311,9 +311,25 @@ QWidget *OptionsDialog::createDataPage() pauseTab->setLayout(pauseLayout); + _computed = new QRadioButton(tr("Computed from distance/time")); + _reported = new QRadioButton(tr("Reported by device")); + if (_options->useReportedSpeed) + _reported->setChecked(true); + else + _computed->setChecked(true); + + QFormLayout *sourceLayout = new QFormLayout(); + sourceLayout->addWidget(_computed); + sourceLayout->addWidget(_reported); + + QWidget *sourceTab = new QWidget(); + sourceTab->setLayout(sourceLayout); + + QTabWidget *filterPage = new QTabWidget(); filterPage->addTab(filterTab, tr("Filtering")); filterPage->addTab(pauseTab, tr("Pause detection")); + filterPage->addTab(sourceTab, tr("Speed")); return filterPage; } @@ -543,6 +559,7 @@ void OptionsDialog::accept() if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01) _options->pauseSpeed = pauseSpeed; _options->pauseInterval = _pauseInterval->value(); + _options->useReportedSpeed = _reported->isChecked(); qreal poiRadius = (_options->units == Imperial) ? _poiRadius->value() * MIINM : (_options->units == Nautical) diff --git a/src/GUI/optionsdialog.h b/src/GUI/optionsdialog.h index 003e9e8a..ad9b3d3c 100644 --- a/src/GUI/optionsdialog.h +++ b/src/GUI/optionsdialog.h @@ -43,6 +43,7 @@ struct Options { bool outlierEliminate; qreal pauseSpeed; int pauseInterval; + bool useReportedSpeed; // POI int poiRadius; // System @@ -110,6 +111,8 @@ private: QCheckBox *_outlierEliminate; QDoubleSpinBox *_pauseSpeed; QSpinBox *_pauseInterval; + QRadioButton *_computed; + QRadioButton *_reported; // POI QDoubleSpinBox *_poiRadius; // System diff --git a/src/GUI/settings.h b/src/GUI/settings.h index 4da33de4..77462a8e 100644 --- a/src/GUI/settings.h +++ b/src/GUI/settings.h @@ -124,6 +124,8 @@ #define PAUSE_SPEED_DEFAULT 0.5 /* m/s */ #define PAUSE_INTERVAL_SETTING "pauseInterval" #define PAUSE_INTERVAL_DEFAULT 10 /* s */ +#define USE_REPORTED_SPEED_SETTING "useReportedSpeed" +#define USE_REPORTED_SPEED_DEFAULT false #define POI_RADIUS_SETTING "poiRadius" #define POI_RADIUS_DEFAULT (int)(IMPERIAL_UNITS() ? MIINM : KMINM) #define USE_OPENGL_SETTING "useOpenGL" diff --git a/src/data/track.cpp b/src/data/track.cpp index a06ea742..d5f076ab 100644 --- a/src/data/track.cpp +++ b/src/data/track.cpp @@ -10,6 +10,7 @@ qreal Track::_pauseSpeed = 0.5; int Track::_pauseInterval = 10; bool Track::_outlierEliminate = true; +bool Track::_useReportedSpeed = false; static qreal median(QVector &v) @@ -91,12 +92,11 @@ Track::Track(const TrackData &data) : _data(data) if (dt < 1e-3) { _speed.append(_speed.at(i-1)); acceleration.append(acceleration.at(i-1)); - continue; + } else { + _speed.append(ds / dt); + qreal dv = _speed.at(i) - _speed.at(i-1); + acceleration.append(dv / dt); } - _speed.append(ds / dt); - - qreal dv = _speed.at(i) - _speed.at(i-1); - acceleration.append(dv / dt); } _pause = 0; @@ -166,7 +166,8 @@ Graph Track::speed() const || _data.at(i).hasSpeed())) { v = 0; stop.append(raw.size()); - } else if (_data.at(i).hasSpeed() && !_outliers.contains(i)) + } else if (_useReportedSpeed && _data.at(i).hasSpeed() + && !_outliers.contains(i)) v = _data.at(i).speed(); else if (!std::isnan(_speed.at(i)) && !_outliers.contains(i)) v = _speed.at(i); diff --git a/src/data/track.h b/src/data/track.h index 891c151a..b4c0222e 100644 --- a/src/data/track.h +++ b/src/data/track.h @@ -42,6 +42,7 @@ public: static void setPauseInterval(int interval) {_pauseInterval = interval;} static void setOutlierElimination(bool eliminate) {_outlierEliminate = eliminate;} + static void useReportedSpeed(bool use) {_useReportedSpeed = use;} private: bool discardStopPoint(int i) const; @@ -58,15 +59,14 @@ private: qreal _pause; static bool _outlierEliminate; - static int _elevationWindow; static int _speedWindow; static int _heartRateWindow; static int _cadenceWindow; static int _powerWindow; - static qreal _pauseSpeed; static int _pauseInterval; + static bool _useReportedSpeed; }; #endif // TRACK_H