added imported to PointAccuracy
This commit is contained in:
@@ -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--;
|
||||
|
||||
Reference in New Issue
Block a user