extract Position from the Point type
This commit is contained in:
parent
cf6d4cf9c0
commit
086664f8fb
@ -5,10 +5,10 @@ import Xml.Decode as XD exposing (path, list, single, floatAttr, stringAttr)
|
||||
import Time
|
||||
import Iso8601
|
||||
|
||||
type alias Position = (Float, Float, Maybe Float) -- lat, lon, ele
|
||||
|
||||
type alias Point =
|
||||
{ lat : Float
|
||||
, lon : Float
|
||||
, ele : Maybe Float
|
||||
{ loc : Position
|
||||
, time : Maybe Time.Posix
|
||||
}
|
||||
|
||||
@ -22,10 +22,11 @@ timeDecoder = XD.andThen (\ts ->
|
||||
)
|
||||
XD.string
|
||||
|
||||
pointDecoder = XD.map4 Point
|
||||
(floatAttr "lat")
|
||||
(floatAttr "lon")
|
||||
(XD.maybe (path ["ele"] (single XD.float)))
|
||||
triple x y z = (x,y,z)
|
||||
|
||||
pointDecoder = XD.map2 Point
|
||||
(XD.map3 triple (floatAttr "lat") (floatAttr "lon")
|
||||
(XD.maybe (path ["ele"] (single XD.float))))
|
||||
(XD.maybe (path ["time"] (single timeDecoder)))
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/
|
||||
"""
|
||||
|
||||
threepoints_expected =
|
||||
[ (Point 51.600643 -0.01856 (Just 64.8) (Just (Time.millisToPosix 1729669252256)))
|
||||
, (Point 51.600679 -0.018179 (Just 65.5) (Just (Time.millisToPosix 1729669255259)))
|
||||
, (Point 51.600697 -0.018064 (Just 66.2) (Just (Time.millisToPosix 1729669256231)))
|
||||
[ (Point (51.600643, -0.01856, Just 64.8) (Just (Time.millisToPosix 1729669252256)))
|
||||
, (Point (51.600679, -0.018179, Just 65.5) (Just (Time.millisToPosix 1729669255259)))
|
||||
, (Point (51.600697, -0.018064, Just 66.2) (Just (Time.millisToPosix 1729669256231)))
|
||||
]
|
||||
|
@ -23,7 +23,7 @@ specs =
|
||||
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 (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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user