add hr
This commit is contained in:
parent
a85a00762d
commit
6e4c1b7351
@ -12,6 +12,7 @@ type alias Point =
|
||||
, time : Maybe Time.Posix
|
||||
, power : Maybe Int
|
||||
, cadence : Maybe Int
|
||||
, hr : Maybe Int
|
||||
}
|
||||
|
||||
type alias Track = List Point
|
||||
@ -26,12 +27,13 @@ timeDecoder = XD.andThen (\ts ->
|
||||
|
||||
triple x y z = (x,y,z)
|
||||
|
||||
pointDecoder = XD.map4 Point
|
||||
pointDecoder = XD.map5 Point
|
||||
(XD.map3 triple (floatAttr "lat") (floatAttr "lon")
|
||||
(XD.maybe (path ["ele"] (single XD.float))))
|
||||
(XD.maybe (path ["time"] (single timeDecoder)))
|
||||
(XD.maybe (path ["extensions", "gpxtpx:TrackPointExtension", "pwr:PowerInWatts"] (single XD.int)))
|
||||
(XD.maybe (path ["extensions", "gpxtpx:TrackPointExtension", "gpxtpx:cad"] (single XD.int)))
|
||||
(XD.maybe (path ["extensions", "gpxtpx:TrackPointExtension", "gpxtpx:hr"] (single XD.int)))
|
||||
|
||||
|
||||
gpxDecoder =
|
||||
|
@ -70,17 +70,20 @@ threepoints_expected =
|
||||
(Just (Time.millisToPosix 1729669252256))
|
||||
(Just 89)
|
||||
(Just 110)
|
||||
Nothing
|
||||
)
|
||||
, (Point
|
||||
(51.600679, -0.018179, Just 65.5)
|
||||
(Just (Time.millisToPosix 1729669255259))
|
||||
(Just 86)
|
||||
(Just 111)
|
||||
Nothing
|
||||
)
|
||||
, (Point
|
||||
(51.600697, -0.018064, Just 66.2)
|
||||
(Just (Time.millisToPosix 1729669256231))
|
||||
(Just 86)
|
||||
(Just 111)
|
||||
Nothing
|
||||
)
|
||||
]
|
||||
|
@ -28,6 +28,19 @@ specs =
|
||||
(_, _, ele) -> Expect.equal ele Nothing
|
||||
Ok _ -> Expect.fail "empty list"
|
||||
(Err f) -> Expect.fail f
|
||||
, test "heart rate" <|
|
||||
\_ ->
|
||||
let
|
||||
xml = String.replace
|
||||
"</gpxtpx:TrackPointExtension>"
|
||||
"<gpxtpx:hr>97</gpxtpx:hr></gpxtpx:TrackPointExtension>"
|
||||
Fixtures.threepoints
|
||||
in
|
||||
case Track.parse xml of
|
||||
Ok (p::pts) ->
|
||||
Expect.equal p.hr (Just 97)
|
||||
Ok _ -> Expect.fail "no points"
|
||||
(Err f) -> Expect.fail f
|
||||
|
||||
, test "multiple trksegs are coalesced" <|
|
||||
\_ ->
|
||||
|
Loading…
Reference in New Issue
Block a user