[libgweather] GWeatherLocation: Additional fix for deserializing a city



commit b1210a844d6237885a8c75f167de5717ff6b7c38
Author: Yanko Kaneti <yaneti declera com>
Date:   Tue Jun 11 13:27:29 2019 +0300

    GWeatherLocation: Additional fix for deserializing a city
    
    Since weather stations are no longer attached to cities, deserializing
    cities with weather stations in format two leads to a location
    pointing to the weather station and missing a timezone.
    Try first to find the city by name and coordinates.

 libgweather/gweather-location.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index 612a03e..ce56617 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -1513,6 +1513,17 @@ gweather_location_common_deserialize (GWeatherLocation *world,
     GList *candidates, *l;
     GWeatherLocation *found;
 
+    /* Since weather stations are no longer attached to cities, first try to
+       find what claims to be a city by name and coordinates */
+    if (is_city && latitude && longitude) {
+        found = gweather_location_find_nearest_city (world,
+                                                     latitude / M_PI * 180.0,
+                                                     longitude / M_PI * 180.0);
+        if (found && (g_strcmp0 (name, found->english_name) == 0 ||
+                      g_strcmp0 (name, found->local_name) == 0))
+           return gweather_location_ref (found);
+    }
+
     if (station_code[0] == '\0')
         return _gweather_location_new_detached (NULL, name, latlon_valid, latitude, longitude);
 


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