mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Code cleanup
This commit is contained in:
parent
fc67f6f19a
commit
2695745d82
@ -81,39 +81,34 @@ static QVector<QPointF> filter(const QVector<QPointF> &v, int window)
|
||||
|
||||
Track::Track(const QVector<Trackpoint> &data) : _data(data)
|
||||
{
|
||||
_distance = 0;
|
||||
qreal dist = 0;
|
||||
|
||||
for (int i = 1; i < _data.count(); i++)
|
||||
_dd.append(llDistance(_data.at(i).coordinates,
|
||||
_data.at(i-1).coordinates));
|
||||
|
||||
for (int i = 0; i < _dd.size(); i++)
|
||||
_distance += _dd.at(i);
|
||||
_dd.append(dist);
|
||||
for (int i = 1; i < _data.count(); i++) {
|
||||
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
|
||||
_dd.append(dist);
|
||||
}
|
||||
}
|
||||
|
||||
void Track::elevationGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
qreal dist = 0;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
if (_data.at(0).hasElevation())
|
||||
raw.append(QPointF(0, _data.at(0).elevation - _data.at(0).geoidheight));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
dist += _dd.at(i-1);
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasElevation())
|
||||
raw.append(QPointF(dist, _data.at(i).elevation
|
||||
raw.append(QPointF(_dd.at(i), _data.at(i).elevation
|
||||
- _data.at(i).geoidheight));
|
||||
}
|
||||
|
||||
graph = filter(raw, WINDOW_EF);
|
||||
}
|
||||
|
||||
void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
qreal dist = 0, v, ds, dt;
|
||||
qreal v, ds;
|
||||
qint64 dt;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
@ -121,21 +116,17 @@ void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
|
||||
raw.append(QPointF(0, 0));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
ds = _dd.at(i-1);
|
||||
dist += ds;
|
||||
|
||||
if (_data.at(i).hasSpeed())
|
||||
v = _data.at(i).speed;
|
||||
else if (_data.at(i).hasTimestamp()) {
|
||||
dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp)
|
||||
/ 1000.0;
|
||||
if (dt == 0)
|
||||
if (!(dt = _data.at(i-1).timestamp.msecsTo(_data.at(i).timestamp)))
|
||||
continue;
|
||||
v = ds / dt;
|
||||
ds = _dd.at(i) - _dd.at(i-1);
|
||||
v = ds / ((qreal)dt / 1000.0);
|
||||
} else
|
||||
continue;
|
||||
|
||||
raw.append(QPointF(dist, v));
|
||||
raw.append(QPointF(_dd.at(i), v));
|
||||
}
|
||||
|
||||
graph = filter(eliminate(raw, WINDOW_SE), WINDOW_SF);
|
||||
@ -143,37 +134,26 @@ void Track::speedGraph(QVector<QPointF> &graph) const
|
||||
|
||||
void Track::heartRateGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
qreal dist = 0;
|
||||
QVector<QPointF> raw;
|
||||
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
if (_data.at(0).hasHeartRate())
|
||||
raw.append(QPointF(0, _data.at(0).heartRate));
|
||||
for (int i = 1; i < _data.count(); i++) {
|
||||
dist += _dd.at(i-1);
|
||||
for (int i = 0; i < _data.count(); i++)
|
||||
if (_data.at(i).hasHeartRate())
|
||||
raw.append(QPointF(dist, _data.at(i).heartRate));
|
||||
}
|
||||
raw.append(QPointF(_dd.at(i), _data.at(i).heartRate));
|
||||
|
||||
graph = filter(eliminate(raw, WINDOW_HE), WINDOW_HF);
|
||||
}
|
||||
|
||||
void Track::temperatureGraph(QVector<QPointF> &graph) const
|
||||
{
|
||||
qreal dist = 0;
|
||||
|
||||
if (!_data.size())
|
||||
return;
|
||||
|
||||
if (_data.at(0).hasTemperature())
|
||||
graph.append(QPointF(0, _data.at(0).temperature));
|
||||
for (int i = 1; i < _data.size(); i++) {
|
||||
dist += _dd.at(i-1);
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
if (_data.at(i).hasTemperature())
|
||||
graph.append(QPointF(dist, _data.at(i).temperature));
|
||||
}
|
||||
graph.append(QPointF(_dd.at(i), _data.at(i).temperature));
|
||||
}
|
||||
|
||||
void Track::track(QVector<QPointF> &track) const
|
||||
@ -187,14 +167,13 @@ qreal Track::time() const
|
||||
if (_data.size() < 2)
|
||||
return 0;
|
||||
|
||||
return (_data.at(0).timestamp.msecsTo(_data.at(_data.size() - 1).timestamp)
|
||||
/ 1000.0);
|
||||
return (_data.first().timestamp.msecsTo(_data.last().timestamp) / 1000.0);
|
||||
}
|
||||
|
||||
QDateTime Track::date() const
|
||||
{
|
||||
if (_data.size())
|
||||
return _data.at(0).timestamp;
|
||||
return _data.first().timestamp;
|
||||
else
|
||||
return QDateTime();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
void heartRateGraph(QVector<QPointF> &graph) const;
|
||||
void temperatureGraph(QVector<QPointF> &graph) const;
|
||||
void track(QVector<QPointF> &track) const;
|
||||
qreal distance() const {return _distance;}
|
||||
qreal distance() const {return _dd.last();}
|
||||
qreal time() const;
|
||||
QDateTime date() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user