parse cadence

This commit is contained in:
Daniel Barlow 2024-10-25 00:12:19 +01:00
parent 94a8987828
commit a85a00762d
2 changed files with 10 additions and 3 deletions

View File

@ -11,6 +11,7 @@ type alias Point =
{ loc : Position
, time : Maybe Time.Posix
, power : Maybe Int
, cadence : Maybe Int
}
type alias Track = List Point
@ -25,11 +26,12 @@ timeDecoder = XD.andThen (\ts ->
triple x y z = (x,y,z)
pointDecoder = XD.map3 Point
pointDecoder = XD.map4 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)))
gpxDecoder =

View File

@ -69,13 +69,18 @@ threepoints_expected =
(51.600643, -0.01856, Just 64.8)
(Just (Time.millisToPosix 1729669252256))
(Just 89)
(Just 110)
)
, (Point
(51.600679, -0.018179, Just 65.5)
(Just (Time.millisToPosix 1729669255259))
(Just 86))
(Just 86)
(Just 111)
)
, (Point
(51.600697, -0.018064, Just 66.2)
(Just (Time.millisToPosix 1729669256231))
(Just 86))
(Just 86)
(Just 111)
)
]