new version
[googlelatitude] / src / gps.cpp
1 #include "gps.h"
2
3 GpsMaemo5::GpsMaemo5(QObject *parent) : QObject(parent) {
4     latitude = 0;
5     longitude = 0;
6     accuracy = 0;
7
8     control = location_gpsd_control_get_default();
9     device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
10
11     g_signal_connect(device, "changed", G_CALLBACK(GpsMaemo5_changed), this);
12     g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
13
14     location_gpsd_control_start(control);
15 }
16
17 void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps) {
18     if (device->fix) {
19         if (device->fix->fields) {
20             g_print("lat = %f, long = %f, eph = %f\n", gps->device->fix->latitude, gps->device->fix->longitude, gps->device->fix->eph/100.);
21             gps->latitude = gps->device->fix->latitude;
22             gps->longitude = gps->device->fix->longitude;
23             gps->accuracy = gps->device->fix->eph/100.;
24             emit gps->fix();
25         }
26     }
27 }