Created
January 29, 2010 10:56
-
-
Save anonymous/289645 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Geo.Radians | |
import Time | |
radius = 6371 | |
distance :: Double -> Double -> Double -> Double -> Double | |
distance latA lngA latB lngB = result | |
where | |
latAr = toRadians latA | |
lngAr = toRadians lngA | |
latBr = toRadians latB | |
lngBr = toRadians lngB | |
deltaLat = latBr - latAr | |
deltaLng = lngBr - lngAr | |
result = radius * 2 * (asin (sqrt (sin $ deltaLat/2.0) ** 2.0 + (cos latAr) * | |
(cos latBr) * | |
(sin $ (deltaLng / 2.0) ** 2.0))) | |
main = do | |
let rangeLat = [-90, -87.5 .. 90] | |
let rangeLng = [-180, -177.5 .. 180] | |
let result = [distance j k l m | j <- rangeLat, k <- rangeLng, l <- rangeLat, m <- rangeLng] | |
print $ take 4 result -- just to make sure it's doing something. | |
print $ last result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment