commit a85a00762d57451463a41c774e2206715c705a9c
parent 94a89878282e3c2db367faca408e4f5be4b65a82
Author: Daniel Barlow <dan@telent.net>
Date: Fri, 25 Oct 2024 00:12:19 +0100
parse cadence
Diffstat:
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/Track.elm b/src/Track.elm
@@ -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 =
diff --git a/tests/Fixtures.elm b/tests/Fixtures.elm
@@ -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)
+ )
]