[libgweather/wip/hadess/serialisation-fix: 4/17] GWeatherLocation: Fix nearest weather station distance calc
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/wip/hadess/serialisation-fix: 4/17] GWeatherLocation: Fix nearest weather station distance calc
- Date: Wed, 10 Oct 2018 12:52:39 +0000 (UTC)
commit 44ad9b033e35da77708ea78deba52c3b20633faf
Author: Bastien Nocera <hadess hadess net>
Date: Tue Oct 9 17:29:42 2018 +0200
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.
libgweather/gweather-location.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index da230f3..60c5c6e 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -168,8 +168,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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]