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



commit ad69e07e2b670b896fcce5e2c6e3e3929acde729
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 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index 3c2047e..5005965 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -163,6 +163,13 @@ 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;
+
         distance = gweather_location_get_distance (location, siblings[i]);
         if (distance < min_distance)
             closest = siblings[i];
@@ -182,7 +189,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]