summaryrefslogtreecommitdiff
path: root/geoid.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2016-03-31 18:35:27 -0700
committerGary E. Miller <gem@rellim.com>2016-03-31 18:35:27 -0700
commit6aeb53c62e5ba436674f1f407a6876b78c67c0a6 (patch)
treeeb51628fb8d8268648a483ca11b36df69656d3c5 /geoid.c
parent26992849ba7617c7c06e57a1a1ca93b34c231a42 (diff)
downloadgpsd-6aeb53c62e5ba436674f1f407a6876b78c67c0a6.tar.gz
Limit climb/speed to merely insane in ecef_to_wgs84fix().
10,000 m/s should be large enough for all practical purposes. That is about 22,369 mph, or mach 29 at sea level.
Diffstat (limited to 'geoid.c')
-rw-r--r--geoid.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/geoid.c b/geoid.c
index fc74e5df..c267e9c0 100644
--- a/geoid.c
+++ b/geoid.c
@@ -119,10 +119,23 @@ void ecef_to_wgs84fix(struct gps_fix_t *fix, double *separation,
-vx * sin(phi) * cos(lambda) - vy * sin(phi) * sin(lambda) +
vz * cos(phi);
veast = -vx * sin(lambda) + vy * cos(lambda);
+
fix->climb =
vx * cos(phi) * cos(lambda) + vy * cos(phi) * sin(lambda) +
vz * sin(phi);
+ /* sanity check the climb, 10,000 m/s max will do */
+ if ( 9999.9 < fix->climb )
+ fix->climb = 9999.9;
+ else if ( -9999.9 > fix->speed )
+ fix->climb = -9999.9;
+
fix->speed = sqrt(pow(vnorth, 2) + pow(veast, 2));
+ /* sanity check the speed, 10,000 m/s max will do */
+ if ( 9999.9 < fix->speed )
+ fix->speed = 9999.9;
+ else if ( -9999.9 > fix->speed )
+ fix->speed = -9999.9;
+
heading = atan2(fix_minuz(veast), fix_minuz(vnorth));
if (heading < 0)
heading += 2 * GPS_PI;