along with this program. If not, see <http://www.gnu.org/licenses/>.
****/
+#include <math.h>
+
#include "callbacks.h"
#include "appdata.h"
#include "util.h"
-// this is just here for debugging and tracing purposes
+// this is just here for debugging
static void print_location(LocationGPSDevice* device) {
g_print("Latitude: %.2f\n"
"Longitude: %.2f\n"
"Altitude: %.2f\n"
- "Speed: %d",
+ "Speed: %.2d\n",
device->fix->latitude,
device->fix->longitude,
device->fix->altitude,
}
void location_changed(LocationGPSDevice* device, gpointer data) {
- print_location(device);
+ //print_location(device);
+ g_assert(data);
+ g_assert(device);
AppData* appdata = (AppData*) data;
- if(device->fix && LOCATION_GPS_DEVICE_SPEED_SET) {
- g_print("Speed is %f km/h", device->fix->speed);
- interpret_speed_from_gps(appdata, device->fix->speed);
+ // check for NaN before passing values
+ if(device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
+ if(!isnan(device->fix->speed)) {
+ interpret_speed_from_gps(appdata, device->fix->speed);
+ }
}
}