rename type MapZoom -> ZoomLevel
This commit is contained in:
parent
7f58809741
commit
86e9919825
@ -53,7 +53,7 @@ main =
|
|||||||
type alias Coord = { x: Float, y: Float }
|
type alias Coord = { x: Float, y: Float }
|
||||||
|
|
||||||
-- zoom level
|
-- zoom level
|
||||||
type alias MapZoom = Int
|
type alias ZoomLevel = Int
|
||||||
|
|
||||||
type alias TileNumber = { x: Int, y: Int }
|
type alias TileNumber = { x: Int, y: Int }
|
||||||
|
|
||||||
@ -86,20 +86,20 @@ reflect c = Coord -c.x -c.y
|
|||||||
translate base offset =
|
translate base offset =
|
||||||
{ base | x = (base.x + offset.x), y = (base.y + offset.y) }
|
{ base | x = (base.x + offset.x), y = (base.y + offset.y) }
|
||||||
|
|
||||||
translatePixels : Coord -> MapZoom -> (Int, Int) -> Coord
|
translatePixels : Coord -> ZoomLevel -> (Int, Int) -> Coord
|
||||||
translatePixels old z (x, y) = translate old (pixelsToCoord z (x, y))
|
translatePixels old z (x, y) = translate old (pixelsToCoord z (x, y))
|
||||||
|
|
||||||
|
|
||||||
tileCovering : Coord -> MapZoom -> TileNumber
|
tileCovering : Coord -> ZoomLevel -> TileNumber
|
||||||
tileCovering c z =
|
tileCovering c z =
|
||||||
TileNumber (truncate (toFloat (2 ^ z) * c.x)) (truncate (toFloat (2 ^ z) * c.y))
|
TileNumber (truncate (toFloat (2 ^ z) * c.x)) (truncate (toFloat (2 ^ z) * c.y))
|
||||||
|
|
||||||
pixelFromCoord : Coord -> MapZoom -> (Int, Int)
|
pixelFromCoord : Coord -> ZoomLevel -> (Int, Int)
|
||||||
pixelFromCoord c z =
|
pixelFromCoord c z =
|
||||||
let {x,y} = tileCovering c (z + 8)
|
let {x,y} = tileCovering c (z + 8)
|
||||||
in (x,y)
|
in (x,y)
|
||||||
|
|
||||||
boundingTiles : Coord -> MapZoom -> Int -> Int -> (TileNumber, TileNumber)
|
boundingTiles : Coord -> ZoomLevel -> Int -> Int -> (TileNumber, TileNumber)
|
||||||
boundingTiles centre z width height =
|
boundingTiles centre z width height =
|
||||||
-- find the tiles needed to cover the area (`width` x `height`)
|
-- find the tiles needed to cover the area (`width` x `height`)
|
||||||
-- about the point at `centre`
|
-- about the point at `centre`
|
||||||
@ -129,7 +129,7 @@ dragDelta d =
|
|||||||
type TrackState = Empty | Loading | Failure String | Present (List Point)
|
type TrackState = Empty | Loading | Failure String | Present (List Point)
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ centre: Coord
|
{ centre: Coord
|
||||||
, zoom: MapZoom
|
, zoom: ZoomLevel
|
||||||
, drag: Drag
|
, drag: Drag
|
||||||
, startTime : Int
|
, startTime : Int
|
||||||
, duration : Int
|
, duration : Int
|
||||||
@ -223,7 +223,7 @@ newModel msg model =
|
|||||||
|
|
||||||
-- VIEW
|
-- VIEW
|
||||||
|
|
||||||
tileUrl : TileNumber -> MapZoom -> String
|
tileUrl : TileNumber -> ZoomLevel -> String
|
||||||
tileUrl {x,y} z =
|
tileUrl {x,y} z =
|
||||||
String.concat ["https://a.tile.openstreetmap.org",
|
String.concat ["https://a.tile.openstreetmap.org",
|
||||||
"/", String.fromInt z,
|
"/", String.fromInt z,
|
||||||
@ -290,7 +290,7 @@ powerView = measureView "power" "#994444" (.power >> Maybe.map toFloat)
|
|||||||
eleView = measureView "elevation" "#4444ee" (.pos >> .ele)
|
eleView = measureView "elevation" "#4444ee" (.pos >> .ele)
|
||||||
|
|
||||||
|
|
||||||
trackView : Int -> Int -> MapZoom -> List Point -> Svg Msg
|
trackView : Int -> Int -> ZoomLevel -> List Point -> Svg Msg
|
||||||
trackView leftedge topedge zoom points =
|
trackView leftedge topedge zoom points =
|
||||||
let plot p =
|
let plot p =
|
||||||
let (x, y) = pixelFromCoord (toCoord p.pos.lat p.pos.lon) zoom
|
let (x, y) = pixelFromCoord (toCoord p.pos.lat p.pos.lon) zoom
|
||||||
|
Loading…
Reference in New Issue
Block a user