gps 0.5.2 → 0.5.3
raw patch · 2 files changed
+12/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.GPS: heading :: (Lat a, Lon a) => a -> a -> Heading
Files
- Data/GPS.hs +11/−8
- gps.cabal +1/−1
Data/GPS.hs view
@@ -29,6 +29,7 @@ , west , radiusOfEarth -- * Helper Functions+ , heading , restLocations , closestDistance , getRadianPair@@ -47,7 +48,7 @@ import Data.Time import Data.Maybe (listToMaybe)-import Data.Fixed (mod')+import Data.Fixed -- |Distances are expressed in meters type Distance = Double@@ -75,6 +76,7 @@ (lat1, lon1) = getRadianPairD a (lat2, lon2) = getRadianPairD b +-- | 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 a b = atan2 (sin (diffLon) * cos (lat2)) @@ -220,7 +222,7 @@ in case first of Nothing -> [] Just f ->- let sorted = sortBy (comparing ((`mod'` (2*pi)). (+ pi/2). heading f)) (filter (/= f) xs)+ let sorted = sortBy (comparing (eastZeroHeading f)) (filter (/= f) xs) in case sorted of (a:b:cs) -> grahamScan (b:a:f:[]) cs cs -> f : cs@@ -234,16 +236,17 @@ Straight -> grahamScan (x:p2:p1:ps) xs _ -> grahamScan (p1:ps) (x:xs) +eastZeroHeading :: (Lat c, Lon c) => c -> c -> Heading+eastZeroHeading s = (`mod'` (2*pi)) . (+ pi/2) . heading s+ data Turn = LeftTurn | RightTurn | Straight deriving (Eq, Ord, Show, Read, Enum) turn :: (Lat c, Lon c) => c -> c -> c -> Turn turn a b c =- let h1 = heading a b- h2 = heading b c- in case compare (h2 - h1) 0 of- LT -> RightTurn- GT -> LeftTurn- EQ -> Straight+ let h1 = eastZeroHeading a b+ h2 = eastZeroHeading b c+ d = h2 - h1+ in if d >= 0 && d < pi then LeftTurn else RightTurn -- | Find the southmost point southMost :: (Lat c) => [c] -> Maybe c
gps.cabal view
@@ -1,5 +1,5 @@ name: gps-version: 0.5.2+version: 0.5.3 license: BSD3 license-file: LICENSE author: Thomas DuBuisson <thomas.dubuisson@gmail.com>