some shit
This commit is contained in:
@@ -11,6 +11,18 @@
|
|||||||
|
|
||||||
#include "route.h"
|
#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 {
|
double Point::distanceTo(const Point &point) const {
|
||||||
// distance = sqrt(dx * dx + dy * dy)
|
// distance = sqrt(dx * dx + dy * dy)
|
||||||
|
|
||||||
@@ -39,6 +51,16 @@ double Point::courseTo(const Point &point) const {
|
|||||||
return res;
|
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() {
|
Route::Route() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-6
@@ -12,6 +12,8 @@
|
|||||||
#ifndef ROUTE_H
|
#ifndef ROUTE_H
|
||||||
#define ROUTE_H
|
#define ROUTE_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@@ -20,6 +22,14 @@
|
|||||||
#define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300
|
#define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300
|
||||||
#define ROUTE_PI 3.14159265358979323846
|
#define ROUTE_PI 3.14159265358979323846
|
||||||
|
|
||||||
|
enum PointAccuracy {
|
||||||
|
none,
|
||||||
|
fourDigOfCM,
|
||||||
|
threeDigOfCM,
|
||||||
|
twoDigOfCM,
|
||||||
|
oneDigOfCM
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A to handle points on the earth
|
* @brief A to handle points on the earth
|
||||||
*
|
*
|
||||||
@@ -34,14 +44,11 @@ class Point{
|
|||||||
* @param lat latidude
|
* @param lat latidude
|
||||||
* @param lon longitude
|
* @param lon longitude
|
||||||
*/
|
*/
|
||||||
Point(double lat, double lon) { this->lat = lat; this->lon = lon; }
|
Point(double lat, double lon, uint32_t horizontalAccuracy = 0);
|
||||||
Point(){ this->lat = 0; this->lon = 0; }
|
Point();
|
||||||
|
|
||||||
double lat = 0;
|
double lat = 0;
|
||||||
double lon = 0;
|
double lon = 0;
|
||||||
uint8_t fixType = -1;
|
|
||||||
uint8_t carrierSolution = -1;
|
|
||||||
uint32_t horizontalAccuracy = -1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief checks if to points are equal
|
* @brief checks if to points are equal
|
||||||
@@ -61,10 +68,19 @@ class Point{
|
|||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
bool isInit() const { return this->lat + this->lon; }
|
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 distanceTo(const Point& point) const;
|
||||||
double courseTo(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;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user