added imported to PointAccuracy

This commit is contained in:
2023-01-04 00:18:35 +01:00
parent abb85340bc
commit 523c170f56
2 changed files with 42 additions and 7 deletions
+37 -6
View File
@@ -28,6 +28,14 @@ Point::Point(Coordinates coords, uint32_t horizontalAccuracy) {
this->init(horizontalAccuracy);
}
Point::Point(Coordinates coords, bool imported) {
this->coordinates = coords;
if (imported)
this->init(UINT32_MAX);
else
this->init(0);
}
Point::Point() {
this->coordinates.lat = 0;
this->coordinates.lon = 0;
@@ -80,17 +88,22 @@ int16_t Point::courseTo(const Point &point) const {
void Point::init(uint32_t horizontalAccuracy) {
this->creationTime = millis();
if (horizontalAccuracy > 9999)
if (horizontalAccuracy == UINT32_MAX)
this->accuracy = PointAccuracy::imported;
else if (horizontalAccuracy > 9999)
this->accuracy = PointAccuracy::fourDigOfCM;
else if (horizontalAccuracy > 999)
this->accuracy = PointAccuracy::threeDigOfCM;
else if (horizontalAccuracy > 99)
this->accuracy = PointAccuracy::twoDigOfCM;
else
this->accuracy = PointAccuracy::oneDigOfCM;
}
Route::Route() {
}
void Route::addPointToRoute(Point point) {
@@ -99,25 +112,40 @@ void Route::addPointToRoute(Point point) {
void Route::clear() {
this->points.clear();
this->currentPoint = 0;
this->started = false;
}
Point Route::startRoute() {
if (this->points.size() < 1)
return Point(0, 0);
if (this->points.size() < 1) {
this->started = false;
return Point();
}
this->it = this->points.begin();
this->currentPoint = 1;
this->started = true;
return *this->it;
}
Point Route::endRoute() {
if (this->points.size() < 1)
return Point(0, 0);
if (this->points.size() < 1) {
this->started = false;
return Point();
}
this->it = this->points.end();
// TODO: Understand why i have to decrement the iterator first to get realy the last element.
this->it--;
this->currentPoint = this->points.size();
this->started = true;
return *this->it;
}
Point Route::getNextPoint() {
if (!this->started)
return Point();
if (this->it != this->points.end()) {
this->it++;
this->currentPoint++;
@@ -130,6 +158,9 @@ Point Route::getNextPoint() {
}
Point Route::getPreviousPoint() {
if (!this->started)
return Point();
if (this->it != this->points.begin()) {
this->it--;
this->currentPoint--;
+5 -1
View File
@@ -44,7 +44,8 @@ class Point{
fourDigOfCM,
threeDigOfCM,
twoDigOfCM,
oneDigOfCM
oneDigOfCM,
imported
};
@@ -57,6 +58,7 @@ class Point{
Point(double lat, double lon, uint32_t horizontalAccuracy = 0);
Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0);
Point(Coordinates coords, uint32_t horizontalAccuracy = 0);
Point(Coordinates coords, bool imported);
Point();
/**
@@ -155,9 +157,11 @@ class Route {
* @return RouteInfo
*/
RouteInfo getRouteInfo();
bool getStarted() const { return this->started; }
private:
uint16_t currentPoint = 0;
bool started = false;
std::list<Point> points;
std::list<Point>::iterator it;