| Copyright | (c) Joe Canero 2017 |
|---|---|
| License | BSD3 |
| Maintainer | jmc41493@gmail.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Database.Mbtiles
Contents
Description
This module provides support for reading, writing, and updating an mbtiles database. There is also functionality for reading metadata from the database.
See the associated README.md for basic usage examples.
- data MbtilesT m a
- type Mbtiles a = MbtilesT IO a
- type MbtilesMeta = HashMap Text Text
- data MBTilesError
- newtype Z = Z Int
- newtype X = X Int
- newtype Y = Y Int
- class ToTile a where
- class FromTile a where
- runMbtilesT :: MonadIO m => FilePath -> MbtilesT m a -> m (Either MBTilesError a)
- runMbtiles :: FilePath -> Mbtiles a -> IO (Either MBTilesError a)
- getTile :: (MonadIO m, FromTile a) => Z -> X -> Y -> MbtilesT m (Maybe a)
- writeTile :: (MonadIO m, ToTile a) => Z -> X -> Y -> a -> MbtilesT m ()
- writeTiles :: (MonadIO m, ToTile a) => [(Z, X, Y, a)] -> MbtilesT m ()
- updateTile :: (MonadIO m, ToTile a) => Z -> X -> Y -> a -> MbtilesT m ()
- updateTiles :: (MonadIO m, ToTile a) => [(Z, X, Y, a)] -> MbtilesT m ()
- getMetadata :: MonadIO m => MbtilesT m MbtilesMeta
- getName :: MonadIO m => MbtilesT m Text
- getType :: MonadIO m => MbtilesT m Text
- getVersion :: MonadIO m => MbtilesT m Text
- getDescription :: MonadIO m => MbtilesT m Text
- getFormat :: MonadIO m => MbtilesT m Text
Types
MbtilesT monad that will run actions on an MBTiles file.
type MbtilesMeta = HashMap Text Text Source #
MBTiles files contain metadata in one of their tables. This is a type alias for a mapping between the metadata key and the metadata value.
data MBTilesError Source #
Data type representing various errors that could occur when opening and validating an MBTiles file.
Constructors
| DoesNotExist | The MBTiles file does not exist. |
| InvalidSchema | The MBTiles schema is invalid according to the spec. |
| InvalidMetadata | The MBTiles |
| InvalidTiles | The MBTiles |
Instances
Newtype wrapper around map zoom level.
Newtype wrapper around a tile's x-coordinate.
Newtype wrapper around a tile's y-coordinate.
Typeclasses
Typeclass representing data types that can be turned into a lazy ByteString and stored as tile data.
Minimal complete definition
Methods
toTile :: a -> ByteString Source #
Instances
class FromTile a where Source #
Typeclass representing data types intp which raw tile data can be converted.
Minimal complete definition
Methods
fromTile :: ByteString -> a Source #
Instances
The MbtilesT monad transformer
runMbtilesT :: MonadIO m => FilePath -> MbtilesT m a -> m (Either MBTilesError a) Source #
Given a path to an MBTiles file, run the MbtilesT action.
This will open a connection to the MBTiles file, run the action,
and then close the connection.
Some validation will be performed first. Of course, we will check if the
MBTiles file actually exists. If it does, we need to validate its schema according
to the MBTiles spec.
runMbtiles :: FilePath -> Mbtiles a -> IO (Either MBTilesError a) Source #
Specialized version of runMbtilesT to run in the IO monad.
Mbtiles read/write functionality
Mbtiles metadata functionality
getMetadata :: MonadIO m => MbtilesT m MbtilesMeta Source #
Returns the MbtilesMeta that was found in the MBTiles file.
This returns all of the currently available metadata for the MBTiles database.
getName :: MonadIO m => MbtilesT m Text Source #
Helper function for getting the specified name of the MBTiles from metadata.
getType :: MonadIO m => MbtilesT m Text Source #
Helper function for getting the type of the MBTiles from metadata.
getVersion :: MonadIO m => MbtilesT m Text Source #
Helper function for getting the version of the MBTiles from metadata.