1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Fixed the "DEM values not used in route points" issue

This commit is contained in:
Martin Tůma 2019-08-29 20:15:03 +02:00
parent 37e07accd4
commit f9c593e6d1
7 changed files with 33 additions and 45 deletions

View File

@ -24,7 +24,7 @@ QString RouteItem::toolTip(Units units) const
RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent) RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
: PathItem(route.path(), map, parent) : PathItem(route.path(), map, parent)
{ {
const QVector<Waypoint> &waypoints = route.waypoints(); const RouteData &waypoints = route.data();
_waypoints.resize(waypoints.size()); _waypoints.resize(waypoints.size());
for (int i = 0; i < waypoints.size(); i++) for (int i = 0; i < waypoints.size(); i++)

View File

@ -71,13 +71,35 @@ static QHash<QString, Parser*> parsers()
QHash<QString, Parser*> Data::_parsers = parsers(); QHash<QString, Parser*> Data::_parsers = parsers();
bool Data::_useDEM = false; bool Data::_useDEM = false;
void Data::processData(const QList<TrackData> &trackData, void Data::processData(QList<TrackData> &trackData, QList<RouteData> &routeData)
const QList<RouteData> &routeData)
{ {
for (int i = 0; i < trackData.count(); i++) for (int i = 0; i < trackData.count(); i++) {
TrackData &track = trackData[i];
for (int j = 0; j < track.size(); j++) {
SegmentData &segment = track[j];
for (int k = 0; k < segment.size(); k++) {
Trackpoint &t = segment[k];
if (!t.hasElevation() || _useDEM) {
qreal elevation = DEM::elevation(t.coordinates());
if (!std::isnan(elevation))
t.setElevation(elevation);
}
}
}
_tracks.append(Track(trackData.at(i))); _tracks.append(Track(trackData.at(i)));
for (int i = 0; i < routeData.count(); i++) }
for (int i = 0; i < routeData.count(); i++) {
RouteData &route = routeData[i];
for (int j = 0; j < route.size(); j++) {
Waypoint &w = route[j];
if (!w.hasElevation() || _useDEM) {
qreal elevation = DEM::elevation(w.coordinates());
if (!std::isnan(elevation))
w.setElevation(elevation);
}
}
_routes.append(Route(routeData.at(i))); _routes.append(Route(routeData.at(i)));
}
for (int i = 0; i < _waypoints.size(); i++) { for (int i = 0; i < _waypoints.size(); i++) {
if (!_waypoints.at(i).hasElevation() || _useDEM) { if (!_waypoints.at(i).hasElevation() || _useDEM) {
qreal elevation = DEM::elevation(_waypoints.at(i).coordinates()); qreal elevation = DEM::elevation(_waypoints.at(i).coordinates());
@ -181,6 +203,4 @@ QStringList Data::filter()
void Data::useDEM(bool use) void Data::useDEM(bool use)
{ {
_useDEM = use; _useDEM = use;
Route::useDEM(use);
Track::useDEM(use);
} }

View File

@ -31,8 +31,7 @@ public:
static void useDEM(bool use); static void useDEM(bool use);
private: private:
void processData(const QList<TrackData> &trackData, void processData(QList<TrackData> &trackData, QList<RouteData> &routeData);
const QList<RouteData> &routeData);
bool _valid; bool _valid;
QString _errorString; QString _errorString;

View File

@ -2,8 +2,6 @@
#include "route.h" #include "route.h"
bool Route::_useDEM = false;
Route::Route(const RouteData &data) : _data(data) Route::Route(const RouteData &data) : _data(data)
{ {
qreal dist = 0; qreal dist = 0;
@ -34,19 +32,8 @@ Graph Route::elevation() const
graph.append(GraphSegment()); graph.append(GraphSegment());
GraphSegment &gs = graph.last(); GraphSegment &gs = graph.last();
for (int i = 0; i < _data.size(); i++) { for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasElevation() && !_useDEM) gs.append(GraphPoint(_distance.at(i), NAN, _data.at(i).elevation()));
gs.append(GraphPoint(_distance.at(i), NAN,
_data.at(i).elevation()));
else {
qreal elevation = DEM::elevation(_data.at(i).coordinates());
if (!std::isnan(elevation))
gs.append(GraphPoint(_distance.at(i), NAN, elevation));
else if (_data.at(i).hasElevation())
gs.append(GraphPoint(_distance.at(i), NAN,
_data.at(i).elevation()));
}
}
return graph; return graph;
} }

View File

@ -13,7 +13,7 @@ public:
Path path() const; Path path() const;
const QVector<Waypoint> &waypoints() const {return _data;} const RouteData &data() const {return _data;}
Graph elevation() const; Graph elevation() const;
@ -24,13 +24,9 @@ public:
bool isValid() const {return _data.size() >= 2;} bool isValid() const {return _data.size() >= 2;}
static void useDEM(bool use) {_useDEM = use;}
private: private:
RouteData _data; RouteData _data;
QVector<qreal> _distance; QVector<qreal> _distance;
static bool _useDEM;
}; };
#endif // ROUTE_H #endif // ROUTE_H

View File

@ -13,7 +13,6 @@ int Track::_pauseInterval = 10;
bool Track::_outlierEliminate = true; bool Track::_outlierEliminate = true;
bool Track::_useReportedSpeed = false; bool Track::_useReportedSpeed = false;
bool Track::_useDEM = false;
static qreal median(QVector<qreal> &v) static qreal median(QVector<qreal> &v)
@ -180,19 +179,8 @@ Graph Track::elevation() const
for (int j = 0; j < sd.size(); j++) { for (int j = 0; j < sd.size(); j++) {
if (seg.outliers.contains(j)) if (seg.outliers.contains(j))
continue; continue;
gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j),
if (sd.at(j).hasElevation() && !_useDEM) sd.at(j).elevation()));
gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j),
sd.at(j).elevation()));
else {
qreal elevation = DEM::elevation(sd.at(j).coordinates());
if (!std::isnan(elevation))
gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j),
elevation));
else if (sd.at(j).hasElevation())
gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j),
sd.at(j).elevation()));
}
} }
ret.append(filter(gs, _elevationWindow)); ret.append(filter(gs, _elevationWindow));

View File

@ -45,7 +45,6 @@ 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 useDEM(bool use) {_useDEM = use;}
private: private:
struct Segment { struct Segment {
@ -71,7 +70,6 @@ private:
static qreal _pauseSpeed; static qreal _pauseSpeed;
static int _pauseInterval; static int _pauseInterval;
static bool _useReportedSpeed; static bool _useReportedSpeed;
static bool _useDEM;
}; };
#endif // TRACK_H #endif // TRACK_H