make elevation part of Position
this reverses the change made in 64470309
when it hadn't occured to
me that the members of a tuple can have different types
This commit is contained in:
parent
5b827ed6ed
commit
7860a189b3
@ -5,7 +5,6 @@ module Track
|
||||
Pos (..),
|
||||
BadFile,
|
||||
pos,
|
||||
elevation,
|
||||
cadence,
|
||||
power,
|
||||
heartRate,
|
||||
@ -29,7 +28,7 @@ import Debug.Trace (trace, traceShow)
|
||||
import Text.XML
|
||||
import Text.XML.Cursor as Cursor
|
||||
import Text.Read (readMaybe)
|
||||
data Pos = Pos Float Float deriving (Show, Eq)
|
||||
data Pos = Pos Float Float (Maybe Float) deriving (Show, Eq)
|
||||
|
||||
type Power = Maybe Int
|
||||
|
||||
@ -39,7 +38,6 @@ type HeartRate = Maybe Int
|
||||
|
||||
data Point = Point
|
||||
{ pos :: Pos,
|
||||
elevation :: Maybe Float,
|
||||
time :: UTCTime,
|
||||
cadence :: Cadence,
|
||||
power :: Power,
|
||||
@ -86,8 +84,7 @@ elToPoint c =
|
||||
then
|
||||
Right $
|
||||
Point
|
||||
(Pos (fromJust lat) (fromJust lon))
|
||||
(ele >>= asFloat)
|
||||
(Pos (fromJust lat) (fromJust lon) (ele >>= asFloat))
|
||||
(fromJust ts)
|
||||
(listToMaybe cadence >>= asInt)
|
||||
(listToMaybe power >>= asInt)
|
||||
|
@ -111,16 +111,29 @@ testMissingAttrs =
|
||||
|
||||
|
||||
test2 =
|
||||
TestList [
|
||||
TestCase $
|
||||
either
|
||||
(assertFailure . displayException)
|
||||
( \(p : _) ->
|
||||
assertEqual
|
||||
"matches lat/lon"
|
||||
(Track.Pos 51.0 (-0.1))
|
||||
(Track.Pos 51.0 (-0.1) Nothing)
|
||||
(Track.pos p)
|
||||
)
|
||||
(Track.parse onepoint)
|
||||
(Track.parse onepoint),
|
||||
TestCase $
|
||||
either
|
||||
(assertFailure . displayException)
|
||||
( \(p : _) ->
|
||||
assertEqual
|
||||
"matches lat/lon"
|
||||
(Track.Pos 51.0 (-0.1) (Just 25.2))
|
||||
(Track.pos p)
|
||||
)
|
||||
(Track.parse onepointWithAttrs)
|
||||
]
|
||||
|
||||
|
||||
test3 =
|
||||
TestCase $
|
||||
@ -130,7 +143,7 @@ test3 =
|
||||
assertEqual
|
||||
"handles missing attributes"
|
||||
(Nothing, Nothing)
|
||||
(Track.elevation p, Track.cadence p)
|
||||
(Track.power p, Track.cadence p)
|
||||
)
|
||||
(Track.parse onepoint)
|
||||
|
||||
@ -141,8 +154,8 @@ test4 =
|
||||
( \(p : _) ->
|
||||
assertEqual
|
||||
"handles attributes"
|
||||
(Just 25.2, Just 128, Just 55, Data.Time.UTCTime (toEnum 60606) 27299.779, Just 160)
|
||||
(Track.elevation p, Track.cadence p, Track.power p, Track.time p, Track.heartRate p)
|
||||
(Just 128, Just 55, Data.Time.UTCTime (toEnum 60606) 27299.779, Just 160)
|
||||
(Track.cadence p, Track.power p, Track.time p, Track.heartRate p)
|
||||
)
|
||||
(Track.parse onepointWithAttrs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user