0.4 release
[speedometer] / callbacks.c
index 950c202..479cca7 100644 (file)
@@ -16,6 +16,8 @@
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****/
 
+#include <math.h>
+
 #include "callbacks.h"
 #include "appdata.h"
 #include "util.h"
@@ -34,12 +36,16 @@ static void print_location(LocationGPSDevice* device) {
 
 void location_changed(LocationGPSDevice* device, gpointer data) {
        //print_location(device);
+       g_assert(data);
+       g_assert(device);
 
        AppData* appdata = (AppData*) data;
 
+       // check for NaN before passing values
        if(device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
-               g_print("Speed is %.2f km/h\n", device->fix->speed);
-               interpret_speed_from_gps(appdata, device->fix->speed);
+               if(!isnan(device->fix->speed)) {
+                       interpret_speed_from_gps(appdata, device->fix->speed);
+                       }
        }
 }