| |
- 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.
- "scale factor" (optional)
Scale multiplier used for Mapnik rendering pipeline. Used for
supporting retina resolution.
For more information about the scale factor, see:
https://github.com/mapnik/mapnik/wiki/Scale-factor
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, scale_factor=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)
| |