2016-08-09 01:16:19 +02:00
|
|
|
#include "ll.h"
|
|
|
|
#include "route.h"
|
|
|
|
|
|
|
|
Route::Route(const QVector<Waypoint> &data) : _data(data)
|
|
|
|
{
|
|
|
|
qreal dist = 0;
|
|
|
|
|
|
|
|
_dd.append(dist);
|
2016-08-09 23:08:49 +02:00
|
|
|
for (int i = 1; i < data.count(); i++) {
|
|
|
|
dist += llDistance(data.at(i).coordinates(), data.at(i-1).coordinates());
|
2016-08-09 01:16:19 +02:00
|
|
|
_dd.append(dist);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-09 23:08:49 +02:00
|
|
|
QVector<QPointF> Route::elevation() const
|
2016-08-09 01:16:19 +02:00
|
|
|
{
|
2016-08-09 23:08:49 +02:00
|
|
|
QVector<QPointF> graph;
|
2016-08-09 01:16:19 +02:00
|
|
|
|
|
|
|
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()));
|
2016-08-09 23:08:49 +02:00
|
|
|
|
|
|
|
return graph;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal Route::distance() const
|
|
|
|
{
|
|
|
|
return (_dd.isEmpty()) ? 0 : _dd.last();
|
2016-08-09 01:16:19 +02:00
|
|
|
}
|