gps 0.6 → 0.6.2
raw patch · 2 files changed
+9/−10 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.GPS: distance :: (Lat a, Lon a) => a -> a -> Distance
+ Data.GPS: distance :: (Lat a, Lon a, Lat b, Lon b) => a -> b -> Distance
- Data.GPS: heading :: (Lat a, Lon a) => a -> a -> Heading
+ Data.GPS: heading :: (Lat a, Lon a, Lat b, Lon b) => a -> b -> Heading
- Data.GPS: speed :: (Lat loc, Lon loc, Time loc) => loc -> loc -> Maybe Speed
+ Data.GPS: speed :: (Lat loc, Lon loc, Time loc, Lat b, Lon b, Time b) => loc -> b -> Maybe Speed
Files
- Data/GPS.hs +8/−9
- gps.cabal +1/−1
Data/GPS.hs view
@@ -67,9 +67,11 @@ getUTCTime :: (Lat a, Lon a, Time a) => a -> Maybe UTCTime getUTCTime = fmap toUTCTime . time -distance :: (Lat a, Lon a) => a -> a -> Distance+distance :: (Lat a, Lon a, Lat b, Lon b) => a -> b -> Distance distance a b =- radiusOfEarth * acos( sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1) )+ let x = sin lat1 * sin lat2 + cos lat1 * cos lat2 * cos (lon2 - lon1)+ x' = if x > 1 then 1 else x+ in radiusOfEarth * acos x' where (lat1, lon1) = getRadianPairD a (lat2, lon2) = getRadianPairD b@@ -79,7 +81,7 @@ totalDistance as = sum $ zipWith distance as (drop 1 as) -- | Direction two points aim toward (0 = North, pi/2 = West, pi = South, 3pi/2 = East)-heading :: (Lat a, Lon a) => a -> a -> Heading -- ^ 0 = North, pi/2 = West...+heading :: (Lat a, Lon a, Lat b, Lon b) => a -> b -> Heading -- ^ 0 = North, pi/2 = West... heading a b = atan2 (sin (diffLon) * cos (lat2)) (cos(lat1) * sin (lat2) - sin(lat1) * cos lat2 * cos (diffLon))@@ -88,11 +90,11 @@ (lat2, lon2) = getRadianPairD b diffLon = lon1 - lon2 -getVector :: (Lat a, Lon a) => a -> a -> Vector+getVector :: (Lat a, Lon a, Lat b, Lon b) => a -> b -> Vector getVector a b = (distance a b, heading a b) -- | Speed in meters per second, only if a 'Time' was recorded for each waypoint.-speed :: (Lat loc, Lon loc, Time loc) => loc -> loc -> Maybe Speed+speed :: (Lat loc, Lon loc, Time loc, Lat b, Lon b, Time b) => loc -> b -> Maybe Speed speed a b = case (getUTCTime b, getUTCTime a) of (Just x, Just y) -> Just $ realToFrac (diffUTCTime x y) / (distance a b)@@ -156,10 +158,7 @@ -- |Provides a lat/lon pair of doubles in radians getRadianPair :: (Lat p, Lon p) => p -> (LatitudeType, LongitudeType)-getRadianPair p = (t, g)- where- t = toRadians (lat p)- g = toRadians (lon p)+getRadianPair p = (toRadians (lat p), toRadians (lon p)) toRadians :: Floating f => f -> f toRadians = (*) (pi / 180)
gps.cabal view
@@ -1,5 +1,5 @@ name: gps-version: 0.6+version: 0.6.2 license: BSD3 license-file: LICENSE author: Thomas DuBuisson <thomas.dubuisson@gmail.com>