Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Haversine geodetic distance algorithm.
- haversine :: (AsCoordinate (->) (Const Coordinate) start, AsCoordinate (->) (Const Coordinate) end) => Sphere -> start -> end -> Double
- haversineD :: (AsCoordinate (->) (Const Coordinate) start, AsCoordinate (->) (Const Coordinate) end) => start -> end -> Double
- haversine' :: Optional1 Sphere (Coordinate -> Coordinate -> Double) x => x
Documentation
:: (AsCoordinate (->) (Const Coordinate) start, AsCoordinate (->) (Const Coordinate) end) | |
=> Sphere | reference sphere |
-> start | start coordinate |
-> end | end coordinate |
-> Double |
Haversine algorithm.
>>>
fmap (printf "%0.4f") (do fr <- 27.812 <°> 154.295; to <- (-66.093) <°> 12.84; return (haversine earthMean fr to)) :: Maybe String
Just "15000950.5589"
>>>
fmap (printf "%0.4f") (do fr <- (-16.7889) <°> 41.935; to <- 6.933 <°> (-162.55); return (haversine earthMean fr to)) :: Maybe String
Just "17128743.0669"
>>>
fmap (printf "%0.4f") (do fr <- 27.812 <°> 154.295; to <- (-66.093) <°> 12.84; return (haversine ((6350000 :: Double) ^. _Sphere) fr to)) :: Maybe String
Just "14959840.4461"
>>>
fmap (printf "%0.4f") (do fr <- (-16.7889) <°> 41.935; to <- 6.933 <°> (-162.55); return (haversine ((6350000 :: Double) ^. _Sphere) fr to)) :: Maybe String
Just "17081801.7377"
:: (AsCoordinate (->) (Const Coordinate) start, AsCoordinate (->) (Const Coordinate) end) | |
=> start | start coordinate |
-> end | end coordinate |
-> Double |
Haversine algorithm with a default sphere of the earth mean.
>>>
fmap (printf "%0.4f") (do fr <- 27.812 <°> 154.295; to <- (-66.093) <°> 12.84; return (haversineD fr to)) :: Maybe String
Just "15000950.5589"
>>>
fmap (printf "%0.4f") (do fr <- (-16.7889) <°> 41.935; to <- 6.933 <°> (-162.55); return (haversineD fr to)) :: Maybe String
Just "17128743.0669"
haversine' :: Optional1 Sphere (Coordinate -> Coordinate -> Double) x => x Source
Haversine algorithm with an optionally applied default sphere of the earth mean.
>>>
fmap (printf "%0.4f") (do fr <- 27.812 <°> 154.295; to <- (-66.093) <°> 12.84; return (haversine' fr to :: Double)) :: Maybe String
Just "15000950.5589"
>>>
fmap (printf "%0.4f") (do fr <- (-16.7889) <°> 41.935; to <- 6.933 <°> (-162.55); return (haversine' fr to :: Double)) :: Maybe String
Just "17128743.0669"