coordinate 0.0.16 → 0.0.17
raw patch · 9 files changed
+78/−9 lines, 9 filesdep +radianPVP ok
version bump matches the API change (PVP)
Dependencies added: radian
API changes (from Hackage documentation)
+ Data.Geo.Coordinate.Latitude: instance (Choice p, Applicative f) => AsLatitude p f (Radian Double)
+ Data.Geo.Coordinate.Longitude: instance (Choice p, Applicative f) => AsLongitude p f (Radian Double)
Files
- LICENCE +1/−1
- changelog +8/−0
- coordinate.cabal +3/−2
- src/Data/Geo/Coordinate/DegreesLatitude.hs +1/−1
- src/Data/Geo/Coordinate/DegreesLongitude.hs +1/−1
- src/Data/Geo/Coordinate/Latitude.hs +31/−1
- src/Data/Geo/Coordinate/Longitude.hs +31/−1
- src/Data/Geo/Coordinate/Minutes.hs +1/−1
- src/Data/Geo/Coordinate/Seconds.hs +1/−1
LICENCE view
@@ -1,4 +1,4 @@-Copyright 2013-2014 NICTA Pty Ltd+Copyright 2013-2014 NICTA Limited All rights reserved.
changelog view
@@ -1,3 +1,11 @@+0.0.17++* Include prisms for radians. Requires a dependency on the `radian` package.++0.0.16++* Some minor fixes to the documentation.+ 0.0.15 * Change mod functions to use rem.
coordinate.cabal view
@@ -1,10 +1,10 @@ name: coordinate-version: 0.0.16+version: 0.0.17 license: BSD3 license-file: LICENCE author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> maintainer: Tony Morris-copyright: Copyright (C) 2013-2014 NICTA Pty Ltd+copyright: Copyright (C) 2013-2014 NICTA Limited synopsis: A representation of latitude and longitude category: Development description: @@ -33,6 +33,7 @@ , lens >= 4.0 , tagged >= 0.7 , transformers >= 0.3.0.0+ , radian >= 0.0.1 ghc-options: -Wall
src/Data/Geo/Coordinate/DegreesLatitude.hs view
@@ -64,7 +64,7 @@ then Just (DegreesLatitude i) else Nothing) --- | Setting a value `>= 90` will get that value `(`rem` 90)`.+-- | Setting a value @>= 90@ will get that value @(`rem` 90)@. -- -- >>> remDegreesLatitude 7 -- DegreesLatitude 7
src/Data/Geo/Coordinate/DegreesLongitude.hs view
@@ -64,7 +64,7 @@ then Just (DegreesLongitude i) else Nothing) --- | Setting a value `>= 180` will get that value `(`rem` 180)`.+-- | Setting a value @>= 180@ will get that value @(`rem` 180)@. -- -- >>> remDegreesLongitude 7 -- DegreesLongitude 7
src/Data/Geo/Coordinate/Latitude.hs view
@@ -9,7 +9,7 @@ ) where import Control.Applicative(Applicative)-import Control.Category(Category(id))+import Control.Category(Category(id, (.))) import Control.Lens(Choice, Profunctor, Optic', iso, prism', lens, (#), (^?)) import Control.Monad(Monad(return)) import Data.Eq(Eq)@@ -18,6 +18,7 @@ import Data.Geo.Coordinate.Minutes(AsMinutes(_Minutes), Minutes) import Data.Geo.Coordinate.Seconds(AsSeconds(_Seconds), Seconds) import Data.Ord(Ord((<)))+import Data.Radian(Radian, radians) import Prelude(Double, Show, Int, Num((+), (*), (-), abs), Fractional((/)), properFraction, fromIntegral) -- $setup@@ -123,6 +124,35 @@ m' <- (abs m :: Int) ^? _Minutes s' <- (abs s * 60) ^? _Seconds return (Latitude d' m' s'))++-- | A prism on latitude to a double between -π2 and π2 exclusive. +--+-- >>> (0.2 :: Radian Double) ^? _Latitude+-- Just (Latitude (DegreesLatitude 11) (Minutes 27) (Seconds 32.9612))+--+-- >>> (1.3 :: Radian Double) ^? _Latitude+-- Just (Latitude (DegreesLatitude 74) (Minutes 29) (Seconds 4.2481))+--+-- >>> (-1.3 :: Radian Double) ^? _Latitude+-- Just (Latitude (DegreesLatitude (-74)) (Minutes 29) (Seconds 4.2481))+--+-- >>> (1.5707963 :: Radian Double) ^? _Latitude+-- Just (Latitude (DegreesLatitude 89) (Minutes 59) (Seconds 59.9945))+--+-- >>> (1.58 :: Radian Double) ^? _Latitude+-- Nothing+--+-- >>> (-1.58 :: Radian Double) ^? _Latitude+-- Nothing+--+-- >>> fmap (\x -> _Latitude # x :: Radian Double) (do deg <- (7 :: Int) ^? _DegreesLatitude; min <- (7 :: Int) ^? _Minutes; sec <- (7 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude)+-- Just (Radian 0.12424320205794079)+--+-- >>> fmap (\x -> _Latitude # x :: Radian Double) (do deg <- (89 :: Int) ^? _DegreesLatitude; min <- (15 :: Int) ^? _Minutes; sec <- (6 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude)+-- Just (Radian 1.5577354462258055)+instance (Choice p, Applicative f) => AsLatitude p f (Radian Double) where+ _Latitude =+ radians . _Latitude instance (p ~ (->), Functor f) => AsDegreesLatitude p f Latitude where _DegreesLatitude =
src/Data/Geo/Coordinate/Longitude.hs view
@@ -9,7 +9,7 @@ ) where import Control.Applicative(Applicative)-import Control.Category(Category(id))+import Control.Category(Category(id, (.))) import Control.Lens(Choice, Profunctor, Optic', iso, prism', lens, (#), (^?)) import Control.Monad(Monad(return)) import Data.Eq(Eq)@@ -18,6 +18,7 @@ import Data.Geo.Coordinate.Minutes(AsMinutes(_Minutes), Minutes) import Data.Geo.Coordinate.Seconds(AsSeconds(_Seconds), Seconds) import Data.Ord(Ord((<)))+import Data.Radian(Radian, radians) import Prelude(Double, Show, Int, Num((+), (*), (-), abs), Fractional((/)), properFraction, fromIntegral) -- $setup@@ -123,6 +124,35 @@ m' <- (abs m :: Int) ^? _Minutes s' <- (abs s * 60) ^? _Seconds return (Longitude d' m' s'))++-- | A prism on longitude to a double between -π and π exclusive.+--+-- >>> (0.2 :: Radian Double) ^? _Longitude+-- Just (Longitude (DegreesLongitude 11) (Minutes 27) (Seconds 32.9612))+--+-- >>> (1.3 :: Radian Double) ^? _Longitude+-- Just (Longitude (DegreesLongitude 74) (Minutes 29) (Seconds 4.2481))+--+-- >>> (-1.3 :: Radian Double) ^? _Longitude+-- Just (Longitude (DegreesLongitude (-74)) (Minutes 29) (Seconds 4.2481))+--+-- >>> (3.14159 :: Radian Double) ^? _Longitude+-- Just (Longitude (DegreesLongitude 179) (Minutes 59) (Seconds 59.4527))+--+-- >>> (3.15 :: Radian Double) ^? _Longitude+-- Nothing+--+-- >>> (-3.15 :: Radian Double) ^? _Longitude+-- Nothing+--+-- >>> fmap (\x -> _Longitude # x :: Radian Double) (do deg <- (7 :: Int) ^? _DegreesLongitude; min <- (7 :: Int) ^? _Minutes; sec <- (7 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude)+-- Just (Radian 0.12424320205794079)+--+-- >>> fmap (\x -> _Longitude # x :: Radian Double) (do deg <- (179 :: Int) ^? _DegreesLongitude; min <- (15 :: Int) ^? _Minutes; sec <- (6 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude)+-- Just (Radian 3.1285317730207023)+instance (Choice p, Applicative f) => AsLongitude p f (Radian Double) where+ _Longitude =+ radians . _Longitude instance (p ~ (->), Functor f) => AsDegreesLongitude p f Longitude where _DegreesLongitude =
src/Data/Geo/Coordinate/Minutes.hs view
@@ -58,7 +58,7 @@ then Just (Minutes i) else Nothing) --- | Setting a value `>= 60` will get that value `(`rem` 60)`.+-- | Setting a value @>= 60@ will get that value @(`rem` 60)@. -- -- >>> remMinutes 7 -- Minutes 7
src/Data/Geo/Coordinate/Seconds.hs view
@@ -71,7 +71,7 @@ then Just (Seconds d) else Nothing) --- | Setting a value `>= 60` will get that value `(`rem` 60)`.+-- | Setting a value @>= 60@ will get that value @(`rem` 60)@. -- -- >>> remSeconds 7 -- Seconds 7.0000