added endRoute and getPreviousPoint
This commit is contained in:
@@ -105,16 +105,34 @@ Point Route::startRoute() {
|
|||||||
return *this->it;
|
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() {
|
Point Route::getNextPoint() {
|
||||||
if (this->it != this->points.end()) {
|
if (this->it != this->points.end()) {
|
||||||
this->it++;
|
this->it++;
|
||||||
this->currentPoint++;
|
this->currentPoint++;
|
||||||
return *this->it;
|
return *this->it;
|
||||||
} else if (this->it == this->points.end() && this->currentPoint != this->points.size()) {
|
// } else if (this->it == this->points.end() && this->currentPoint != this->points.size()) {
|
||||||
this->currentPoint++;
|
// this->currentPoint++;
|
||||||
return *this->it;
|
// return *this->it;
|
||||||
} else
|
} 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() {
|
RouteInfo Route::getRouteInfo() {
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ class Route {
|
|||||||
* @return Point
|
* @return Point
|
||||||
*/
|
*/
|
||||||
Point startRoute();
|
Point startRoute();
|
||||||
|
Point endRoute();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the next point and set it as target
|
* @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
|
* @return Point is zero if there are no more Points
|
||||||
*/
|
*/
|
||||||
Point getNextPoint();
|
Point getNextPoint();
|
||||||
|
Point getPreviousPoint();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Route Info object
|
* @brief Get the Route Info object
|
||||||
|
|||||||
Reference in New Issue
Block a user