[Tilecache] Basic Questions

Christopher Schmidt crschmidt at metacarta.com
Mon Sep 24 17:48:06 EDT 2007


On Mon, Sep 24, 2007 at 11:57:29AM -0700, Jeffrey Johnson wrote:
> Ok, some more questions.
> 
> I am calling tilecache like this in JS
> 
> 	map = new OpenLayers.Map( $('map'));
> 	currentLayer = new OpenLayers.Layer.WMS(layer_name,
> ["http://localhost/cgi-bin/tilecache-1.9/crystalnavigator.py?srcFile="
> + srcFile + "&layer_name=" + layer_name,
> "http://localhost/cgi-bin/tilecache-1.9/crystalnavigator.py?srcFile="
> + srcFile + "&layer_name=" + layer_name], {'layers':layer_name},
> {maxResolution:4, numZoomLevels:3, maxExtent: new
> OpenLayers.Bounds(0,0,1024,1024)});
> 	map.addLayer(currentLayer);
> 	map.zoomToMaxExtent();
> 
> and crystalnavigator.py looks like this
> 
> #!C:/Python25/python.exe -u
> 
> import cgi
> from TileCache.Service import Service, modPythonHandler, cgiHandler
> from TileCache.Layer import Layer, ImageLayer
> from TileCache.Cache import DiskCache
> 
> layerList = {}
> 
> form = cgi.FieldStorage()
> srcFile = form["srcFile"].value
> layer_name = form["layer_name"].value
> layerList[layer_name] = ImageLayer(layer_name, file=srcFile,
> filebounds="0,0,1024,1024", bbox="0,0,1024,1024",
> maxresolution="4",levels="3", extension="jpeg")
> 
> myService = Service (DiskCache("c:/tmp/crystalimagecache"), layerList)
> 
> def handler (req):
>     return modPythonHandler(req, myService)
> 
> if __name__ == '__main__':
>     cgiHandler(myService)
> 
> So, my question is. Is there someway that I can seed the cache or
> precache images when I am not using a cfg file like this.

Not trivially. However, there is a seed() function, which (as of latest
trunk about 3 hours ago) you can pass a Service and Layer to, and
pre-cache. If you read the code, you may be able to get it. 

> Likewise, is there someway to blow away the cache intelligently ...
> without just blowing away the entire directory structure.

Not for big caches. tilecache_clean does a last-modified based LRU
cleaning, but it's slow enough to be prohibitive with more than a gig or
two of tiles.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Tilecache mailing list