Python: module TileStache.MBTiles

TileStache.MBTiles | index

`Support for MBTiles file format, version 1.1.
MBTiles (http://mbtiles.org) is a specification for storing tiled map data in
SQLite databases for immediate use and for transfer. The files are designed for
portability of thousands, hundreds of thousands, or even millions of standard
map tile images in a single file.
This makes it easy to manage and share map tiles.
Read the spec:
https://github.com/mapbox/mbtiles-spec/blob/master/1.1/spec.md
MBTiles files generated by other applications such as Tilemill or Arc2Earth
can be used as data sources for the MBTiles Provider.
Example configuration:
{
"cache": { ... }.
"layers":
{
"roads":
{
"provider":
{
"name": "mbtiles",
"tileset": "collection.mbtiles"
}
}
}
}
MBTiles provider parameters:
tileset:
Required local file path to MBTiles tileset file, a SQLite 3 database file.`

Classes
`` |  | Cache Provider TileResponse
class Cache
`` | `Cache provider for writing to MBTiles files. This class is not exposed as a normal cache provider for TileStache, because MBTiles has restrictions on file formats that aren't quite compatible with some of the looser assumptions made by TileStache. Instead, this cache provider is provided for use with the script tilestache-seed.py, which can be called with --to-mbtiles option to write cached tiles to a new tileset.`
| Methods defined here: __init__(self, filename, format, name) lock(self, layer, coord, format) read(self, layer, coord, format) `Return raw tile content from tileset.` remove(self, layer, coord, format) `Remove a cached tile.` save(self, body, layer, coord, format) `Write raw tile content to tileset.` unlock(self, layer, coord, format)
class Provider
`` | `MBTiles provider. See module documentation for explanation of constructor arguments.`
| Methods defined here: __init__(self, layer, tileset) getTypeByExtension(self, extension) `Get mime-type and format by file extension. This only accepts "png" or "jpg" or "json".` renderTile(self, width, height, srs, coord) `Retrieve a single tile, return a TileResponse instance.` Static methods defined here: prepareKeywordArgs(config_dict) `Convert configured parameters to keyword args for __init__().`
class TileResponse
`` | `Wrapper class for tile response that makes it behave like a PIL.Image object. TileStache.getTile() expects to be able to save one of these to a buffer. Constructor arguments: - format: 'PNG' or 'JPEG'. - content: Raw response bytes.`
| Methods defined here: __init__(self, format, content) save(self, out, format)

Functions
`` |  | create_tileset(filename, name, type, version, description, format, bounds=None) `Create a tileset 1.1 with the given filename and metadata. From the specification: The metadata table is used as a key/value store for settings. Five keys are required: name: The plain-english name of the tileset. type: overlay or baselayer version: The version of the tileset, as a plain number. description: A description of the layer as plain text. format: The image file format of the tile data: png or jpg or json One row in metadata is suggested and, if provided, may enhance performance: bounds: The maximum extent of the rendered map area. Bounds must define an area covered by all zoom levels. The bounds are represented in WGS:84 - latitude and longitude values, in the OpenLayers Bounds format - left, bottom, right, top. Example of the full earth: -180.0,-85,180,85.` delete_tile(filename, coord) `Delete a tile by coordinate.` get_tile(filename, coord) `Retrieve the mime-type and raw content of a tile by coordinate. If the tile does not exist, None is returned for the content.` list_tiles(filename) `Get a list of tile coordinates.` put_tile(filename, coord, content) tileset_exists(filename) `Return true if the tileset exists and appears to have the right tables.` tileset_info(filename) `Return name, type, version, description, format, and bounds for a tileset. Returns None if tileset does not exist.`