Safe Haskell | None |
---|
- newtype TileID = TID {}
- data TileCoords = TileCoords {}
- type Zoom = Int
- data OSMConfig = OSMCfg {
- baseUrl :: String
- cache :: Text
- noCacheAction :: Maybe (TileID -> Zoom -> IO (Either Status ByteString))
- nrQueuedDownloads :: Int
- nrConcurrentDownloads :: Int
- networkEnabled :: Bool
- data OSMState
- data OSM a
- evalOSM :: OSM a -> OSMConfig -> IO a
- getBestFitTiles :: Coordinate a => [a] -> OSM [[Either Status ByteString]]
- getTiles :: [[TileID]] -> Zoom -> OSM [[Either Status ByteString]]
- getTile :: TileID -> Zoom -> OSM (Either Status ByteString)
- defaultOSMConfig :: IO OSMConfig
- downloadBestFitTiles :: Coordinate a => String -> [a] -> IO [[Either Status ByteString]]
- downloadTiles :: String -> Zoom -> [[TileID]] -> IO [[Either Status ByteString]]
- downloadTile :: String -> Zoom -> TileID -> IO (Either Status ByteString)
- osmTileURL :: String
- data Frame a = Frame {}
- selectTilesForFrame :: Coordinate a => Frame a -> [[TileID]]
- tileCoordsForFrame :: Coordinate a => Frame a -> TileCoords
- pixelPositionForFrame :: Coordinate a => Frame a -> a -> (Int, Int)
- pixelPosForCoord :: (Coordinate a, Integral t) => a -> TileCoords -> Zoom -> (t, t)
- determineTileCoords :: Coordinate a => [a] -> Zoom -> Maybe TileCoords
- selectedTiles :: TileCoords -> [[TileID]]
- osmCopyrightText :: String
Basic Types
A TileID, along with a zoom level, uniquely identifies a single OSM map tile. The standard size is 256x256 pixels for such a tile.
data TileCoords Source
The coordinates associated with any particular GPS location
can be computed using determineTileCoords
and converted into tile ids
using selectedTiles
before final download with downloadTiles
.
Types for tile cacheing
The cacheing operations run in their own monad that describe the location of the cache, the tile server URL, and the worker threads the retrieve tiles.
OSMCfg | |
|
The OSM operations maintain a list of tiles needing refreshed (for local caching), the state of the local cache, and initial configuration options.
A Monad transformer allowing you acquire OSM maps
High-level (cacheing) Operations
evalOSM :: OSM a -> OSMConfig -> IO aSource
evalOSM allows you to query an OSM server and the local cache.
Take note - the OSMConfig
thread limit is enforced per-evalOSM.
Running many evalOSM processes can result in a violation of the
limit and incur admin wrath.
getBestFitTiles :: Coordinate a => [a] -> OSM [[Either Status ByteString]]Source
Like downloadBestFitTiles
but uses the cached copies when available.
getTiles :: [[TileID]] -> Zoom -> OSM [[Either Status ByteString]]Source
Like downloadTiles
but uses the cached copies when available
getTile :: TileID -> Zoom -> OSM (Either Status ByteString)Source
Like downloadTile
but uses a cached copy when available.
Downloaded copies are added to the cache.
When the cached copy is out of date it will still be returned but a new copy will be downloaded and added to the cache concurrently.
defaultOSMConfig :: IO OSMConfigSource
A default configuration using the main OSM server as a tile server and a cabal-generated directory for the cache directory
Network Operations
downloadBestFitTiles :: Coordinate a => String -> [a] -> IO [[Either Status ByteString]]Source
Takes the tile server base URL,
the set of coordinates that must appear within the map boundaries, and users
the downloadTiles
function to acquire all the necessary tiles.
The returned files should all be in an approriate grid for row/column display. See the test files of Main.hs and Main2.hs for examples of Repa stiching tiles into a single image or side by side display of individual tiles.
downloadTiles :: String -> Zoom -> [[TileID]] -> IO [[Either Status ByteString]]Source
Takes the boundaries of the OSM tiles and downloads the tiles, keeping them in proper grid patterns for latter stiching or side-by-side display.
downloadTile :: String -> Zoom -> TileID -> IO (Either Status ByteString)Source
Download a single tile form a given OSM server URL.
The official OSM tile server.
Frame-oriented operations
selectTilesForFrame :: Coordinate a => Frame a -> [[TileID]]Source
Given a width, height and center, compute the tiles needed to fill the display.
THIS ASSUMES tiles are 256x256 pixels!
tileCoordsForFrame :: Coordinate a => Frame a -> TileCoordsSource
pixelPositionForFrame :: Coordinate a => Frame a -> a -> (Int, Int)Source
Helper Functions
pixelPosForCoord :: (Coordinate a, Integral t) => a -> TileCoords -> Zoom -> (t, t)Source
Takes a coordinate, the OSM tile boundaries, and a zoom level then generates (x,y) points to be placed on the Image. The origin is in the upper left of the picture.
determineTileCoords :: Coordinate a => [a] -> Zoom -> Maybe TileCoordsSource
Computes the rectangular map region to download based on GPS points and a zoom level
selectedTiles :: TileCoords -> [[TileID]]Source
Takes the boundaries of the OSM tiles, and generates a list of the encompassed OSM tiles.
Legal
osmCopyrightText :: StringSource
The suggested copyright text in accordance with http://wiki.openstreetmap.org/wiki/Legal_FAQ