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 Source #

Newtype wrapper around map zoom level.

Constructors

Z Int 

Instances

Eq Z Source # 

Methods

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

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

Ord Z Source # 

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 Source # 

Methods

showsPrec :: Int -> Z -> ShowS #

show :: Z -> String #

showList :: [Z] -> ShowS #

newtype X Source #

Newtype wrapper around a tile's x-coordinate.

Constructors

X Int 

Instances

Eq X Source # 

Methods

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

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

Ord X Source # 

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 Source # 

Methods

showsPrec :: Int -> X -> ShowS #

show :: X -> String #

showList :: [X] -> ShowS #

newtype Y Source #

Newtype wrapper around a tile's y-coordinate.

Constructors

Y Int 

Instances

Eq Y Source # 

Methods

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

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

Ord Y Source # 

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 Source # 

Methods

showsPrec :: Int -> Y -> ShowS #

show :: Y -> String #

showList :: [Y] -> ShowS #

newtype Tile Source #

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 Source # 

Methods

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

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

Ord Tile Source # 

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 Source # 

Methods

showsPrec :: Int -> Tile -> ShowS #

show :: Tile -> String #

showList :: [Tile] -> ShowS #

newtype Lng Source #

Newtype wrapper around longitude.

Constructors

Lng Double 

Instances

Bounded Lng Source # 

Methods

minBound :: Lng #

maxBound :: Lng #

Eq Lng Source # 

Methods

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

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

Ord Lng Source # 

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 Source # 

Methods

showsPrec :: Int -> Lng -> ShowS #

show :: Lng -> String #

showList :: [Lng] -> ShowS #

newtype Lat Source #

Newtype wrapper around latitude.

Constructors

Lat Double 

Instances

Bounded Lat Source # 

Methods

minBound :: Lat #

maxBound :: Lat #

Eq Lat Source # 

Methods

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

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

Ord Lat Source # 

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 Source # 

Methods

showsPrec :: Int -> Lat -> ShowS #

show :: Lat -> String #

showList :: [Lat] -> ShowS #

newtype LngLat Source #

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

Constructors

LngLat (Lng, Lat) 

newtype Px Source #

Newtype wrapper around a pixel's x-coordinate

Constructors

Px Int 

Instances

Eq Px Source # 

Methods

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

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

Ord Px Source # 

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 Source # 

Methods

showsPrec :: Int -> Px -> ShowS #

show :: Px -> String #

showList :: [Px] -> ShowS #

newtype Py Source #

Newtype wrapper around a pixel's y-coordinate

Constructors

Py Int 

Instances

Eq Py Source # 

Methods

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

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

Ord Py Source # 

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 Source # 

Methods

showsPrec :: Int -> Py -> ShowS #

show :: Py -> String #

showList :: [Py] -> ShowS #

newtype Pixel Source #

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

Constructors

Pixel (Px, Py) 

Instances

Eq Pixel Source # 

Methods

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

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

Ord Pixel Source # 

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 Source # 

Methods

showsPrec :: Int -> Pixel -> ShowS #

show :: Pixel -> String #

showList :: [Pixel] -> ShowS #

data BoxOrigin Source #

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 Source #

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

Functions

Tile functionality

maxTileIndex :: Z -> Int Source #

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

maxTilesInDimension :: Z -> Int Source #

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

maxPixelsInDimension :: Z -> Int Source #

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

flipY :: Tile -> Tile Source #

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

subTiles :: Tile -> [Tile] Source #

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

parentTile :: Tile -> Maybe Tile Source #

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

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

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

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

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 Source #

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

lngLatToPixel :: Z -> LngLat -> Pixel Source #

Convert a LngLat into a Pixel.

To Tile

pixelToTile :: Z -> Pixel -> Tile Source #

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

lngLatToTile :: Z -> LngLat -> Tile Source #

Convert a LngLat into a Tile.

To LngLat

pixelToLngLat :: Z -> Pixel -> LngLat Source #

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

tileToLngLat :: Tile -> LngLat Source #

Convert a Tile into a LngLat.

To TileBounds

tileToBounds :: BoxOrigin -> Tile -> TileBounds Source #

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