* trail edit / waypoints from photos: prevent creating different waypoints for near-by locations * remove not necessary imports * remove changes from gitignore * patch gitignore * waypoint merge radius as category property * change datamodel for merge radius (use more generic settings field for future implementations) * fix npm run check issues * several improvements/fixes * fix * move geo cluster code to db * fix compile issue * fix docker issue * merge with existing waypoints --------- Co-authored-by: Christian Beutel <> Co-authored-by: Flomp <Flomp@users.noreply.github.com>
15 lines
454 B
Go
15 lines
454 B
Go
package util
|
|
|
|
import "math"
|
|
|
|
func HaversineDistance(lat1 float64, lon1 float64, lat2 float64, lon2 float64) float64 {
|
|
const earthRadiusKm = 6371
|
|
dLat := (lat2 - lat1) * (math.Pi / 180)
|
|
dLon := (lon2 - lon1) * (math.Pi / 180)
|
|
a := math.Sin(dLat/2)*math.Sin(dLat/2) +
|
|
math.Cos(lat1*(math.Pi/180))*math.Cos(lat2*(math.Pi/180))*
|
|
math.Sin(dLon/2)*math.Sin(dLon/2)
|
|
c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a))
|
|
return earthRadiusKm * c * 1000
|
|
}
|