TileStache.Goodies.Providers.Monkeycache | index

`Monkeycache is a tile provider that reads data from an existing cache.
Normally, TileStache creates new tiles at request-time and saves them to a
cache for later visitors. Monkeycache supports a different workflow, where
a cache is seeded ahead of time, and then only existing tiles are served
from this cache.
For example, you might have a TileStache configuration with a Mapnik
provider, which requires PostGIS and other software to be installed on your
system. Monkeycache would allow you to seed that cache into a directory of
files or an MBTiles file on a system with a fast processor and I/O, and then
serve the contents of the cache from another system with a faster network
connection but no Mapnik or PostGIS.
Two sample configurations:
{
"cache": {"name": "Disk", "path": "/var/cache"},
"layers":
{
"expensive-layer":
{
"provider": {"name": "Mapnik", "mapfile": "style.xml"}
}
}
}
{
"cache": {"name": "Test"},
"layers":
{
"cheap-layer":
{
"provider":
{
"class": "TileStache.Goodies.Providers.Monkeycache:Provider",
"kwargs":
{
"layer_name": "expensive-layer",
"cache_config": {"name": "Disk", "path": "/var/cache"},
"format": "PNG"
}
}
}
}
}`

Classes

``

CacheResponse
Provider

class CacheResponse
`` | `Wrapper class for Cache 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: - body: Raw data pulled from cache. - format: File format to check against.`

Methods defined here:

__init__(self, body, format)

save(self, out, format)

class Provider
`` | `Monkeycache Provider with source_layer, source_cache and tile_format attributes. Source_layer is an instance of TileStache.Core.Layer. Source_cache is a valid TileStache Cache provider. Tile_format is a string.`

Methods defined here:

__init__(self, layer, cache_config, layer_name, format='PNG')
  `Initialize the Monkeycache Provider.
  Cache_config is a complete cache configuration dictionary that you
  might use in a TileStache setup (http://tilestache.org/doc/#caches).
  This is where Monkeycache will look for already-rendered tiles.
  Layer_name is the name of a layer saved in that cache.
  Format should match the second return value of your original
  layer's getTypeByExtention() method, e.g. "PNG", "JPEG", or for
  the Vector provider "GeoJSON" and others. This might not necessarily
  match the file name extension, though common cases like "jpg"/"JPEG"
  are accounted for.`

renderTile(self, width, height, srs, coord)
  `Pull a single tile from self.source_cache.`