TileStache package¶
Subpackages¶
- TileStache.Goodies package
- Subpackages
- TileStache.Goodies.Caches package
- TileStache.Goodies.Providers package
- Submodules
- TileStache.Goodies.Providers.Cascadenik module
- TileStache.Goodies.Providers.Composite module
- TileStache.Goodies.Providers.GDAL module
- TileStache.Goodies.Providers.Grid module
- TileStache.Goodies.Providers.MapnikGrid module
- TileStache.Goodies.Providers.MirrorOSM module
- TileStache.Goodies.Providers.Monkeycache module
- TileStache.Goodies.Providers.PostGeoJSON module
- TileStache.Goodies.Providers.SolrGeoJSON module
- TileStache.Goodies.Providers.TileDataOSM module
- TileStache.Goodies.Providers.UtfGridComposite module
- TileStache.Goodies.Providers.UtfGridCompositeOverlap module
- Module contents
- Submodules
- TileStache.Goodies.VecTiles package
- Submodules
- TileStache.Goodies.VecTiles.client module
- TileStache.Goodies.VecTiles.geojson module
- TileStache.Goodies.VecTiles.mvt module
- TileStache.Goodies.VecTiles.ops module
- TileStache.Goodies.VecTiles.pbf module
- TileStache.Goodies.VecTiles.server module
- TileStache.Goodies.VecTiles.topojson module
- TileStache.Goodies.VecTiles.wkb module
- Module contents
- Submodules
- Submodules
- Module contents
- Subpackages
- TileStache.Vector package
Submodules¶
- TileStache.Caches module
- TileStache.Config module
- TileStache.Core module
- TileStache.Geography module
- TileStache.MBTiles module
- TileStache.Mapnik module
- TileStache.Memcache module
- TileStache.PixelEffects module
- TileStache.Pixels module
- TileStache.Providers module
- TileStache.Redis module
- TileStache.S3 module
- TileStache.Sandwich module
- TileStache.Tornado module
Module contents¶
A stylish alternative for caching your map tiles.
TileStache is a Python-based server application that can serve up map tiles based on rendered geographic data. You might be familiar with TileCache (http://tilecache.org), the venerable open source WMS server from MetaCarta. TileStache is similar, but we hope simpler and better-suited to the needs of designers and cartographers.
Documentation available at http://tilestache.org/doc/
-
class
TileStache.WSGITileServer(config, autoreload=False)¶ Create a WSGI application that can handle requests from any server that talks WSGI.
- This class is documented as part of TileStache’s public API:
- http://tilestache.org/doc/#wsgi
The WSGI application is an instance of this class. Example:
app = WSGITileServer(‘/path/to/tilestache.cfg’) werkzeug.serving.run_simple(‘localhost’, 8080, app)
-
TileStache.cgiHandler(environ, config='./tilestache.cfg', debug=False)¶ Read environment PATH_INFO, load up configuration, talk to stdout by CGI.
- This function is documented as part of TileStache’s public API:
- http://tilestache.org/doc/#cgi
Calls requestHandler().
Config parameter can be a file path string for a JSON configuration file or a configuration object with ‘cache’, ‘layers’, and ‘dirpath’ properties.
-
TileStache.getPreview(layer)¶ Get a type string and dynamic map viewer HTML for a given layer.
-
TileStache.getTile(layer, coord, extension, ignore_cached=False)¶ Get a type string and tile binary for a given request layer tile.
- This function is documented as part of TileStache’s public API:
- http://tilestache.org/doc/#tilestache-gettile
Arguments: - layer: instance of Core.Layer to render. - coord: one ModestMaps.Core.Coordinate corresponding to a single tile. - extension: filename extension to choose response type, e.g. “png” or “jpg”. - ignore_cached: always re-render the tile, whether it’s in the cache or not.
This is the main entry point, after site configuration has been loaded and individual tiles need to be rendered.
-
TileStache.mergePathInfo(layer, coord, extension)¶ Converts layer name, coordinate and extension back to a PATH_INFO string.
See also splitPathInfo().
-
TileStache.modpythonHandler(request)¶ Handle a mod_python request.
TODO: Upgrade to new requestHandler() so this can return non-200 HTTP.
Calls requestHandler().
Example Apache configuration for TileStache:
- <Directory /home/migurski/public_html/TileStache>
- AddHandler mod_python .py PythonHandler TileStache::modpythonHandler PythonOption config /etc/tilestache.cfg
</Directory>
Configuration options, using PythonOption directive: - config: path to configuration file, defaults to “tilestache.cfg”,
using request.filename as the current working directory.
-
TileStache.parseConfig(configHandle)¶ Parse a configuration file and return a Configuration object.
Configuration could be a Python dictionary or a file formatted as JSON. In both cases it needs to be formatted with two sections, “cache” and “layers”:
- {
“cache”: { ... }, “layers”: {
“layer-1”: { ... }, “layer-2”: { ... }, ...}
}
The full path to the file is significant, used to resolve any relative paths found in the configuration.
See the Caches module for more information on the “caches” section, and the Core and Providers modules for more information on the “layers” section.
-
TileStache.parseConfigfile(configHandle)¶ Parse a configuration file and return a Configuration object.
Configuration could be a Python dictionary or a file formatted as JSON. In both cases it needs to be formatted with two sections, “cache” and “layers”:
- {
“cache”: { ... }, “layers”: {
“layer-1”: { ... }, “layer-2”: { ... }, ...}
}
The full path to the file is significant, used to resolve any relative paths found in the configuration.
See the Caches module for more information on the “caches” section, and the Core and Providers modules for more information on the “layers” section.
-
TileStache.requestHandler(config_hint, path_info, query_string=None)¶ Generate a mime-type and response body for a given request.
- This function is documented as part of TileStache’s public API:
- http://tilestache.org/doc/#tilestache-requesthandler
TODO: replace this with requestHandler2() in TileStache 2.0.0.
Calls requestHandler2().
-
TileStache.requestHandler2(config_hint, path_info, query_string=None, script_name='')¶ Generate a set of headers and response body for a given request.
TODO: Replace requestHandler() with this function in TileStache 2.0.0.
Requires a configuration and PATH_INFO (e.g. “/example/0/0/0.png”).
Config_hint parameter can be a path string for a JSON configuration file or a configuration object with ‘cache’, ‘layers’, and ‘dirpath’ properties.
Query string is optional, currently used for JSON callbacks.
Calls Layer.getTileResponse() to render actual tiles, and getPreview() to render preview.html.
-
TileStache.requestLayer(config, path_info)¶ Return a Layer.
Requires a configuration and PATH_INFO (e.g. “/example/0/0/0.png”).
Config parameter can be a file path string for a JSON configuration file or a configuration object with ‘cache’, ‘layers’, and ‘dirpath’ properties.
-
TileStache.splitPathInfo(pathinfo)¶ Converts a PATH_INFO string to layer name, coordinate, and extension parts.
Example: “/layer/0/0/0.png”, leading “/” optional.