hayai/seismo/seismo.go
2024-08-25 12:20:20 +02:00

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
}