mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 03:29:16 +02:00
Split DEM setting for data and POI + only load DEM data for visible POIs
This commit is contained in:
@ -51,7 +51,7 @@ static QHash<QString, Parser*> parsers()
|
||||
|
||||
|
||||
QHash<QString, Parser*> Data::_parsers = parsers();
|
||||
bool Data::_useDEMElevation = false;
|
||||
bool Data::_useDEM = false;
|
||||
|
||||
Data::~Data()
|
||||
{
|
||||
@ -68,7 +68,7 @@ void Data::processData()
|
||||
for (int i = 0; i < _routeData.count(); i++)
|
||||
_routes.append(new Route(_routeData.at(i)));
|
||||
for (int i = 0; i < _waypoints.size(); i++) {
|
||||
if (!_waypoints.at(i).hasElevation() || _useDEMElevation) {
|
||||
if (!_waypoints.at(i).hasElevation() || _useDEM) {
|
||||
qreal elevation = DEM::elevation(_waypoints.at(i).coordinates());
|
||||
if (!std::isnan(elevation))
|
||||
_waypoints[i].setElevation(elevation);
|
||||
@ -76,7 +76,7 @@ void Data::processData()
|
||||
}
|
||||
}
|
||||
|
||||
Data::Data(const QString &fileName)
|
||||
Data::Data(const QString &fileName, bool poi)
|
||||
{
|
||||
QFile file(fileName);
|
||||
QFileInfo fi(fileName);
|
||||
@ -92,7 +92,8 @@ Data::Data(const QString &fileName)
|
||||
QHash<QString, Parser*>::iterator it;
|
||||
if ((it = _parsers.find(fi.suffix().toLower())) != _parsers.end()) {
|
||||
if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) {
|
||||
processData();
|
||||
if (!poi)
|
||||
processData();
|
||||
_valid = true;
|
||||
return;
|
||||
} else {
|
||||
@ -102,7 +103,8 @@ Data::Data(const QString &fileName)
|
||||
} else {
|
||||
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
||||
if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) {
|
||||
processData();
|
||||
if (!poi)
|
||||
processData();
|
||||
_valid = true;
|
||||
return;
|
||||
}
|
||||
@ -148,9 +150,9 @@ QStringList Data::filter()
|
||||
return filter;
|
||||
}
|
||||
|
||||
void Data::useDEMElevation(bool use)
|
||||
void Data::useDEM(bool use)
|
||||
{
|
||||
_useDEMElevation = use;
|
||||
Route::useDEMElevation(use);
|
||||
Track::useDEMElevation(use);
|
||||
_useDEM = use;
|
||||
Route::useDEM(use);
|
||||
Track::useDEM(use);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
class Data
|
||||
{
|
||||
public:
|
||||
Data(const QString &fileName);
|
||||
Data(const QString &fileName, bool poi = false);
|
||||
~Data();
|
||||
|
||||
bool isValid() const {return _valid;}
|
||||
@ -28,7 +28,7 @@ public:
|
||||
static QString formats();
|
||||
static QStringList filter();
|
||||
|
||||
static void useDEMElevation(bool use);
|
||||
static void useDEM(bool use);
|
||||
|
||||
private:
|
||||
void processData();
|
||||
@ -45,7 +45,7 @@ private:
|
||||
QList<RouteData> _routeData;
|
||||
|
||||
static QHash<QString, Parser*> _parsers;
|
||||
static bool _useDEMElevation;
|
||||
static bool _useDEM;
|
||||
};
|
||||
|
||||
#endif // DATA_H
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "common/rectc.h"
|
||||
#include "common/greatcircle.h"
|
||||
#include "data.h"
|
||||
#include "dem.h"
|
||||
#include "poi.h"
|
||||
|
||||
|
||||
@ -14,7 +15,7 @@ POI::POI(QObject *parent) : QObject(parent)
|
||||
|
||||
bool POI::loadFile(const QString &path, bool dir)
|
||||
{
|
||||
Data data(path);
|
||||
Data data(path, true);
|
||||
FileIndex index;
|
||||
|
||||
index.enabled = true;
|
||||
@ -107,6 +108,17 @@ void POI::search(const RectC &rect, QSet<int> &set) const
|
||||
_tree.Search(min, max, cb, &set);
|
||||
}
|
||||
|
||||
void POI::appendElevation(QList<Waypoint> &points) const
|
||||
{
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
if (!points.at(i).hasElevation() || _useDEM) {
|
||||
qreal elevation = DEM::elevation(points.at(i).coordinates());
|
||||
if (!std::isnan(elevation))
|
||||
points[i].setElevation(elevation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<Waypoint> POI::points(const Path &path) const
|
||||
{
|
||||
QList<Waypoint> ret;
|
||||
@ -137,6 +149,8 @@ QList<Waypoint> POI::points(const Path &path) const
|
||||
for (it = set.constBegin(); it != set.constEnd(); ++it)
|
||||
ret.append(_data.at(*it));
|
||||
|
||||
appendElevation(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -158,6 +172,8 @@ QList<Waypoint> POI::points(const Waypoint &point) const
|
||||
for (it = set.constBegin(); it != set.constEnd(); ++it)
|
||||
ret.append(_data.at(*it));
|
||||
|
||||
appendElevation(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -203,3 +219,10 @@ void POI::setRadius(unsigned radius)
|
||||
|
||||
emit pointsChanged();
|
||||
}
|
||||
|
||||
void POI::useDEM(bool use)
|
||||
{
|
||||
_useDEM = use;
|
||||
|
||||
emit pointsChanged();
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
|
||||
unsigned radius() const {return _radius;}
|
||||
void setRadius(unsigned radius);
|
||||
void useDEM(bool use);
|
||||
|
||||
QList<Waypoint> points(const Path &path) const;
|
||||
QList<Waypoint> points(const Waypoint &point) const;
|
||||
@ -45,6 +46,7 @@ private:
|
||||
|
||||
bool loadFile(const QString &path, bool dir);
|
||||
void search(const RectC &rect, QSet<int> &set) const;
|
||||
void appendElevation(QList<Waypoint> &points) const;
|
||||
|
||||
POITree _tree;
|
||||
QVector<Waypoint> _data;
|
||||
@ -52,6 +54,7 @@ private:
|
||||
QList<FileIndex> _indexes;
|
||||
|
||||
unsigned _radius;
|
||||
bool _useDEM;
|
||||
|
||||
QString _errorString;
|
||||
int _errorLine;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "route.h"
|
||||
|
||||
|
||||
bool Route::_useDEMElevation = false;
|
||||
bool Route::_useDEM = false;
|
||||
|
||||
Route::Route(const RouteData &data) : _data(data)
|
||||
{
|
||||
@ -31,7 +31,7 @@ Graph Route::elevation() const
|
||||
Graph graph;
|
||||
|
||||
for (int i = 0; i < _data.size(); i++) {
|
||||
if (_data.at(i).hasElevation() && !_useDEMElevation)
|
||||
if (_data.at(i).hasElevation() && !_useDEM)
|
||||
graph.append(GraphPoint(_distance.at(i), NAN,
|
||||
_data.at(i).elevation()));
|
||||
else {
|
||||
|
@ -24,13 +24,13 @@ public:
|
||||
|
||||
bool isNull() const {return (_data.count() < 2);}
|
||||
|
||||
static void useDEMElevation(bool use) {_useDEMElevation = use;}
|
||||
static void useDEM(bool use) {_useDEM = use;}
|
||||
|
||||
private:
|
||||
const RouteData &_data;
|
||||
QVector<qreal> _distance;
|
||||
|
||||
static bool _useDEMElevation;
|
||||
static bool _useDEM;
|
||||
};
|
||||
|
||||
#endif // ROUTE_H
|
||||
|
@ -13,7 +13,7 @@ int Track::_pauseInterval = 10;
|
||||
|
||||
bool Track::_outlierEliminate = true;
|
||||
bool Track::_useReportedSpeed = false;
|
||||
bool Track::_useDEMElevation = false;
|
||||
bool Track::_useDEM = false;
|
||||
|
||||
|
||||
static qreal median(QVector<qreal> &v)
|
||||
@ -154,7 +154,7 @@ Graph Track::elevation() const
|
||||
if (_outliers.contains(i))
|
||||
continue;
|
||||
|
||||
if (_data.at(i).hasElevation() && !_useDEMElevation)
|
||||
if (_data.at(i).hasElevation() && !_useDEM)
|
||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||
_data.at(i).elevation()));
|
||||
else {
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
static void setOutlierElimination(bool eliminate)
|
||||
{_outlierEliminate = eliminate;}
|
||||
static void useReportedSpeed(bool use) {_useReportedSpeed = use;}
|
||||
static void useDEMElevation(bool use) {_useDEMElevation = use;}
|
||||
static void useDEM(bool use) {_useDEM = use;}
|
||||
|
||||
private:
|
||||
bool discardStopPoint(int i) const;
|
||||
@ -70,7 +70,7 @@ private:
|
||||
static qreal _pauseSpeed;
|
||||
static int _pauseInterval;
|
||||
static bool _useReportedSpeed;
|
||||
static bool _useDEMElevation;
|
||||
static bool _useDEM;
|
||||
};
|
||||
|
||||
#endif // TRACK_H
|
||||
|
Reference in New Issue
Block a user