scan-flow: geolocation scan, location-aware SMS throttle (log sender), finder contact, sms_enabled toggle, branding — 19/19 phase-2 scenarios pass
This commit is contained in:
16
frontend/internal/sms/geo.go
Normal file
16
frontend/internal/sms/geo.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package sms
|
||||
|
||||
import "math"
|
||||
|
||||
const earthRadiusM = 6371000.0
|
||||
|
||||
// HaversineMeters returns the great-circle distance between two points
|
||||
// (lat/lng in decimal degrees) in metres.
|
||||
func HaversineMeters(lat1, lng1, lat2, lng2 float64) float64 {
|
||||
rad := func(d float64) float64 { return d * math.Pi / 180 }
|
||||
dLat := rad(lat2 - lat1)
|
||||
dLng := rad(lng2 - lng1)
|
||||
a := math.Sin(dLat/2)*math.Sin(dLat/2) +
|
||||
math.Cos(rad(lat1))*math.Cos(rad(lat2))*math.Sin(dLng/2)*math.Sin(dLng/2)
|
||||
return 2 * earthRadiusM * math.Asin(math.Sqrt(a))
|
||||
}
|
||||
Reference in New Issue
Block a user