1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00
GPXSee/src/route.cpp
Martin Tůma 20b107581e Added missing routes related stuff
Refactoring/optimization/cleanup
2016-08-09 23:08:49 +02:00

31 lines
611 B
C++

#include "ll.h"
#include "route.h"
Route::Route(const QVector<Waypoint> &data) : _data(data)
{
qreal dist = 0;
_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);
}
}
QVector<QPointF> Route::elevation() const
{
QVector<QPointF> graph;
for (int i = 0; i < _data.size(); i++)
if (_data.at(i).hasElevation())
graph.append(QPointF(_dd.at(i), _data.at(i).elevation()
- _data.at(i).geoidHeight()));
return graph;
}
qreal Route::distance() const
{
return (_dd.isEmpty()) ? 0 : _dd.last();
}