Geodetic-0.1: Data/Geo/Coord.hs
-- | A coordinate on earth with a latitude and longitude.
module Data.Geo.Coord(
Coord,
(|.|),
(!.!),
(|..|),
radians'
) where
import Data.Geo.Latitude
import Data.Geo.Longitude
import Data.Geo.Radians
import Data.Geo.Accessor.Lat
import Data.Geo.Accessor.Lon
import Data.Geo.Accessor.Value
import Control.Applicative
import Control.Arrow
data Coord = Coord Latitude Longitude
deriving Eq
instance Lat Coord where
lat (Coord x _) = x
instance Lon Coord where
lon (Coord _ x) = x
instance Show Coord where
show = show . (value . lat &&& value . lon)
-- | Construct a coordinate with the given latitude and longitude.
(|.|) :: Latitude -> Longitude -> Coord
(|.|) = Coord
infixl 8 |.|
-- | -- | Construct a coordinate with the given latitude and longitude in degrees.
(!.!) :: Double -> Double -> Coord
(!.!) x y = latitude x |.| longitude y
infixl 8 !.!
-- | -- | Construct a coordinate with the given latitude and longitude in radians.
(|..|) :: Double -> Double -> Coord
(|..|) lat' lon' = fromRadians lat' |.| fromRadians lon'
infixl 8 |..|
-- | Convert the latitude and longitude of the given coordinate to radians.
radians' :: Coord -> (Double, Double)
radians' = radians <$> lat <*> lon