diff --git a/src/data/route.cpp b/src/data/route.cpp index 9d83cc8c..15326465 100644 --- a/src/data/route.cpp +++ b/src/data/route.cpp @@ -33,13 +33,16 @@ Path Route::path() const Graph Route::gpsElevation() const { Graph graph; - graph.append(GraphSegment(QDateTime())); - GraphSegment &gs = graph.last(); + QDateTime date; + GraphSegment gs(date); for (int i = 0; i < _data.size(); i++) if (_data.at(i).hasElevation()) gs.append(GraphPoint(_distance.at(i), NAN, _data.at(i).elevation())); + if (gs.size() >= 2) + graph.append(gs); + if (_data.style().color().isValid()) graph.setColor(_data.style().color()); @@ -49,8 +52,8 @@ Graph Route::gpsElevation() const Graph Route::demElevation() const { Graph graph; - graph.append(GraphSegment(QDateTime())); - GraphSegment &gs = graph.last(); + QDateTime date; + GraphSegment gs(date); for (int i = 0; i < _data.size(); i++) { qreal dem = DEM::elevation(_data.at(i).coordinates()); @@ -58,6 +61,9 @@ Graph Route::demElevation() const gs.append(GraphPoint(_distance.at(i), NAN, dem)); } + if (gs.size() >= 2) + graph.append(gs); + if (_data.style().color().isValid()) graph.setColor(_data.style().color());