diff options
author | Bastien Nocera <hadess@hadess.net> | 2018-10-09 17:28:31 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2018-10-18 12:13:07 +0200 |
commit | ad69e07e2b670b896fcce5e2c6e3e3929acde729 (patch) | |
tree | 2d59a4d75080589e31604930cb1e483582b70d37 | |
parent | f51ef766eda10a05df34afef0a1c7d4e85c5e77b (diff) | |
download | libgweather-ad69e07e2b670b896fcce5e2c6e3e3929acde729.tar.gz |
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.
-rw-r--r-- | libgweather/gweather-location.c | 9 |
1 files changed, 8 insertions, 1 deletions
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); |