diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm index 901fd64..e7e9d20 100644 --- a/frontend/src/Main.elm +++ b/frontend/src/Main.elm @@ -80,11 +80,11 @@ type alias Lng = Float sec x = 1 / (cos x) -toCoord : Lat -> Lng -> Coord -toCoord lat lng = +toCoord : Pos -> Coord +toCoord pos = let - lat_rad = lat * pi / 180 - x = (lng + 180) / 360 + lat_rad = pos.lat * pi / 180 + x = (pos.lon + 180) / 360 y = (1 - (logBase e ((tan lat_rad) + (sec lat_rad))) / pi) / 2 in Coord x y @@ -166,7 +166,9 @@ init _ url navKey = Just (Timeline (Just s) (Just d)) -> (s, d) _ -> (10,10) in - ((Model (toCoord 0 0) (FineZoomLevel (1*8)) None 0 0 Empty), + ((Model + (toCoord (Pos 0 0 Nothing)) + (FineZoomLevel (1*8)) None 0 0 Empty), (fetchTrack start duration)) -- SUBSCRIPTIONS @@ -199,10 +201,6 @@ type Msg | Dribble String -coordFromPos p = - let {lat, lon } = p - in toCoord lat lon - update : Msg -> Model -> (Model, Cmd Msg) update msg model = (updateModel msg model, Cmd.none) @@ -248,7 +246,7 @@ updateModel msg model = in { model | track = Present trk - , centre = coordFromPos (Point.centre trk) + , centre = toCoord (Point.centre trk) , zoom = FineZoomLevel ( 13 * 8) , startTime = floor start , duration = ceiling duration @@ -492,7 +490,7 @@ eleView = measureView "elevation" "#4444ee" (.pos >> .ele) trackView : Int -> Int -> ZoomLevel -> List Point -> Svg Msg trackView leftedge topedge zoom points = let plot p = - let (x, y) = pixelFromCoord (toCoord p.pos.lat p.pos.lon) zoom + let (x, y) = pixelFromCoord (toCoord p.pos) zoom x_ = x - leftedge y_ = y - topedge in (String.fromInt x_) ++ ", " ++