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:
parent
37e07accd4
commit
f9c593e6d1
@ -24,7 +24,7 @@ QString RouteItem::toolTip(Units units) const
|
||||
RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
||||
: PathItem(route.path(), map, parent)
|
||||
{
|
||||
const QVector<Waypoint> &waypoints = route.waypoints();
|
||||
const RouteData &waypoints = route.data();
|
||||
|
||||
_waypoints.resize(waypoints.size());
|
||||
for (int i = 0; i < waypoints.size(); i++)
|
||||
|
@ -71,13 +71,35 @@ static QHash<QString, Parser*> parsers()
|
||||
QHash<QString, Parser*> Data::_parsers = parsers();
|
||||
bool Data::_useDEM = false;
|
||||
|
||||
void Data::processData(const QList<TrackData> &trackData,
|
||||
const QList<RouteData> &routeData)
|
||||
void Data::processData(QList<TrackData> &trackData, 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)));
|
||||
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)));
|
||||
}
|
||||
for (int i = 0; i < _waypoints.size(); i++) {
|
||||
if (!_waypoints.at(i).hasElevation() || _useDEM) {
|
||||
qreal elevation = DEM::elevation(_waypoints.at(i).coordinates());
|
||||
@ -181,6 +203,4 @@ QStringList Data::filter()
|
||||
void Data::useDEM(bool use)
|
||||
{
|
||||
_useDEM = use;
|
||||
Route::useDEM(use);
|
||||
Track::useDEM(use);
|
||||
}
|
||||
|
@ -31,8 +31,7 @@ public:
|
||||
static void useDEM(bool use);
|
||||
|
||||
private:
|
||||
void processData(const QList<TrackData> &trackData,
|
||||
const QList<RouteData> &routeData);
|
||||
void processData(QList<TrackData> &trackData, QList<RouteData> &routeData);
|
||||
|
||||
bool _valid;
|
||||
QString _errorString;
|
||||
|
@ -2,8 +2,6 @@
|
||||
#include "route.h"
|
||||
|
||||
|
||||
bool Route::_useDEM = false;
|
||||
|
||||
Route::Route(const RouteData &data) : _data(data)
|
||||
{
|
||||
qreal dist = 0;
|
||||
@ -34,19 +32,8 @@ Graph Route::elevation() const
|
||||
graph.append(GraphSegment());
|
||||
GraphSegment &gs = graph.last();
|
||||
|
||||
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()));
|
||||
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()));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
gs.append(GraphPoint(_distance.at(i), NAN, _data.at(i).elevation()));
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
|
||||
Path path() const;
|
||||
|
||||
const QVector<Waypoint> &waypoints() const {return _data;}
|
||||
const RouteData &data() const {return _data;}
|
||||
|
||||
Graph elevation() const;
|
||||
|
||||
@ -24,13 +24,9 @@ public:
|
||||
|
||||
bool isValid() const {return _data.size() >= 2;}
|
||||
|
||||
static void useDEM(bool use) {_useDEM = use;}
|
||||
|
||||
private:
|
||||
RouteData _data;
|
||||
QVector<qreal> _distance;
|
||||
|
||||
static bool _useDEM;
|
||||
};
|
||||
|
||||
#endif // ROUTE_H
|
||||
|
@ -13,7 +13,6 @@ int Track::_pauseInterval = 10;
|
||||
|
||||
bool Track::_outlierEliminate = true;
|
||||
bool Track::_useReportedSpeed = false;
|
||||
bool Track::_useDEM = false;
|
||||
|
||||
|
||||
static qreal median(QVector<qreal> &v)
|
||||
@ -180,19 +179,8 @@ Graph Track::elevation() const
|
||||
for (int j = 0; j < sd.size(); j++) {
|
||||
if (seg.outliers.contains(j))
|
||||
continue;
|
||||
|
||||
if (sd.at(j).hasElevation() && !_useDEM)
|
||||
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));
|
||||
|
@ -45,7 +45,6 @@ public:
|
||||
static void setOutlierElimination(bool eliminate)
|
||||
{_outlierEliminate = eliminate;}
|
||||
static void useReportedSpeed(bool use) {_useReportedSpeed = use;}
|
||||
static void useDEM(bool use) {_useDEM = use;}
|
||||
|
||||
private:
|
||||
struct Segment {
|
||||
@ -71,7 +70,6 @@ private:
|
||||
static qreal _pauseSpeed;
|
||||
static int _pauseInterval;
|
||||
static bool _useReportedSpeed;
|
||||
static bool _useDEM;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
Loading…
Reference in New Issue
Block a user