[libgweather/wip/hadess/3.28.3: 9/10] GWeatherLocation: Fix distance for loc1 == loc2
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/wip/hadess/3.28.3: 9/10] GWeatherLocation: Fix distance for loc1 == loc2
- Date: Fri, 22 Feb 2019 16:45:06 +0000 (UTC)
commit 0957f1b42a986f780a56f0beacd53f8586a7c4d3
Author: Bastien Nocera <hadess hadess net>
Date: Tue Oct 9 18:04:45 2018 +0200
GWeatherLocation: Fix distance for loc1 == loc2
If the coordinates for the 2 sets of coordinates are exactly the same,
the returned distance between the 2 would have been "nan" instead of
0.0, such as for Bamboo and its airport.
libgweather/gweather-location.c | 3 +++
1 file changed, 3 insertions(+)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index cb3710e..7e6982c 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -678,6 +678,9 @@ location_distance (double lat1, double long1,
/* average radius of the earth in km */
static const double radius = 6372.795;
+ if (lat1 == lat2 && long1 == long2)
+ return 0.0;
+
return acos (cos (lat1) * cos (lat2) * cos (long1 - long2) +
sin (lat1) * sin (lat2)) * radius;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]