Trail Edit / Waypoints from photos: prevent creating different waypoints for near-by locations (#457)
* 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>
This commit is contained in:
14
db/util/geo.go
Normal file
14
db/util/geo.go
Normal file
@@ -0,0 +1,14 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user