Last active
April 29, 2024 13:20
-
-
Save ahmadmahboubi/499db76fdcd2b3ce6de6246fc126552f to your computer and use it in GitHub Desktop.
Revisions
-
ahmadmahboubi renamed this gist
Apr 29, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ahmadmahboubi created this gist
Apr 29, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ private double HaversineDistance(Coordinates point1, Coordinates point2) { const double EarthRadiusKm = 6371; var dLat = Math.PI * ((double)point2.Latitude - (double)point1.Latitude) / 180.0; var dLon = Math.PI * ((double)point2.Longitude - (double)point1.Longitude) / 180.0; var a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) + Math.Cos(Math.PI * (double)point1.Latitude / 180.0) * Math.Cos(Math.PI * (double)point2.Latitude / 180.0) * Math.Sin(dLon / 2) * Math.Sin(dLon / 2); var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); var distance = EarthRadiusKm * c; return distance; }