[libgweather/wip/hadess/serialisation-fix: 4/17] GWeatherLocation: Fix nearest weather station distance calc



commit 912f1a4dccf80d9ebd9ae7b1d47266fd120fdcf9
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]