Python: module TileStache.Mapnik

TileStache.Mapnik | index

`Mapnik Providers.
ImageProvider is known as "mapnik" in TileStache config, GridProvider is
known as "mapnik grid". Both require Mapnik to be installed; Grid requires
Mapnik 2.0.0 and above.`

Modules
`` |  |
PIL.Image | json | logging | os

Classes
`` |  | GridProvider ImageProvider SaveableResponse
class GridProvider
`` | `Built-in UTF Grid provider. Renders JSON raster objects from Mapnik. This provider is identified by the name "mapnik grid" in the Tilestache config, and uses Mapnik 2.0 (and above) to generate JSON UTF grid responses. Sample configuration for a single grid layer: "provider": { "name": "mapnik grid", "mapfile": "world_merc.xml", "fields": ["NAME", "POP2005"] } Sample configuration for multiple overlaid grid layers: "provider": { "name": "mapnik grid", "mapfile": "world_merc.xml", "layers": [ [1, ["NAME"]], [0, ["NAME", "POP2005"]], [0, null], [0, []] ] } Arguments: - mapfile (required) Local file path to Mapnik XML file. - fields (optional) Array of field names to return in the response, defaults to all. An empty list will return no field names, while a value of null is equivalent to all. - layer index (optional) Which layer from the mapfile to render, defaults to 0 (first layer). - layers (optional) Ordered list of (layer index, fields) to combine; if provided layers overrides both layer index and fields arguments. An empty fields list will return no field names, while a value of null is equivalent to all fields. - scale (optional) Scale factor of output raster, defaults to 4 (64x64). - layer id key (optional) If set, each item in the 'data' property will have its source mapnik layer name added, keyed by this value. Useful for distingushing between data items. Information and examples for UTF Grid: - https://github.com/mapbox/utfgrid-spec/blob/master/1.2/utfgrid.md - http://mapbox.github.com/wax/interaction-leaf.html`
| Methods defined here: __init__(self, layer, mapfile, fields=None, layers=None, layer_index=0, scale=4, layer_id_key=None) `Initialize Mapnik grid provider with layer and mapfile. XML mapfile keyword arg comes from TileStache config, and is an absolute path by the time it gets here.` getTypeByExtension(self, extension) `Get mime-type and format by file extension. This only accepts "json".` renderArea(self, width, height, srs, xmin, ymin, xmax, ymax, zoom) Static methods defined here: prepareKeywordArgs(config_dict) `Convert configured parameters to keyword args for __init__().`
class ImageProvider
`` | `Built-in Mapnik provider. Renders map images from Mapnik XML files. This provider is identified by the name "mapnik" in the TileStache config. Arguments: - mapfile (required) Local file path to Mapnik XML file. - fonts (optional) Local directory path to *.ttf font files. More information on Mapnik and Mapnik XML: - http://mapnik.org - http://trac.mapnik.org/wiki/XMLGettingStarted - http://trac.mapnik.org/wiki/XMLConfigReference`
| Methods defined here: __init__(self, layer, mapfile, fonts=None) `Initialize Mapnik provider with layer and mapfile. XML mapfile keyword arg comes from TileStache config, and is an absolute path by the time it gets here.` renderArea(self, width, height, srs, xmin, ymin, xmax, ymax, zoom) Static methods defined here: prepareKeywordArgs(config_dict) `Convert configured parameters to keyword args for __init__().`
class SaveableResponse
`` | `Wrapper class for JSON response that makes it behave like a PIL.Image object. TileStache.getTile() expects to be able to save one of these to a buffer.`
| Methods defined here: __init__(self, content, scale) crop(self, bbox) `Return a cropped grid response.` save(self, out, format)

Functions
`` |  | allocate_lock(...) `allocate_lock() -> lock object (allocate() is an obsolete synonym) Create a new lock object. See help(LockType) for information about locks.` decode_char(char) encode_id(id) get_mapnikMap(mapfile) `Get a new mapnik.Map instance for a mapfile` merge_grids(grid1, grid2) `Merge two UTF Grid objects.` time(...) `time() -> floating point number Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.`

Data
`` |  | absolute_import = _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0), 16384) global_mapnik_lock = <thread.lock object>