From 4bdd103bd5a7f652b6fdfc228a5fdce924b85a53 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 10 Nov 2024 20:12:34 +0000 Subject: [PATCH] plot the points --- frontend/src/Main.elm | 50 ++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm index c09e5c8..5368b34 100644 --- a/frontend/src/Main.elm +++ b/frontend/src/Main.elm @@ -197,7 +197,7 @@ newModel msg model = Loaded result -> case result of - Ok trk -> { model | track = Debug.log "LOADED" (Present trk) } + Ok trk -> { model | track = Present trk } Err (Http.BadBody e) -> { model | track = Debug.log e (Failure "e") } Err e -> { model | track = Debug.log "unknown error" (Failure "e") } @@ -215,36 +215,28 @@ tileImg zoom tilenumber = img [ width 256, height 256, src (tileUrl tilenumber zoom) ] [] -trackView : List Point -> Svg Msg - - -trackView track = +trackView : List Point -> Int -> Int -> Svg Msg +trackView points leftedge topedge = + let plot p = + let (x, y) = pixelFromCoord (toCoord p.pos.lat p.pos.lon) 13 + x_ = x - leftedge + y_ = y - topedge + in circle [ cx (px x_), cy (px y_), r "2" ] [] + line = List.map plot points + in svg - [H.style "width" "100%" - ,H.style "height" "100%" - ,H.style "position" "absolute" + [ H.style "width" "100%" + , H.style "height" "100%" + , H.style "position" "absolute" ] [ g - [fill "none" - ,stroke "blue" - ,strokeWidth "7" - ,strokeOpacity "0.5"] - [ rect - [ x "10" - , y "10" - , S.width "100" - , S.height "100" - , rx "15" - , ry "15" - ] - [] - , circle - [ cx "50" - , cy "50" - , r "50" - ] - [] - ]] + [ fill "none" + , stroke "blue" + , strokeWidth "7" + , strokeOpacity "0.5"] + line + ] + px x = String.fromInt x ++ "px" @@ -270,7 +262,7 @@ canvas centre zoom width height track = ys = List.range mintile.y maxtile.y epos e = Tuple.mapBoth floor floor e.pointer.clientPos tv = case track of - Present t -> trackView t + Present t -> trackView t leftedge topedge Failure f -> Debug.log f (div [] [ text "failure", text f]) Loading -> div [] [text "loading"] Empty -> div [] [text "no points"]