fix low-hanging errors from elm-analyse

This commit is contained in:
Daniel Barlow 2024-11-21 21:53:07 +00:00
parent 9484597491
commit f17332a047
2 changed files with 15 additions and 19 deletions

View File

@ -2,7 +2,7 @@ module Main exposing (view)
import Browser import Browser
import Browser.Navigation as Nav 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.Attributes as H exposing (src, style, width, height)
import Html.Events exposing (onClick, on) import Html.Events exposing (onClick, on)
import Html.Events.Extra.Pointer as Pointer import Html.Events.Extra.Pointer as Pointer
@ -12,20 +12,17 @@ import List.Extra exposing(find)
import Json.Decode as D import Json.Decode as D
import Http import Http
import Point exposing(Point, Pos ,decoder) 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 import Svg.Attributes as S exposing
( viewBox ( viewBox
, preserveAspectRatio , preserveAspectRatio
, transform , transform
, x, y , x, y
, x1, y1 , x2, y2 , x1, y1 , x2, y2
, r, rx, ry
, cx, cy
, fill , fill
, points
, stroke, strokeWidth, strokeOpacity) , stroke, strokeWidth, strokeOpacity)
import Time exposing(Posix) import Time -- exposing(Posix)
import Url.Parser exposing (Parser, (</>), (<?>), int, map, oneOf, s, string) import Url.Parser exposing (Parser, (<?>), int, map, s, string)
import Url.Parser.Query as Query import Url.Parser.Query as Query
import Url exposing (Url) import Url exposing (Url)
@ -45,12 +42,10 @@ main =
{ init = init { init = init
, update = update , update = update
, subscriptions = subscriptions , subscriptions = subscriptions
, onUrlRequest = (\ ur -> NewUrlRequest) , onUrlRequest = \ _ -> NewUrlRequest
, onUrlChange = (\ u -> UrlChanged) , onUrlChange = \ _ -> UrlChanged
, view = view } , view = view }
-- MATHS -- MATHS
-- Coordinates in a Mercator projection -- Coordinates in a Mercator projection
@ -72,9 +67,6 @@ incZoom (FineZoomLevel z) delta =
type alias TileNumber = { x: Int, y: Int } 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 -- project lat/long to co-ordinates based on pseudocode at
-- https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Zoom_levels -- https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Zoom_levels
@ -137,7 +129,7 @@ dragTo : Drag -> (Int, Int) -> Drag
dragTo d dest = dragTo d dest =
case d of case d of
None -> None None -> None
Dragging target from to -> Dragging target from dest Dragging target from _ -> Dragging target from dest
dragDelta target d = dragDelta target d =
case d of case d of
@ -168,7 +160,7 @@ init _ url navKey =
in in
((Model ((Model
(toCoord (Pos 0 0 Nothing)) (toCoord (Pos 0 0 Nothing))
(FineZoomLevel (1*8)) None 0 0 Empty), (FineZoomLevel (1*8)) None 0 0 Loading),
(fetchTrack start duration)) (fetchTrack start duration))
-- SUBSCRIPTIONS -- SUBSCRIPTIONS

View File

@ -38,10 +38,9 @@ last x xs =
[] -> x [] -> x
(x_::xs_) -> last x_ xs_ (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 -- divide the points into n equal time buckets and return the first
-- point in each -- point in each
downsample : Int -> List Point -> List Point
downsample n points = downsample n points =
let let
nextpoint step prev points_ = nextpoint step prev points_ =
@ -58,14 +57,16 @@ downsample n points =
in nextpoint step first rest in nextpoint step first rest
[] -> [] [] -> []
duration : List Point -> Float
duration points = duration points =
case points of case points of
(p::ps) -> (last p ps).time - p.time (p::ps) -> (last p ps).time - p.time
_ -> 0 _ -> 0
startTime : List Point -> Maybe Float
startTime points = startTime points =
case points of case points of
(p::ps) -> Just p.time (p::_) -> Just p.time
_ -> Nothing _ -> Nothing
type Bound = Bound Pos Pos | NoBound type Bound = Bound Pos Pos | NoBound
@ -81,9 +82,11 @@ extendBound pos b =
NoBound -> NoBound ->
Bound pos pos Bound pos pos
bounds : List Point -> Bound
bounds points = bounds points =
List.foldr extendBound NoBound (List.map .pos points) List.foldr extendBound NoBound (List.map .pos points)
centre : List Point -> Pos
centre points = centre points =
case bounds points of case bounds points of
Bound min max -> Pos Bound min max -> Pos
@ -92,6 +95,7 @@ centre points =
Nothing Nothing
NoBound -> Pos 0 0 Nothing NoBound -> Pos 0 0 Nothing
subseq : List Point -> Float -> Float -> List Point
subseq points start dur = subseq points start dur =
case points of case points of
[] -> [] [] -> []