summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2018-10-09 17:29:42 +0200
committerBastien Nocera <hadess@hadess.net>2019-02-22 17:38:42 +0100
commit624ce37addd5f3ccf82693043e5fcf68b16636b9 (patch)
tree265ac5ddc16f46020a2725587291688c030c42ed
parent6e6a1da4739c936ef0cb0f3ddc029485b9857436 (diff)
downloadlibgweather-624ce37addd5f3ccf82693043e5fcf68b16636b9.tar.gz
GWeatherLocation: Fix nearest weather station distance calc
The code would fail to update min_distance (the distance to the selected nearest weather station), so the loop would instead select the last sibling as the closest weather station.
-rw-r--r--libgweather/gweather-location.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index c09c704..9f9a840 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -164,8 +164,10 @@ add_nearest_weather_station (GWeatherLocation *location)
continue;
distance = gweather_location_get_distance (location, siblings[i]);
- if (distance < min_distance)
+ if (distance < min_distance) {
closest = siblings[i];
+ min_distance = distance;
+ }
}
if (!closest) {