23 lines
459 B
Elm
23 lines
459 B
Elm
|
module Track exposing (Track, parse)
|
||
|
|
||
|
import Result
|
||
|
import Xml.Decode as XD exposing (path, single, list, float)
|
||
|
|
||
|
|
||
|
type alias Point =
|
||
|
{ lat : Float
|
||
|
, lon : Float
|
||
|
}
|
||
|
|
||
|
type alias Track = List Point
|
||
|
|
||
|
pointDecoder = XD.map2 Point
|
||
|
(XD.path ["ele"] (single float))
|
||
|
(XD.path ["ele"] (single float))
|
||
|
|
||
|
gpxDecoder =
|
||
|
(XD.path [ "trk", "trkseg", "trkpt" ] (XD.list pointDecoder))
|
||
|
|
||
|
|
||
|
parse str = XD.run gpxDecoder str
|