mirror of
https://github.com/make-42/hayai.git
synced 2024-11-10 04:11:37 +01:00
15 lines
456 B
Go
15 lines
456 B
Go
package seismo
|
|
|
|
import (
|
|
"hayai/constants"
|
|
|
|
"github.com/jftuga/geodist"
|
|
)
|
|
|
|
func CalculateEquivalentMagnitude(earthquakeMagnitude float64, earthquakeLat, earthquakeLon, userLat, userLon float64) float64 {
|
|
var earthquake = geodist.Coord{Lat: earthquakeLat, Lon: earthquakeLon}
|
|
var user = geodist.Coord{Lat: userLat, Lon: userLon}
|
|
_, km, _ := geodist.VincentyDistance(earthquake, user)
|
|
return earthquakeMagnitude - km*constants.MagnitudeDecreasePerKM
|
|
}
|