[libgweather/wip/hadess/serialisation-fix-stable: 8/13] GWeatherLocation: Fix nearest weather station distance calc



commit 0176be3b406eaa88f6cf0c6480d5a687a900127b
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 5005965..46118a0 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -171,8 +171,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]