[gnome-maps] Update to latest geocode-glib api



commit 8f39c8fb7e25838eecb5c6377598f0b9fee15ed7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Apr 3 16:34:23 2013 +0300

    Update to latest geocode-glib api
    
    accuracy is now:
    
    * a double value in meters
    * property of location instance itself

 src/mapView.js |   21 ++++++++++-----------
 src/utils.js   |   16 ++++++++--------
 2 files changed, 18 insertions(+), 19 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index e295a1a..08059f2 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -63,10 +63,10 @@ const MapView = new Lang.Class({
             }));
     },
 
-    _gotoLocation: function(location, accuracy, animate) {
+    _gotoLocation: function(location, animate) {
         log(location.description);
 
-        let zoom = Utils.getZoomLevelForAccuracy(accuracy);
+        let zoom = Utils.getZoomLevelForAccuracy(location.accuracy);
         this._view.set_zoom_level(zoom);
 
         if (animate)
@@ -81,15 +81,15 @@ const MapView = new Lang.Class({
             let lat = lastLocation.get_child_value(0);
             let lng = lastLocation.get_child_value(1);
 
+            // FIXME: We should keep the accuracy cached too but this type is soon going to change
+            //        from an enum to a double in geocode-glib so lets do it after that happens.
             let location = new Geocode.Location({ latitude: lat.get_double(),
-                                                  longitude: lng.get_double() });
+                                                  longitude: lng.get_double(),
+                                                  accuracy: Geocode.LOCATION_ACCURACY_CITY });
             let lastLocationDescription = Application.settings.get_string('last-location-description');
             location.set_description(lastLocationDescription);
-            // FIXME: We should keep the accuracy cached too but this type is soon going to change
-            //        from an enum to a double in geocode-glib so lets do it after that happens.
-            let accuracy = Geocode.LocationAccuracy.CITY;
 
-            this._gotoLocation(location, accuracy, false);
+            this._gotoLocation(location, false);
         }
 
         let ipclient = new Geocode.Ipclient();
@@ -97,9 +97,9 @@ const MapView = new Lang.Class({
         ipclient.search_async(null, Lang.bind(this,
             function(ipclient, res) {
                 try {
-                    let [location, accuracy] = ipclient.search_finish(res);
+                    let location = ipclient.search_finish(res);
 
-                    this._gotoLocation(location, accuracy, true);
+                    this._gotoLocation(location, true);
 
                     let variant = GLib.Variant.new('ad', [location.latitude, location.longitude]);
                     Application.settings.set_value('last-location', variant);
@@ -126,8 +126,7 @@ const MapView = new Lang.Class({
             }));
 
         if (locations.length == 1)
-            // FIXME: accuracy should come from geocode-glib
-            this._gotoLocation(locations[0], Geocode.LocationAccuracy.CITY, true);
+            this._gotoLocation(locations[0], true);
         else {
             let min_latitude = 90;
             let max_latitude = -90;
diff --git a/src/utils.js b/src/utils.js
index 40a2d3c..42d7888 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -59,18 +59,18 @@ function initActions(actionMap, simpleActionEntries) {
     });
 }
 
-// accuracy: Geocode.LocationAccuracy
+// accuracy: double value in meters
 function getZoomLevelForAccuracy(accuracy) {
-    switch (accuracy) {
-    case Geocode.LocationAccuracy.STREET:
+    if (accuracy <= Geocode.LOCATION_ACCURACY_STREET)
         return 18;
-    case Geocode.LocationAccuracy.CITY:
+    else if (accuracy <= Geocode.LOCATION_ACCURACY_CITY)
         return 13;
-    case Geocode.LocationAccuracy.REGION:
+    else if (accuracy <= Geocode.LOCATION_ACCURACY_REGION)
         return 10;
-    case Geocode.LocationAccuracy.COUNTRY:
+    else if (accuracy <= Geocode.LOCATION_ACCURACY_COUNTRY)
         return 6;
-    default:
+    else if (accuracy == Geocode.LOCATION_ACCURACY_UNKNOWN)
+        return 13; // Accuracy is usually city-level when unknown
+    else
         return 3;
-    }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]