10 self.control = location.GPSDControl.get_default()
11 self.control.set_properties(preferred_method=location\
12 .METHOD_USER_SELECTED,
13 preferred_interval=location\
15 self.control.connect("error-verbose", self.on_error, self.control)
16 self.control.connect("gpsd-stopped", self.on_stop, None)
18 self.device = location.GPSDevice()
19 self.device.connect("changed", self.on_changed, self.control)
21 def update_location(self):
22 """ Run the loop and update lat and long """
24 gobject.idle_add(self.start_location, self.control)
26 def on_error(self, control, error, data):
28 print "location error: %d... quitting" % error
31 def on_changed(self, device, data):
32 """ Set long and lat """
36 # once fix is found and horizontal accuracy is 1km
37 if location.GPS_DEVICE_LATLONG_SET:
38 if device.fix[6] <= 100000:
39 self.lat, self.long = device.fix[4:6]
42 def on_stop(self, control, data):
43 """ Stop the location service """
46 def start_location(self, data):
47 """ Start the location service """
52 """ Reset coordinates """
55 self.device.reset_last_known()