34 lines
726 B
Elm
34 lines
726 B
Elm
|
module Point exposing(Pos, Point, decoder)
|
||
|
|
||
|
import Json.Decode as D
|
||
|
|
||
|
type alias Pos =
|
||
|
{ lat : Float
|
||
|
, lon : Float
|
||
|
, ele : Maybe Float
|
||
|
}
|
||
|
|
||
|
|
||
|
type alias Point =
|
||
|
{ time : Float
|
||
|
, pos : Pos
|
||
|
, cadence : Maybe Int
|
||
|
, power : Maybe Int
|
||
|
, heartRate : Maybe Int
|
||
|
}
|
||
|
|
||
|
posDecoder : D.Decoder Pos
|
||
|
posDecoder = D.map3 Pos
|
||
|
(D.field "lat" D.float)
|
||
|
(D.field "lon" D.float)
|
||
|
(D.field "ele" (D.maybe D.float))
|
||
|
|
||
|
|
||
|
decoder : D.Decoder Point
|
||
|
decoder = D.map5 Point
|
||
|
(D.field "time" D.float)
|
||
|
(D.field "pos" posDecoder)
|
||
|
(D.field "cadence" (D.maybe D.int))
|
||
|
(D.field "power" (D.maybe D.int))
|
||
|
(D.field "heartRate" (D.maybe D.int))
|