* special case when min_deltas has LPP_GPS value
This commit is contained in:
1 parent
f6cbc11c85
commit
b0fd8e6801
3 files changed
+83
-12
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
class GPSLocHelper {
|
||||
static constexpr double APPROX_RADIUS = 6371e3; // 6,371 km
|
||||
|
||||
static double toRadians(float degrees) {
|
||||
return degrees * PI / 180;
|
||||
}
|
||||
|
||||
public:
|
||||
static float calcGreatArcMeters(float lat1, float lon1, float lat2, float lon2) {
|
||||
double diffLati = toRadians(lat1 - lat2);
|
||||
double diffLong = toRadians(lon1 - lon2);
|
||||
double radiusStartLati = toRadians(lat2);
|
||||
double radiusEndLati = toRadians(lat1);
|
||||
|
||||
// A and C are the 'sides' from the spherical triangle.
|
||||
double sinLati = sin(diffLati / 2);
|
||||
double sinLong = sin(diffLong / 2);
|
||||
|
||||
double a = sinLati*sinLati + sinLong*sinLong * cos(radiusStartLati) * cos(radiusEndLati);
|
||||
double c = 2 * asin(sqrt(a));
|
||||
|
||||
return APPROX_RADIUS * c;
|
||||
}
|
||||
};
|
||||
@@ -162,6 +162,12 @@ public:
|
||||
return size;
|
||||
}
|
||||
|
||||
static uint8_t readGPS(const uint8_t* _buf, float& lat, float& lon, float& alt) {
|
||||
lat = getFloat(&_buf[0], 3, 10000, true);
|
||||
lon = getFloat(&_buf[3], 3, 10000, true);
|
||||
alt = getFloat(&_buf[6], 3, 100, true);
|
||||
return 9;
|
||||
}
|
||||
};
|
||||
|
||||
class LPPReader {
|
||||
|
||||
Reference in new issue
Block a user