From 27d68533d71f69747f788c3ac4032a68b97aed7d Mon Sep 17 00:00:00 2001 From: torsten Date: Tue, 22 Sep 2009 14:22:49 +0000 Subject: [PATCH] Catch a possible NAN at insanely low but greater than zero speeds --- src/Instrumentation/gps.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 2d448f575..e2b451467 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -476,8 +476,9 @@ GPS::updateTTWNode(UpdateContext& ctx, double distance_m, SGPropertyNode_ptr nod // increase. Makes most sense when travelling directly towards // the waypoint. double TTW = 0.0; - if (ctx.speed_kt > 0.0 && distance_m > 0.0) { - TTW = (distance_m * SG_METER_TO_NM) / (ctx.speed_kt / 3600); + double speed_nm_per_second = ctx.speed_kt / 3600; + if (speed_nm_per_second > SGLimitsd::min() && distance_m > 0.0) { + TTW = (distance_m * SG_METER_TO_NM) / speed_nm_per_second; } if (TTW < 356400.5) { // That's 99 hours unsigned int TTW_seconds = (int) (TTW + 0.5); -- 2.39.5