[libgweather/wip/hadess/3.28.3: 7/10] GWeatherLocation: Fix nearest weather station distance calc



commit 624ce37addd5f3ccf82693043e5fcf68b16636b9
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 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) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]