commit f17332a0477bc44bcd76702d2e5c3b1cc4d5ac13
parent 9484597491c9291782a1d1a730f96dc9bdacb57d
Author: Daniel Barlow <dan@telent.net>
Date: Thu, 21 Nov 2024 21:53:07 +0000
fix low-hanging errors from elm-analyse
Diffstat:
2 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm
@@ -2,7 +2,7 @@ module Main exposing (view)
import Browser
import Browser.Navigation as Nav
-import Html exposing (Html, button, div, span, text, img, pre)
+import Html exposing (Html, button, div, span, text, img)
import Html.Attributes as H exposing (src, style, width, height)
import Html.Events exposing (onClick, on)
import Html.Events.Extra.Pointer as Pointer
@@ -12,20 +12,17 @@ import List.Extra exposing(find)
import Json.Decode as D
import Http
import Point exposing(Point, Pos ,decoder)
-import Svg exposing (Svg, svg, rect, circle, g, polyline, line)
+import Svg exposing (Svg, svg, rect, g, polyline, line)
import Svg.Attributes as S exposing
( viewBox
, preserveAspectRatio
, transform
, x, y
, x1, y1 , x2, y2
- , r, rx, ry
- , cx, cy
, fill
- , points
, stroke, strokeWidth, strokeOpacity)
-import Time exposing(Posix)
-import Url.Parser exposing (Parser, (</>), (<?>), int, map, oneOf, s, string)
+import Time -- exposing(Posix)
+import Url.Parser exposing (Parser, (<?>), int, map, s, string)
import Url.Parser.Query as Query
import Url exposing (Url)
@@ -45,12 +42,10 @@ main =
{ init = init
, update = update
, subscriptions = subscriptions
- , onUrlRequest = (\ ur -> NewUrlRequest)
- , onUrlChange = (\ u -> UrlChanged)
+ , onUrlRequest = \ _ -> NewUrlRequest
+ , onUrlChange = \ _ -> UrlChanged
, view = view }
-
-
-- MATHS
-- Coordinates in a Mercator projection
@@ -72,9 +67,6 @@ incZoom (FineZoomLevel z) delta =
type alias TileNumber = { x: Int, y: Int }
-type alias Lat = Float
-type alias Lng = Float
-
-- project lat/long to co-ordinates based on pseudocode at
-- https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Zoom_levels
@@ -137,7 +129,7 @@ dragTo : Drag -> (Int, Int) -> Drag
dragTo d dest =
case d of
None -> None
- Dragging target from to -> Dragging target from dest
+ Dragging target from _ -> Dragging target from dest
dragDelta target d =
case d of
@@ -168,7 +160,7 @@ init _ url navKey =
in
((Model
(toCoord (Pos 0 0 Nothing))
- (FineZoomLevel (1*8)) None 0 0 Empty),
+ (FineZoomLevel (1*8)) None 0 0 Loading),
(fetchTrack start duration))
-- SUBSCRIPTIONS
diff --git a/frontend/src/Point.elm b/frontend/src/Point.elm
@@ -38,10 +38,9 @@ last x xs =
[] -> x
(x_::xs_) -> last x_ xs_
-tracef x = Debug.log (String.fromFloat x) x
-
-- divide the points into n equal time buckets and return the first
-- point in each
+downsample : Int -> List Point -> List Point
downsample n points =
let
nextpoint step prev points_ =
@@ -58,14 +57,16 @@ downsample n points =
in nextpoint step first rest
[] -> []
+duration : List Point -> Float
duration points =
case points of
(p::ps) -> (last p ps).time - p.time
_ -> 0
+startTime : List Point -> Maybe Float
startTime points =
case points of
- (p::ps) -> Just p.time
+ (p::_) -> Just p.time
_ -> Nothing
type Bound = Bound Pos Pos | NoBound
@@ -81,9 +82,11 @@ extendBound pos b =
NoBound ->
Bound pos pos
+bounds : List Point -> Bound
bounds points =
List.foldr extendBound NoBound (List.map .pos points)
+centre : List Point -> Pos
centre points =
case bounds points of
Bound min max -> Pos
@@ -92,6 +95,7 @@ centre points =
Nothing
NoBound -> Pos 0 0 Nothing
+subseq : List Point -> Float -> Float -> List Point
subseq points start dur =
case points of
[] -> []