Upstream sync
This commit is contained in:
@@ -4,7 +4,28 @@
|
||||
|
||||
package shared
|
||||
|
||||
import "math"
|
||||
|
||||
const (
|
||||
RoleAdmin string = "admin"
|
||||
RoleProUser string = "pro-user"
|
||||
)
|
||||
|
||||
func DistanceKm(lat1 float64, lng1 float64, lat2 float64, lng2 float64) float64 {
|
||||
radlat1 := float64(math.Pi * lat1 / 180)
|
||||
radlat2 := float64(math.Pi * lat2 / 180)
|
||||
|
||||
theta := float64(lng1 - lng2)
|
||||
radtheta := float64(math.Pi * theta / 180)
|
||||
|
||||
dist := math.Sin(radlat1)*math.Sin(radlat2) + math.Cos(radlat1)*math.Cos(radlat2)*math.Cos(radtheta)
|
||||
if dist > 1 {
|
||||
dist = 1
|
||||
}
|
||||
|
||||
dist = math.Acos(dist)
|
||||
dist = dist * 180 / math.Pi
|
||||
dist = dist * 60 * 1.1515
|
||||
|
||||
return dist * 1.609344
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user