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 # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord Z # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord X # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord Y # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord Tile # 
Instance details

Defined in Data.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 # 
Instance details

Defined in Data.Tile

Methods

showsPrec :: Int -> Tile -> ShowS #

show :: Tile -> String #

showList :: [Tile] -> ShowS #

newtype Lng #

Newtype wrapper around longitude.

Constructors

Lng Double 
Instances
Bounded Lng # 
Instance details

Defined in Data.Tile

Methods

minBound :: Lng #

maxBound :: Lng #

Eq Lng # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord Lng # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

Methods

showsPrec :: Int -> Lng -> ShowS #

show :: Lng -> String #

showList :: [Lng] -> ShowS #

newtype Lat #

Newtype wrapper around latitude.

Constructors

Lat Double 
Instances
Bounded Lat # 
Instance details

Defined in Data.Tile

Methods

minBound :: Lat #

maxBound :: Lat #

Eq Lat # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord Lat # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

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
Eq LngLat # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord LngLat # 
Instance details

Defined in Data.Tile

Show LngLat # 
Instance details

Defined in Data.Tile

newtype Px #

Newtype wrapper around a pixel's x-coordinate

Constructors

Px Int 
Instances
Eq Px # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord Px # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord Py # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

Methods

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

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

Ord Pixel # 
Instance details

Defined in Data.Tile

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 # 
Instance details

Defined in Data.Tile

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.

Instances
Eq BoxOrigin # 
Instance details

Defined in Data.Tile

Show BoxOrigin # 
Instance details

Defined in Data.Tile

data TileBounds #

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

Instances
Eq TileBounds # 
Instance details

Defined in Data.Tile

Show TileBounds # 
Instance details

Defined in Data.Tile

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.