[libgweather/wip/hadess/serialisation-fix: 3/17] GWeatherLocation: Don't use a city as a weather station



commit a8cf7feb171c4917bb2229fbfa486e37e55ecfe0
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Oct 9 17:28:31 2018 +0200

    GWeatherLocation: Don't use a city as a weather station
    
    Don't use cities as the nearest weather station to another city, it
    makes no sense.

 libgweather/gweather-location.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index 976b8b9..da230f3 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -160,6 +160,9 @@ add_nearest_weather_station (GWeatherLocation *location)
         if (siblings[i] == location)
             continue;
 
+        if (siblings[i]->level != GWEATHER_LOCATION_WEATHER_STATION)
+            continue;
+
         /* Skip siblings without valid coordinates */
         if (!siblings[i]->latlon_valid)
             continue;
@@ -183,7 +186,7 @@ add_nearest_weather_station (GWeatherLocation *location)
     station->local_sort_name = g_strdup (closest->local_sort_name);
     station->english_sort_name = g_strdup (closest->english_sort_name);
     station->parent = location;
-    station->level = closest->level;
+    station->level = GWEATHER_LOCATION_WEATHER_STATION;
     station->country_code = g_strdup (closest->country_code);
     station->tz_hint = g_strdup (closest->tz_hint);
     station->station_code = g_strdup (closest->station_code);


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