TileStache.Goodies.Providers.Monkeycache module¶
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”}
}
}
}
}
-
class
TileStache.Goodies.Providers.Monkeycache.CacheResponse(body, format)¶ 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.
-
save(out, format)¶
-
-
class
TileStache.Goodies.Providers.Monkeycache.Provider(layer, cache_config, layer_name, format='PNG')¶ 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.
-
renderTile(width, height, srs, coord)¶ Pull a single tile from self.source_cache.
-