[gnome-maps/wip/mlundblad/photon-geocode: 4/14] utils: Add function to get country of coordinates



commit 6f65e0b80b909e2fee53cdc5b15b657877ec219c
Author: Marcus Lundblad <ml update uu se>
Date:   Sun Jun 2 17:26:55 2019 +0200

    utils: Add function to get country of coordinates
    
    Gets country/territory code corrisponding to
    given coordinates.

 src/utils.js | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/src/utils.js b/src/utils.js
index f4e6dfb..2407e3c 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -26,6 +26,7 @@ const GdkPixbuf = imports.gi.GdkPixbuf;
 const Geocode = imports.gi.GeocodeGlib;
 const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
+const GWeather = imports.gi.GWeather;
 const Soup = imports.gi.Soup;
 const ByteArray = imports.byteArray;
 
@@ -368,3 +369,10 @@ function getBufferText(buffer) {
         return buffer.toString();
     }
 }
+
+function getCountryCodeForCoordinates(lat, lon) {
+    let location = GWeather.Location.new_detached('', null, lat, lon);
+
+    return location.get_country();
+}
+


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