GNOME GeoClue - The Geolocation Service in Gnome

1,134 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,134
On SlideShare
0
From Embeds
0
Number of Embeds
25
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

GNOME GeoClue - The Geolocation Service in Gnome

  1. 1. 1 GeoClue - The Geolocation Service William.L wiliwe@gmail.com 2010-06-15
  2. 2. 2 Outline History Overview Dependencies Components Reference
  3. 3. 3 History & Goal Started during GNOME Summit 2006 in Boston. Provides a convenient way to find out where the user is, from a number of sources such as GPS, GSM cell, wifi network, internetwork.
  4. 4. 4 Overview GeoClue A software framework utilizing the D-Bus inter-process communication(IPC) mechanism to provide location information, and applications can use it to become geo-aware Can geocode(getting a Position(longitude/latitude coordinate) from an Address) and reverse-geocode (getting an Address from a Position) Licensed under the GNU LGPL http://geoclue.freedesktop.org/
  5. 5. 5 Dependencies (1/2) GObject Glib D-Bus GPSD A GPS daemon on most Debian like system http://gpsd.berlios.de/ Gypsy Written by Iain Holmes at o-hand A GPS multiplexing daemon which allows multiple clients to access GPS data from multiple GPS sources concurrently http://gypsy.freedesktop.org/wiki/
  6. 6. 6 Dependencies (2/2) Wammu A program to manage data in your cell phone such as contacts, calendar or messages. http://wammu.eu/ OpenCellID (basement station ID) Aiming to create a complete database of CellID worlwide, with their locations. http://opencellid.org/
  7. 7. 7 Components (1/10) A set of geoinformation interfaces For querying "current situation“ Position Address Velocity Use a method / signal architecture Ex : To get current position, use – geoclue_position_get_position() method or "position- changed" signal with a callback function
  8. 8. 8 Components (2/10) Class of Interfaces Position - GeocluePosition Via gpsd, gypsy, hostip, plazes, gsmloc Address - GeoclueAddress Via hostip, plazes, manual, localnet Velocity - GeoclueVelocity Via gpsd, gypsy Geocode - GeoclueGeocode Via nominatim (http://nominatim.openstreetmap.org/), geonames (http://www.geonames.org/), yahoo (http://developer.yahoo.com/maps/rest/V1/geocode.html) ReverseGeocode - GeoclueReverseGeocode Via nominatim, geonames Accuracy - GeoclueAccuracy Reports the horizontal and vertical accuracy levels
  9. 9. 9 Components (3/10) Provider Implement more than one Geoclue interface All Geoclue providers are D-Bus services Do not have to run as daemons, as D-Bus will start them when needed (providers may also shut down when they're no longer used). Currently has 9 providers - http://www.freedesktop.org/wiki/Software/GeoClue/Providers
  10. 10. 10 Components (4/10) Type of Providers User-specified address that maps to a router's mac address (home, office). A user-specified address A web service that gets location based on your current router mac address. Interfaces with a user's Plazes account. http://plazes.com A web service that guesses location based on the current IP address. http://www.hostip.info Description Address Address Position, Address Position, Address Service Localnet Manual Plazes Hostip Type
  11. 11. 11 Components (5/10) Type of Providers Gets cell ID data, and estimates location from a web service based upon that data PositionGsmloc A GPS daemon that supports bluetooth and serial GPS devices Position, VelocityGypsy A web service that can convert an address to a position. Conversely, it can also find the nearest address to a given position. A web service that converts an address to a position A GPS daemon that uses TCP sockets Description Geocode, ReverseGeocode Geocode Position, Velocity Service Geonames Yahoo GPSd Type
  12. 12. 12 Components (6/10) Problem on using Providers A single provider cannot be the best solution to all problems The "best" providers will be different depending on the user Master Provider Single window for user to use providers It is an attempt to take away all of the complications of choosing the right provider Choose the best provider to provide what you are looking for based on client requirements and provider availability, accuracy and resource requirements. The provider that is actually used may change over time as conditions change, but the client can just ignore this
  13. 13. 13 Components (7/10) Usage of Master Provider A typical Master provider use : Getting a client-specific GeoclueMasterClient from GeoclueMaster Setting GeoclueMasterClient requirements (such as accuracy) Starting the wanted interfaces (such as Position) Using the client just like a regular provider Master provider is fairly new and may not be as stable as the rest of Geoclue
  14. 14. 14 Components (8/10) Ex : Master Provider #include <geoclue/geoclue-master.h> static void position_changed(...) { if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { g_print ("t%f, %fnn", latitude, longitude);} else { g_print ("tLatitude and longitude not available.nn"); } } int main () { GMainLoop *loop; GeoclueMaster *master; GeoclueMasterClient *client; GeocluePosition *pos; GeocluePositionFields fields; double lat, lon; GError *error = NULL; g_type_init (); / * create a MasterClient using Master * / master = geoclue_master_get_default (); client = geoclue_master_create_client (master, NULL, &error); g_object_unref (master); if (!client) { g_printerr ("Error creating GeoclueMasterClient"); g_error_free (error); return 1; }
  15. 15. 15 Components (9/10) / * Set our requirements: We want at least city level accuracy, require signals, and allow the use of network (but not e.g. GPS) * / if (!geoclue_master_client_set_requirements (client, GEOCLUE_ACCURACY_LEVEL_LOCALITY, 0, TRUE, GEOCLUE_RESOURCE_NETWORK, &error)) { g_printerr ("set_requirements failed: %s", error->message); g_error_free (error); g_object_unref (client); return 1; } / * Get a Position object * / pos = geoclue_master_client_create_position (client, NULL); if (!pos) { g_printerr ("Failed to get a position object"); g_object_unref (client); return 1; } / * call get_position. We do not know which provider actually provides the answer (although we could find out using MasterClient API) * / fields = geoclue_position_get_position (pos, NULL, &lat, &lon, NULL, NULL, &error); if (error) { g_printerr ("Error in geoclue_position_get_position: %s.n", error->message); g_error_free (error); error = NULL; } else { if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE && fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) { g_print ("We're at %.3f, %.3f.n", lat, lon); } } g_signal_connect (G_OBJECT (pos), "position-changed", G_CALLBACK (position_changed), NULL);
  16. 16. 16 Components (10/10) loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_main_loop_unref (loop); g_object_unref (pos); g_object_unref (client); return 0; }
  17. 17. 17 References GeoClue API http://folks.o-hand.com/jku/geoclue-docs Geoclue: Location Information Retrieval for Moblin 2.0 Linux http://software.intel.com/en-us/articles/geoclue-location- information- retrieval-for-moblin-20-linux/ http://software.intel.com/zh-cn/blogs/2009/03/11/moblin-sdk- geoclue/

×