[Tilecache] Basic Questions

Jeffrey Johnson ortelius at gmail.com
Mon Sep 24 14:57:29 EDT 2007


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.

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

Thanks,

Jeff

On 9/20/07, Jeffrey Johnson <ortelius at gmail.com> wrote:
> Got everything working perfectly today. Thanks so much for your help!!
>
> On 9/19/07, Jeffrey Johnson <ortelius at gmail.com> wrote:
> > On 9/19/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> > > On Wed, Sep 19, 2007 at 02:18:03PM -0700, Jeffrey Johnson wrote:
> > > > The error output is
> > > >
> > > > An error occurred: couldn't calculate tile index for layer
> > > > b000000012345_wA01-1_d20070829_t174940_i00_s2432_ from ([0.0, 1024.0,
> > > > 1024.0, 2048.0])
> > > This error message is much clearer in 1.9. Can you upgrade? That would
> > > let us know what resolutions there *are* there, so we can debug further.
> > >
> > > >
> > > > So, it looks like somehow I need to specify the maxResolution and the
> > > > bbox in my Layer definition when I am setting up the layers, but I
> > > > think I have done this correctly. What am I missing here.
> > >
> > > Whatever you're missing, I'm missing too.
> >
> > Whatever it was, its solved now. Not sure what I did to fix it, but oh
> > well, it works.
> >
> > > > Also, is this going to be a serious performance bottleneck to dive
> > > > through this directory and setup the layers everytime the script
> > > > Example.py is called? Any alternatives?
> > >
> > > Sure. Make the script parse the CGI args, and find the layer name, and
> > > only create a layer for that filename, might be one. Not sure how that
> > > will work -- parsing the query string with the cgi module might be a
> > > one-time-only thing -- but if it is, you can always poke at
> > > os.environ['QUERY_STRING'] directly instead.
> >
> > Will look into this, Thanks for the tips!
> >
> > Jeff
> >
>



More information about the Tilecache mailing list