With that being said, I'm getting an Error Message in the line that holds "c := 2 * ATan(Sqrt(a), Sqrt(1-a))" saying "==> Too many parameters passed to function."
Anybody know how to reconcile this error, and still have it work?
Website Reference: https://stackoverflow.com/questions/365826/calculate-distance-between-2-gps-coordinates
Code: Select all
degreesToRadians(degrees)
{
return degrees * pi/180
}
distanceInMilesBetweenEarthCoordinates(lat1, lon1, lat2, lon2)
{
earthRadiusMiles=3959
dLat := degreesToRadians(lat2-lat1)
dLon := degreesToRadians(lon2-lon1)
lat1 := degreesToRadians(lat1)
lat2 := degreesToRadians(lat2)
a := Sin(dLat/2) * Sin(dLat/2) + Sin(dLon2) * Sin(dLon2) * Cos(lat1) * Cos(lat2)
c := 2 * ATan(Sqrt(a), Sqrt(1-a))
return earthRadiusMiles * c
}