BSD-3-Clause licensed by Joe Canero
Maintained by [email protected]
This version can be pinned in stack with:mbtiles-0.6.0.0@sha256:763f23b6683dbc712490274dbce1d377ac0c3765926d0d7a3e102b8de1332c7b,1579

Module documentation for 0.6.0.0

mbtiles

Haskell library for interfacing with MapBox MBTiles files.

Documentation available on Hackage.

Functionality

  • Getting tiles by zoom, x, and y.
  • Writing new tiles by zoom, x, and y.
  • Updating existing tiles by zoom, x, and y.
  • Accessing metadata from the mbtiles file.

Basic Usage

Reading, writing, and updating tiles:

{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Lazy as BL
import           Database.Mbtiles

main = do
  let myData = "myTileData" :: BL.ByteString
  runMbtiles "my/path/to/file.mbtiles" $ do
    maybeTileData <- getTile (Z 0) (X 0) (Y 0)
    case maybeTileData of
      Nothing  -> writeTile (Z 0) (X 0) (Y 0) myData
      (Just d) -> updateTile (Z 0) (X 0) (Y 0) $ BL.init d

Getting metadata:


import Control.Monad.IO.Class
import Database.Mbtiles

main = do
  runMbtiles "my/path/to/file.mbtiles" $ do
    liftIO . print =<< getName
    liftIO . print =<< getType
    liftIO . print =<< getFormat

Future Work

  • Improve database error handling.
  • Investigate usage as a performant tile server.
  • Add tests.