From 1fabf0ab16706b0baeaf182c1ef79b18f33c7c07 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Wed, 28 Dec 2022 17:45:18 +0100 Subject: [PATCH] added endRoute and getPreviousPoint --- lib/Navigation/route.cpp | 26 ++++++++++++++++++++++---- lib/Navigation/route.h | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/Navigation/route.cpp b/lib/Navigation/route.cpp index ceccad1..61dce58 100644 --- a/lib/Navigation/route.cpp +++ b/lib/Navigation/route.cpp @@ -105,16 +105,34 @@ Point Route::startRoute() { return *this->it; } +Point Route::endRoute() { + if (this->points.size() < 1) + return Point(0, 0); + this->it = this->points.end(); + this->currentPoint = this->points.size(); + return *this->it; +} + Point Route::getNextPoint() { if (this->it != this->points.end()) { this->it++; this->currentPoint++; return *this->it; - } else if (this->it == this->points.end() && this->currentPoint != this->points.size()) { - this->currentPoint++; - return *this->it; + // } else if (this->it == this->points.end() && this->currentPoint != this->points.size()) { + // this->currentPoint++; + // return *this->it; } else - return Point(0, 0); + return Point(); +} + +Point Route::getPreviousPoint() { + if (this->it != this->points.begin()) { + this->it--; + this->currentPoint--; + return *this->it; + } else { + return Point(); + } } RouteInfo Route::getRouteInfo() { diff --git a/lib/Navigation/route.h b/lib/Navigation/route.h index afa6674..4edac8f 100644 --- a/lib/Navigation/route.h +++ b/lib/Navigation/route.h @@ -138,6 +138,7 @@ class Route { * @return Point */ Point startRoute(); + Point endRoute(); /** * @brief Get the next point and set it as target @@ -145,6 +146,7 @@ class Route { * @return Point is zero if there are no more Points */ Point getNextPoint(); + Point getPreviousPoint(); /** * @brief Get the Route Info object