| tilecache(8) | GIS Utilities | tilecache(8) |
tilecache - Cache and serve map tiles
TileCache is a BSD licensed tile caching mechanism. The goal is to make it easy to set up a WMS or TMS frontend to any backend data services you might be interested in, using a pluggable caching and rendering mechanism.
TileCache was developed by MetaCarta Labs and released to the public under a BSD license.
The TileCache was designed as a companion to OpenLayers, the BSD licensed web mapping interface. If you are using TileCache with OpenLayers, please read the section of this readme which describes how to do so. For additional help with setting up TileCache for use with OpenLayers, please feel free to stop by #openlayers, on irc.freenode.net, or to send email to tilecache@openlayers.org.
http://yourmachine.example.com/cgi-bin/tilecache.cgi?LAYERS=basic&SERVICE=WMS&BBOX=-180,-90,0,90
http://yourmachine.example.com/cgi-bin/tilecache.cgi/1.0.0/basic/0/0/0.png
Alias /tiles /var/lib/python-support/python2.4/tilecache/ <Directory /var/lib/python-support/python2.4/>
SetHandler python-program
PythonHandler TileCache.Service
PythonOption TileCacheConfig /etc/tilecache.cfg </Directory>
TileCache includes standalone HTTP server which uses the WSGI handler. This implementation depends on Python Paste , which can be installed via the python-paste package.
For versions of Python earlier than 2.5, you will also need to install wsgiref:
http://cheeseshop.python.org/pypi/wsgiref
Once you have all the prerequisites installed, simply run:
/usr/sbin/tilecache_http_server
This will start a webserver listening on port 8080 (by default), after which you should be able to open:
http://yourmachine.example.com:8080/1.0.0/basic/0/0/0.png
to see your first tile.
TileCache includes a fastcgi implementation. In order to use this implementation, you will need to install flup, available from:
http://trac.saddi.com/flup
This implementation also depends on Python Paste, which can be downloaded via the python-paste package:
Once you have done this, you can configure your fastcgi server to use tilecache.fcgi.
Configuring FastCGI is beyond the scope of this documentation.
TileCache is configured by a config file, defaulting to /etc/tilecache.cfg. There are several parameters to control TileCache layers that are applicable to all layers:
To run OpenLayers with TileCache the URL passed to the OpenLayers.Layer.WMS constructor must point to the TileCache script, i.e. tilecache.cgi or tilecache.py. As an example see the example-cgi.html file included in the TileCache distribution, under /usr/share/doc/tilecache/examples/.
Note: example-cgi.html assumes TileCache is set up under CGI (see above). If you set up TileCache under mod_python you´d need to slighly modify example-cgi.html: the URL passed to the OpenLayers.Layer.WMS constructor must point to the mod_python script as opposed to the CGI script. Similarly, you would need to edit this URL if you were to use TileCache with the standalone HTTP Server or FastCGI.
The most important thing to do is to ensure that the OpenLayers Layer has the same resolutions and bounding box as your TileCache layer. You can define the resolutions in OpenLayers via the ´resolutions´ option or the ´maxResolution´ option on the layer. The maxExtent should be defined to match the bbox parameter of the TileCache layer.
MapServer has a map level metadata option, labelcache_map_edge_buffer, which is set automatically by TileCache to the metaBuffer plus five when metaTiling is on, if it is not set in the mapfile.
If you are using MetaTiling, be aware that MapServer generates interlaced PNG files, which PIL will not read. See http://mapserver.gis.umn.edu/docs/faq/pil_mapscript on how to resolve this.
The tilecache_seed utility will seed tiles in a cache automatically. You will need to have TileCache set up in one of the previously described configurations.
/usr/sbin/tilecache_seed [options] <layer> [<zoom start> <zoom stop>]
If called without zoom level arguments, tilecache_seed.py will seed zoom levels 5 to 17 and assume that it needs to read a list of points and radii from standard input, in the form:
<lat>,<lon>,<radius> <lat>,<lon>,<radius> <lat>,<lon>,<radius> <lat>,<lon>,<radius> <ctrl + d>
The format of this file is:
An example with zoom levels 5 through 12 would be like;
$ /usr/sbin/tilecache_seed -c /etc/tilecache.cfg -b "-118.12500,31.952162238,-116.015625,34.3071438563" Zip_Codes 5 12
The bbox can be dropped and defaults to world lonlat(-180,-90,180,90):
$ /usr/sbin/tilecache_seed.py -c /etc/tilecache.cfg Zip_Codes 0 9
In center point/radius mode, the zoom level range is not specifiable from the command-line. An example usage might look like:
$ /usr/sbin/tilecache_seed.py -c /etc/tilecache.cfg Zip_Codes -118.12500,31.952162238,0.05 -121.46327,32.345345645,0.08 <Ctrl+D>
... the seeding will then commence ...
The tilecache_clean utility will remove the least recently accessed tiles from a cache, down to a specified size.
/usr/sbin/tilecache_clean [options] <cache_location>
The --entries option to tilecache_clean.py is optional, and is used to regulate how much memory it uses to do its bookkeeping. The default value of 1 million will hopefully keep RAM utilization under about 100M on a 32-bit x86 Linux machine. If tilecache_clean.py doesn´t appear to be keeping your disk cache down to an appropriate size, try upping this value.
tilecache_clean is designed to be run from a cronjob like so:
00 05 * * * /usr/sbin/tilecache_clean.py -s500 /var/www/tilecache
Occasionally, for some reason, when using meta tiles, your server may leave behind lock files. If this happens, there will be files in your cache directory with the extension ´.lck´. If you are seeing tiles not render and taking multiple minutes before returning a 500 error, you may be suffering under a stuck lock.
Removing all files with extension ´.lck´ from the cache directory will resolve this problem.
http://tilecache.org/
http://openlayers.org/
http://wiki.osgeo.org/index.php/WMS_Tiling_Client_Recommendation
http://wiki.osgeo.org/index.php/Tile_Map_Service_Specification
crschmidt@metacarta.com
(c) 2006-2007 MetaCarta, Inc. Distributed under the BSD license.
| 2008-05-19 | 2.03 |