refactoring fmt + moving utils

This commit is contained in:
2023-10-20 13:47:51 +02:00
parent 6696cd3152
commit b7bba4cdaa
25 changed files with 71 additions and 91 deletions

View File

@@ -1,22 +0,0 @@
package utils
import "math"
func Haversine(lat1, lon1, lat2, lon2 float64) float64 {
// Radius of the Earth in kilometers
R := 6371.0
lat1 = lat1 * math.Pi / 180
lon1 = lon1 * math.Pi / 180
lat2 = lat2 * math.Pi / 180
lon2 = lon2 * math.Pi / 180
dlat := lat2 - lat1
dlon := lon2 - lon1
a := math.Sin(dlat/2)*math.Sin(dlat/2) + math.Cos(lat1)*math.Cos(lat2)*math.Sin(dlon/2)*math.Sin(dlon/2)
c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
distance := R * c
return distance
}