- some should be the same as previous commit (sorry!) - some should be new: LINT checks, ...?
57 lines
1.6 KiB
C++
57 lines
1.6 KiB
C++
#ifndef GPSDATA_H
|
|
#define GPSDATA_H
|
|
|
|
#include "../../data/Timestamp.h"
|
|
#include "../../geo/EarthPos.h"
|
|
|
|
struct GPSData {
|
|
|
|
/** time this measurement was received (NOT the GPS-time) */
|
|
Timestamp tsReceived;
|
|
|
|
float lat; // deg
|
|
float lon; // deg
|
|
float alt; // m above sea-level
|
|
|
|
float accuracy; // m [might be NAN]
|
|
float speed; // m/s [might be NAN]
|
|
|
|
/** ctor for invalid/unknown data */
|
|
GPSData() : tsReceived(), lat(NAN), lon(NAN), alt(NAN), accuracy(NAN), speed(NAN) {;}
|
|
|
|
/** ctor */
|
|
GPSData(const Timestamp tsReceived, const float lat, const float lon, const float alt) : tsReceived(tsReceived), lat(lat), lon(lon), alt(alt), accuracy(NAN), speed(NAN) {;}
|
|
|
|
/** ctor */
|
|
GPSData(const Timestamp tsReceived, const float lat, const float lon, const float alt, const float accuracy) : tsReceived(tsReceived), lat(lat), lon(lon), alt(alt), accuracy(accuracy), speed(NAN) {;}
|
|
|
|
/** get as EarthPos struct */
|
|
EarthPos toEarthPos() const {
|
|
return EarthPos(lat, lon, alt);
|
|
}
|
|
|
|
/** data valid? */
|
|
bool isValid() const {
|
|
return (lat == lat) && (lon == lon);
|
|
}
|
|
|
|
bool operator == (const GPSData& o) const {
|
|
return EQ_OR_NAN(lat, o.lat) &&
|
|
EQ_OR_NAN(lon, o.lon) &&
|
|
EQ_OR_NAN(alt, o.alt) &&
|
|
EQ_OR_NAN(accuracy, o.accuracy) &&
|
|
EQ_OR_NAN(speed, o.speed);
|
|
}
|
|
|
|
std::string asString() const {
|
|
return "(lat: " + std::to_string(lat) + ", lon: " + std::to_string(lon) + ", alt: " + std::to_string(alt) + " acur: " + std::to_string(accuracy) + ")";
|
|
}
|
|
|
|
private:
|
|
|
|
static inline bool EQ_OR_NAN(const float a, const float b) {return (a==b) || ( (a!=a) && (b!=b) );}
|
|
|
|
};
|
|
|
|
#endif // GPSDATA_H
|