some shit

This commit is contained in:
2022-12-20 21:26:50 +01:00
parent a5cf2f2c1d
commit 3a3aa6be32
2 changed files with 44 additions and 6 deletions
+22
View File
@@ -11,6 +11,18 @@
#include "route.h"
Point::Point(double lat, double lon, uint32_t horizontalAccuracy) {
this->lat = lat;
this->lon = lon;
this->init(horizontalAccuracy);
}
Point::Point() {
this->lat = 0;
this->lon = 0;
this->init(0);
}
double Point::distanceTo(const Point &point) const {
// distance = sqrt(dx * dx + dy * dy)
@@ -39,6 +51,16 @@ double Point::courseTo(const Point &point) const {
return res;
}
void Point::init(uint32_t horizontalAccuracy) {
this->creationTime = millis();
if (horizontalAccuracy > 9999)
this->accuracy = PointAccuracy::fourDigOfCM;
else if (horizontalAccuracy > 999)
this->accuracy = PointAccuracy::threeDigOfCM
else if (horizontalAccuracy > 99)
}
Route::Route() {
}
+22 -6
View File
@@ -12,6 +12,8 @@
#ifndef ROUTE_H
#define ROUTE_H
#include <Arduino.h>
#include <cstdint>
#include <list>
#include <cmath>
@@ -20,6 +22,14 @@
#define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300
#define ROUTE_PI 3.14159265358979323846
enum PointAccuracy {
none,
fourDigOfCM,
threeDigOfCM,
twoDigOfCM,
oneDigOfCM
};
/**
* @brief A to handle points on the earth
*
@@ -34,14 +44,11 @@ class Point{
* @param lat latidude
* @param lon longitude
*/
Point(double lat, double lon) { this->lat = lat; this->lon = lon; }
Point(){ this->lat = 0; this->lon = 0; }
Point(double lat, double lon, uint32_t horizontalAccuracy = 0);
Point();
double lat = 0;
double lon = 0;
uint8_t fixType = -1;
uint8_t carrierSolution = -1;
uint32_t horizontalAccuracy = -1;
/**
* @brief checks if to points are equal
@@ -61,10 +68,19 @@ class Point{
* @return false
*/
bool isInit() const { return this->lat + this->lon; }
bool isValid() const { return (this->horizontalAccuracy < 5000) ? true : false; }
bool isValid() const { return (this->accuracy > 0) ? true : false; }
double distanceTo(const Point& point) const;
double courseTo(const Point& point) const;
PointAccuracy getAccuracy() { return this->accuracy; }
private:
void init(uint32_t horizontalAccuracy);
PointAccuracy accuracy = PointAccuracy::none;
uint32_t creationTime = 0;
};
/**