File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 20
20
21
21
/*------------------------------------------------------------------
22
22
*
23
- * Module: dwgps .c
23
+ * Module: dwgpsd .c
24
24
*
25
25
* Purpose: Interface to location data, i.e. GPS receiver.
26
26
*
@@ -401,13 +401,15 @@ static void * read_gpsd_thread (void *arg)
401
401
402
402
if (/*gpsdata.stupid_status >= STATUS_FIX &&*/ gpsdata .fix .mode >= MODE_2D ) {
403
403
404
- info .dlat = isfinite (gpsdata .fix .latitude ) ? gpsdata .fix .latitude : G_UNKNOWN ;
405
- info .dlon = isfinite (gpsdata .fix .longitude ) ? gpsdata .fix .longitude : G_UNKNOWN ;
404
+ #define GOOD (x ) (isfinite(x) && ! isnan(x))
405
+
406
+ info .dlat = GOOD (gpsdata .fix .latitude ) ? gpsdata .fix .latitude : G_UNKNOWN ;
407
+ info .dlon = GOOD (gpsdata .fix .longitude ) ? gpsdata .fix .longitude : G_UNKNOWN ;
406
408
// When stationary, track is NaN which is not finite.
407
- info .track = isfinite (gpsdata .fix .track ) ? gpsdata .fix .track : G_UNKNOWN ;
408
- info .speed_knots = isfinite (gpsdata .fix .speed ) ? (MPS_TO_KNOTS * gpsdata .fix .speed ) : G_UNKNOWN ;
409
+ info .track = GOOD (gpsdata .fix .track ) ? gpsdata .fix .track : G_UNKNOWN ;
410
+ info .speed_knots = GOOD (gpsdata .fix .speed ) ? (MPS_TO_KNOTS * gpsdata .fix .speed ) : G_UNKNOWN ;
409
411
if (gpsdata .fix .mode >= MODE_3D ) {
410
- info .altitude = isfinite (gpsdata .fix .stupid_altitude ) ? gpsdata .fix .stupid_altitude : G_UNKNOWN ;
412
+ info .altitude = GOOD (gpsdata .fix .stupid_altitude ) ? gpsdata .fix .stupid_altitude : G_UNKNOWN ;
411
413
}
412
414
// Otherwise keep last known altitude when we downgrade from 3D to 2D fix.
413
415
// Caller knows altitude is outdated if info.fix == DWFIX_2D.
You can’t perform that action at this time.
0 commit comments