/** * @file route.h * @author Alexander Klein (alex@kleiax.de) * @brief Contains a class which hold multiple Points * @version 0.1 * @date 2022-01-31 * * @copyright Copyright (c) 2022 * */ #ifndef ROUTE_H #define ROUTE_H #include #include #include #define ROUTE_DEGREE_TO_RADIANT 0.01745 #define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300 #define ROUTE_PI 3.14159265358979323846 /** * @brief A to handle points on the earth * * The points inherits latidue and longitude as doubles * */ class Point{ public: /** * @brief Construct a new Point object * * @param lat latidude * @param lon longitude */ Point(double lat, double lon) { this->lat = lat; this->lon = lon; } Point(){ this->lat = 0; this->lon = 0; } 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 * * @param rhs * @return true * @return false */ bool operator==(const Point& rhs) const { return this->lat == rhs.lat && this->lon == rhs.lon; } /** * @brief Checks if the Point is initalized. * * @return true * @return false */ bool isInit() const { return this->lat + this->lon; } bool isValid() const { return (this->horizontalAccuracy < 5000) ? true : false; } double distanceTo(const Point& point) const; double courseTo(const Point& point) const; }; /** * @brief Holds some route information * */ struct RouteInfo{ /** * @brief Selected number of Points */ uint16_t currentPoint; /** * @brief Total points stored in route */ uint16_t totalPoints; }; /** * @brief A class to manage multiple points * * The list of point presents a route which can be driven */ class Route { public: /** * @brief Construct a new Route object */ Route(); /** * @brief Adds a point to the list * * @param point */ void addPointToRoute(Point point); /** * @brief Select the first point as target * * @return Point */ Point startRoute(); /** * @brief Get the next point and set it as target * * @return Point is zero if there are no more Points */ Point getNextPoint(); /** * @brief Get the Route Info object * * @return RouteInfo */ RouteInfo getRouteInfo(); private: uint16_t currentPoint = 0; std::list points; std::list::iterator it; }; #endif // ROUTE_H