tile-0.3.0.0: Slippy map tile functionality.

Copyright(c) Joe Canero 2017
LicenseBSD3
Maintainerjmc41493@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

Data.Tile

Contents

Description

This module provides types and functions for manipulating tiles, latitude/longitude pairs, and pixels.

See the associated README.md for basic usage examples.

Synopsis

Types

newtype Z #

Newtype wrapper around map zoom level.

Constructors

Z Int 

Instances

Eq Z # 

Methods

(==) :: Z -> Z -> Bool #

(/=) :: Z -> Z -> Bool #

Ord Z # 

Methods

compare :: Z -> Z -> Ordering #

(<) :: Z -> Z -> Bool #

(<=) :: Z -> Z -> Bool #

(>) :: Z -> Z -> Bool #

(>=) :: Z -> Z -> Bool #

max :: Z -> Z -> Z #

min :: Z -> Z -> Z #

Show Z # 

Methods

showsPrec :: Int -> Z -> ShowS #

show :: Z -> String #

showList :: [Z] -> ShowS #

newtype X #

Newtype wrapper around a tile's x-coordinate.

Constructors

X Int 

Instances

Eq X # 

Methods

(==) :: X -> X -> Bool #

(/=) :: X -> X -> Bool #

Ord X # 

Methods

compare :: X -> X -> Ordering #

(<) :: X -> X -> Bool #

(<=) :: X -> X -> Bool #

(>) :: X -> X -> Bool #

(>=) :: X -> X -> Bool #

max :: X -> X -> X #

min :: X -> X -> X #

Show X # 

Methods

showsPrec :: Int -> X -> ShowS #

show :: X -> String #

showList :: [X] -> ShowS #

newtype Y #

Newtype wrapper around a tile's y-coordinate.

Constructors

Y Int 

Instances

Eq Y # 

Methods

(==) :: Y -> Y -> Bool #

(/=) :: Y -> Y -> Bool #

Ord Y # 

Methods

compare :: Y -> Y -> Ordering #

(<) :: Y -> Y -> Bool #

(<=) :: Y -> Y -> Bool #

(>) :: Y -> Y -> Bool #

(>=) :: Y -> Y -> Bool #

max :: Y -> Y -> Y #

min :: Y -> Y -> Y #

Show Y # 

Methods

showsPrec :: Int -> Y -> ShowS #

show :: Y -> String #

showList :: [Y] -> ShowS #

newtype Tile #

Newtype wrapper around a triple of Z, X, and Y representing a single tile in a map's tile system.

Constructors

Tile (Z, X, Y) 

Instances

Eq Tile # 

Methods

(==) :: Tile -> Tile -> Bool #

(/=) :: Tile -> Tile -> Bool #

Ord Tile # 

Methods

compare :: Tile -> Tile -> Ordering #

(<) :: Tile -> Tile -> Bool #

(<=) :: Tile -> Tile -> Bool #

(>) :: Tile -> Tile -> Bool #

(>=) :: Tile -> Tile -> Bool #

max :: Tile -> Tile -> Tile #

min :: Tile -> Tile -> Tile #

Show Tile # 

Methods

showsPrec :: Int -> Tile -> ShowS #

show :: Tile -> String #

showList :: [Tile] -> ShowS #

newtype Lng #

Newtype wrapper around longitude.

Constructors

Lng Double 

Instances

Bounded Lng # 

Methods

minBound :: Lng #

maxBound :: Lng #

Eq Lng # 

Methods

(==) :: Lng -> Lng -> Bool #

(/=) :: Lng -> Lng -> Bool #

Ord Lng # 

Methods

compare :: Lng -> Lng -> Ordering #

(<) :: Lng -> Lng -> Bool #

(<=) :: Lng -> Lng -> Bool #

(>) :: Lng -> Lng -> Bool #

(>=) :: Lng -> Lng -> Bool #

max :: Lng -> Lng -> Lng #

min :: Lng -> Lng -> Lng #

Show Lng # 

Methods

showsPrec :: Int -> Lng -> ShowS #

show :: Lng -> String #

showList :: [Lng] -> ShowS #

newtype Lat #

Newtype wrapper around latitude.

Constructors

Lat Double 

Instances

Bounded Lat # 

Methods

minBound :: Lat #

maxBound :: Lat #

Eq Lat # 

Methods

(==) :: Lat -> Lat -> Bool #

(/=) :: Lat -> Lat -> Bool #

Ord Lat # 

Methods

compare :: Lat -> Lat -> Ordering #

(<) :: Lat -> Lat -> Bool #

(<=) :: Lat -> Lat -> Bool #

(>) :: Lat -> Lat -> Bool #

(>=) :: Lat -> Lat -> Bool #

max :: Lat -> Lat -> Lat #

min :: Lat -> Lat -> Lat #

Show Lat # 

Methods

showsPrec :: Int -> Lat -> ShowS #

show :: Lat -> String #

showList :: [Lat] -> ShowS #

newtype LngLat #

Newtype wrapper around a tuple of Lng and Lat representing a WGS84 latitude and longitude on the map.

Constructors

LngLat (Lng, Lat) 

Instances

newtype Px #

Newtype wrapper around a pixel's x-coordinate

Constructors

Px Int 

Instances

Eq Px # 

Methods

(==) :: Px -> Px -> Bool #

(/=) :: Px -> Px -> Bool #

Ord Px # 

Methods

compare :: Px -> Px -> Ordering #

(<) :: Px -> Px -> Bool #

(<=) :: Px -> Px -> Bool #

(>) :: Px -> Px -> Bool #

(>=) :: Px -> Px -> Bool #

max :: Px -> Px -> Px #

min :: Px -> Px -> Px #

Show Px # 

Methods

showsPrec :: Int -> Px -> ShowS #

show :: Px -> String #

showList :: [Px] -> ShowS #

newtype Py #

Newtype wrapper around a pixel's y-coordinate

Constructors

Py Int 

Instances

Eq Py # 

Methods

(==) :: Py -> Py -> Bool #

(/=) :: Py -> Py -> Bool #

Ord Py # 

Methods

compare :: Py -> Py -> Ordering #

(<) :: Py -> Py -> Bool #

(<=) :: Py -> Py -> Bool #

(>) :: Py -> Py -> Bool #

(>=) :: Py -> Py -> Bool #

max :: Py -> Py -> Py #

min :: Py -> Py -> Py #

Show Py # 

Methods

showsPrec :: Int -> Py -> ShowS #

show :: Py -> String #

showList :: [Py] -> ShowS #

newtype Pixel #

Newtype wrapper around a tuple of Px and Py representing a single pixel.

Constructors

Pixel (Px, Py) 

Instances

Eq Pixel # 

Methods

(==) :: Pixel -> Pixel -> Bool #

(/=) :: Pixel -> Pixel -> Bool #

Ord Pixel # 

Methods

compare :: Pixel -> Pixel -> Ordering #

(<) :: Pixel -> Pixel -> Bool #

(<=) :: Pixel -> Pixel -> Bool #

(>) :: Pixel -> Pixel -> Bool #

(>=) :: Pixel -> Pixel -> Bool #

max :: Pixel -> Pixel -> Pixel #

min :: Pixel -> Pixel -> Pixel #

Show Pixel # 

Methods

showsPrec :: Int -> Pixel -> ShowS #

show :: Pixel -> String #

showList :: [Pixel] -> ShowS #

data BoxOrigin #

Datatype representing the origin point of a bounding box.

Constructors

SW

Indicates that the origin is in the southwest corner of the bbox, and the second point is in the northeast corner of the bbox.

NW

Indicates that the origin is in the northwest corner of the bbox, and the second point is in the southeast corner of the bbox.

data TileBounds #

Datatype representing the bounds of a tile as a BoxOrigin and two LngLat values.

Functions

Tile functionality

maxTileIndex :: Z -> Int #

Get the maximum index a tile can have along a given dimension, x or y.

maxTilesInDimension :: Z -> Int #

Get the numbers of tiles in a given dimension, x or y, at the specified map zoom level.

maxPixelsInDimension :: Z -> Int #

Get the number of pixels in a given dimension, x or y, assuming a tile is 256x256px.

flipY :: Tile -> Tile #

Given a Tile, flip its y-coordinate according to the rules of TMS.

subTiles :: Tile -> [Tile] #

Given a Tile, return a list of its four subtiles.

parentTile :: Tile -> Maybe Tile #

Given a Tile, return its parent Tile, if it has one.

mkTile :: Z -> X -> Y -> Maybe Tile #

Smart constructor for tiles. Validates that the X and Y values are valid for the value of Z.

tilesInBounds :: BoxOrigin -> Z -> (LngLat, LngLat) -> [Tile] #

Given a BoxOrigin, a Z, and a pair of LngLats, return a list of all tiles touching or within the bounding box.

Conversions

To Pixel

tileToPixel :: Tile -> Pixel #

Convert a Tile to a Pixel assuming a tile size of 256x256px.

lngLatToPixel :: Z -> LngLat -> Pixel #

Convert a LngLat into a Pixel.

To Tile

pixelToTile :: Z -> Pixel -> Tile #

Convert a Pixel into a Tile assuming a tile size of 256x256px.

lngLatToTile :: Z -> LngLat -> Tile #

Convert a LngLat into a Tile.

To LngLat

pixelToLngLat :: Z -> Pixel -> LngLat #

Convert a Pixel into a LngLat assuming map resolution as defined at the equator.

tileToLngLat :: Tile -> LngLat #

Convert a Tile into a LngLat.

To TileBounds

tileToBounds :: BoxOrigin -> Tile -> TileBounds #

Convert a Tile into a TileBounds value representing the bounding box of that tile.