mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 03:29:16 +02:00
Prefer the map DEM for track/waypoints elevation if present
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
#include "common/dem.h"
|
||||
#include "map/map.h"
|
||||
#include "route.h"
|
||||
|
||||
bool Route::_useDEM = false;
|
||||
@ -49,19 +49,17 @@ Graph Route::gpsElevation() const
|
||||
return graph;
|
||||
}
|
||||
|
||||
Graph Route::demElevation() const
|
||||
Graph Route::demElevation(Map *map) const
|
||||
{
|
||||
Graph graph;
|
||||
QDateTime date;
|
||||
GraphSegment gs(date);
|
||||
|
||||
DEM::lock();
|
||||
for (int i = 0; i < _data.size(); i++) {
|
||||
qreal dem = DEM::elevation(_data.at(i).coordinates());
|
||||
qreal dem = map->elevation(_data.at(i).coordinates());
|
||||
if (!std::isnan(dem))
|
||||
gs.append(GraphPoint(_distance.at(i), NAN, dem));
|
||||
}
|
||||
DEM::unlock();
|
||||
|
||||
if (gs.size() >= 2)
|
||||
graph.append(gs);
|
||||
@ -72,18 +70,18 @@ Graph Route::demElevation() const
|
||||
return graph;
|
||||
}
|
||||
|
||||
GraphPair Route::elevation() const
|
||||
GraphPair Route::elevation(Map *map) const
|
||||
{
|
||||
if (_useDEM) {
|
||||
Graph dem(demElevation());
|
||||
Graph dem(demElevation(map));
|
||||
return (dem.isEmpty())
|
||||
? GraphPair(gpsElevation(), Graph())
|
||||
: GraphPair(dem, _show2ndElevation ? gpsElevation() : Graph());
|
||||
} else {
|
||||
Graph gps(gpsElevation());
|
||||
return (gps.isEmpty())
|
||||
? GraphPair(demElevation(), Graph())
|
||||
: GraphPair(gps, _show2ndElevation ? demElevation() : Graph());
|
||||
? GraphPair(demElevation(map), Graph())
|
||||
: GraphPair(gps, _show2ndElevation ? demElevation(map) : Graph());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "graph.h"
|
||||
#include "path.h"
|
||||
|
||||
class Map;
|
||||
|
||||
class Route
|
||||
{
|
||||
public:
|
||||
@ -13,7 +15,7 @@ public:
|
||||
|
||||
const RouteData &data() const {return _data;}
|
||||
Path path() const;
|
||||
GraphPair elevation() const;
|
||||
GraphPair elevation(Map *map) const;
|
||||
qreal distance() const;
|
||||
|
||||
const QString &name() const {return _data.name();}
|
||||
@ -30,7 +32,7 @@ public:
|
||||
|
||||
private:
|
||||
Graph gpsElevation() const;
|
||||
Graph demElevation() const;
|
||||
Graph demElevation(Map *map) const;
|
||||
|
||||
RouteData _data;
|
||||
QVector<qreal> _distance;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "common/dem.h"
|
||||
#include "map/map.h"
|
||||
#include "track.h"
|
||||
|
||||
|
||||
@ -277,11 +277,10 @@ Graph Track::gpsElevation() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
Graph Track::demElevation() const
|
||||
Graph Track::demElevation(Map *map) const
|
||||
{
|
||||
Graph ret;
|
||||
|
||||
DEM::lock();
|
||||
for (int i = 0; i < _data.size(); i++) {
|
||||
const SegmentData &sd = _data.at(i);
|
||||
if (sd.size() < 2)
|
||||
@ -290,7 +289,7 @@ Graph Track::demElevation() const
|
||||
GraphSegment gs(seg.start);
|
||||
|
||||
for (int j = 0; j < sd.size(); j++) {
|
||||
qreal dem = DEM::elevation(sd.at(j).coordinates());
|
||||
qreal dem = map->elevation(sd.at(j).coordinates());
|
||||
if (std::isnan(dem) || seg.outliers.contains(j))
|
||||
continue;
|
||||
gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j), dem));
|
||||
@ -299,7 +298,6 @@ Graph Track::demElevation() const
|
||||
if (gs.size() >= 2)
|
||||
ret.append(filter(gs, _elevationWindow));
|
||||
}
|
||||
DEM::unlock();
|
||||
|
||||
if (_data.style().color().isValid())
|
||||
ret.setColor(_data.style().color());
|
||||
@ -307,18 +305,18 @@ Graph Track::demElevation() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
GraphPair Track::elevation() const
|
||||
GraphPair Track::elevation(Map *map) const
|
||||
{
|
||||
if (_useDEM) {
|
||||
Graph dem(demElevation());
|
||||
Graph dem(demElevation(map));
|
||||
return (dem.isEmpty())
|
||||
? GraphPair(gpsElevation(), Graph())
|
||||
: GraphPair(dem, _show2ndElevation ? gpsElevation() : Graph());
|
||||
} else {
|
||||
Graph gps(gpsElevation());
|
||||
return (gps.isEmpty())
|
||||
? GraphPair(demElevation(), Graph())
|
||||
: GraphPair(gps, _show2ndElevation ? demElevation() : Graph());
|
||||
? GraphPair(demElevation(map), Graph())
|
||||
: GraphPair(gps, _show2ndElevation ? demElevation(map) : Graph());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "graph.h"
|
||||
#include "path.h"
|
||||
|
||||
class Map;
|
||||
|
||||
class Track
|
||||
{
|
||||
@ -17,7 +18,7 @@ public:
|
||||
|
||||
Path path() const;
|
||||
|
||||
GraphPair elevation() const;
|
||||
GraphPair elevation(Map *map) const;
|
||||
GraphPair speed() const;
|
||||
Graph heartRate() const;
|
||||
Graph temperature() const;
|
||||
@ -68,7 +69,7 @@ private:
|
||||
qreal lastTime(int seg);
|
||||
bool discardStopPoint(const Segment &seg, int i) const;
|
||||
|
||||
Graph demElevation() const;
|
||||
Graph demElevation(Map *map) const;
|
||||
Graph gpsElevation() const;
|
||||
Graph reportedSpeed() const;
|
||||
Graph computedSpeed() const;
|
||||
|
@ -1,18 +1,16 @@
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include "common/dem.h"
|
||||
#include "map/map.h"
|
||||
#include "waypoint.h"
|
||||
|
||||
bool Waypoint::_useDEM = false;
|
||||
bool Waypoint::_show2ndElevation = false;
|
||||
QHash<QString, QPixmap> Waypoint::_symbolIcons;
|
||||
|
||||
QPair<qreal, qreal> Waypoint::elevations() const
|
||||
QPair<qreal, qreal> Waypoint::elevations(Map *map) const
|
||||
{
|
||||
if (_useDEM) {
|
||||
DEM::lock();
|
||||
qreal dem = DEM::elevation(coordinates());
|
||||
DEM::unlock();
|
||||
qreal dem = map->elevation(coordinates());
|
||||
if (!std::isnan(dem))
|
||||
return QPair<qreal, qreal>(dem, _show2ndElevation ? elevation()
|
||||
: NAN);
|
||||
@ -20,12 +18,10 @@ QPair<qreal, qreal> Waypoint::elevations() const
|
||||
return QPair<qreal, qreal>(elevation(), NAN);
|
||||
} else {
|
||||
if (hasElevation()) {
|
||||
DEM::lock();
|
||||
qreal dem = _show2ndElevation ? DEM::elevation(coordinates()) : NAN;
|
||||
DEM::unlock();
|
||||
qreal dem = _show2ndElevation ? map->elevation(coordinates()) : NAN;
|
||||
return QPair<qreal, qreal>(elevation(), dem);
|
||||
} else
|
||||
return QPair<qreal, qreal>(DEM::elevation(coordinates()), NAN);
|
||||
return QPair<qreal, qreal>(map->elevation(coordinates()), NAN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "link.h"
|
||||
#include "style.h"
|
||||
|
||||
class Map;
|
||||
|
||||
class Waypoint
|
||||
{
|
||||
public:
|
||||
@ -33,7 +35,7 @@ public:
|
||||
qreal elevation() const {return _elevation;}
|
||||
const PointStyle &style() const {return _style;}
|
||||
|
||||
QPair<qreal, qreal> elevations() const;
|
||||
QPair<qreal, qreal> elevations(Map *map) const;
|
||||
|
||||
void setCoordinates(const Coordinates &coordinates)
|
||||
{_coordinates = coordinates;}
|
||||
|
Reference in New Issue
Block a user