Compare commits

..

No commits in common. "cf6d4cf9c0c38dd2ade3c578d4c32b1504b88de4" and "7b8e07d3baacaa57e1cf7d0d5370f534af72cecb" have entirely different histories.

3 changed files with 7 additions and 22 deletions

View File

@ -8,8 +8,8 @@ import Iso8601
type alias Point = type alias Point =
{ lat : Float { lat : Float
, lon : Float , lon : Float
, ele : Maybe Float , ele : Float
, time : Maybe Time.Posix , time : Time.Posix
} }
type alias Track = List Point type alias Track = List Point
@ -25,8 +25,8 @@ timeDecoder = XD.andThen (\ts ->
pointDecoder = XD.map4 Point pointDecoder = XD.map4 Point
(floatAttr "lat") (floatAttr "lat")
(floatAttr "lon") (floatAttr "lon")
(XD.maybe (path ["ele"] (single XD.float))) (path ["ele"] (single XD.float))
(XD.maybe (path ["time"] (single timeDecoder))) (path ["time"] (single timeDecoder))
gpxDecoder = gpxDecoder =

View File

@ -1,7 +1,6 @@
module Fixtures exposing (threepoints, threepoints_expected) module Fixtures exposing (threepoints, threepoints_expected)
import Track exposing (Track, Point) import Track exposing (Track, Point)
import Time import Time
import Maybe
threepoints = """ threepoints = """
@ -65,7 +64,7 @@ xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/
""" """
threepoints_expected = threepoints_expected =
[ (Point 51.600643 -0.01856 (Just 64.8) (Just (Time.millisToPosix 1729669252256))) [ (Point 51.600643 -0.01856 64.8 (Time.millisToPosix 1729669252256))
, (Point 51.600679 -0.018179 (Just 65.5) (Just (Time.millisToPosix 1729669255259))) , (Point 51.600679 -0.018179 65.5 (Time.millisToPosix 1729669255259))
, (Point 51.600697 -0.018064 (Just 66.2) (Just (Time.millisToPosix 1729669256231))) , (Point 51.600697 -0.018064 66.2 (Time.millisToPosix 1729669256231))
] ]

View File

@ -4,7 +4,6 @@ import Fixtures
import Track exposing (Track, Point) import Track exposing (Track, Point)
import Test exposing (..) import Test exposing (..)
import Expect exposing (Expectation) import Expect exposing (Expectation)
import Time
specs: Test specs: Test
specs = specs =
@ -14,19 +13,6 @@ specs =
case Track.parse Fixtures.threepoints of case Track.parse Fixtures.threepoints of
(Ok trk) -> Expect.equalLists Fixtures.threepoints_expected trk (Ok trk) -> Expect.equalLists Fixtures.threepoints_expected trk
_ -> Expect.fail "not ok" _ -> Expect.fail "not ok"
, test "missing child ele node in track point" <|
\_ ->
let
xml = String.replace
"<ele>64.8</ele>"
""
Fixtures.threepoints
in
case Track.parse xml of
Ok (p::pts) -> Expect.equal p (Point 51.600643 -0.01856 Nothing (Just (Time.millisToPosix 1729669252256)))
Ok _ -> Expect.fail "empty list"
(Err f) -> Expect.fail f
, test "multiple trksegs are coalesced" <| , test "multiple trksegs are coalesced" <|
\_ -> \_ ->
let let