GeoClue is a system for giving easy access to location information for applications over the D-BUS. Lots of people have shown interest in adding geographical awareness in their software, and I really think GeoClue is the right way to move forward, especially for mobile devices.
Consider the following Python code to get current location:
# Access the D-BUS session bus bus = dbus.SessionBus() # Get an interface for the GeoClue master (which will talk to appropriate backend) proxy_obj = bus.get_object('org.foinse_project.geoclue.position.master', '/org/foinse_project/geoclue/position/master') geoclue_iface = dbus.Interface(proxy_obj, 'org.foinse_project.geoclue.position') # Get the coordinates from the service coordinates = geoclue_iface.current_position()
Caveat: the code might not work exactly like this, but instead may need a bit of tweaking. I’m sorry but I’m currently without an N800 to test on. C code in any case is as easy as:
gdouble lat, lon; geoclue_position_init (); geoclue_position_current_position (&lat, &lon);
Traditional methods to get location would require a lot more code and would be hardcoded to just one position source, like GPS. GeoClue can provide lots of different back-ends, including Plazes and HostIP in addition to the common gpsd.
While we were talking to application developers, Jussi Kukkonen, the Google Summer of Code student I mentor was also busy. He made a new GeoClue release, which is the first one to give the system a real UI. Good stuff!
Thanks to Jussi for the hard work, and to Andreas Nilsson for the GeoClue icon featured earlier in the post!
BTW, When I upgraded my blog to new layout and structure last January I left commenting out pretty much for the same reasons as what Joel Spolsky outlined in his post. People who really want to discuss my post will anyway either contact me by email or comment on Jaiku.