From b9c0a6d411ada7586abd88c14b1fb7cd985470ed Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Thu, 14 Mar 2024 18:59:11 +0100 Subject: [PATCH] Update Location.cs --- MapControl/Shared/Location.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MapControl/Shared/Location.cs b/MapControl/Shared/Location.cs index 1d8ceef0..c4202ee2 100644 --- a/MapControl/Shared/Location.cs +++ b/MapControl/Shared/Location.cs @@ -3,6 +3,7 @@ // Licensed under the Microsoft Public License (Ms-PL) using System; +using System.Diagnostics; using System.Globalization; namespace MapControl @@ -107,7 +108,8 @@ namespace MapControl var cosLon12 = Math.Cos(lon2 - lon1); var a = cosLat1 * sinLat2 - sinLat1 * cosLat2 * cosLon12; var b = cosLat2 * sinLon12; - var s12 = Math.Atan2(Math.Sqrt(a * a + b * b), sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosLon12); + var c = sinLat1 * sinLat2 + cosLat1 * cosLat2 * cosLon12; + var s12 = Math.Atan2(Math.Sqrt(a * a + b * b), c); return earthRadius * s12; }