[Tilecache] dir & file naming algorithm

Christopher Schmidt crschmidt at metacarta.com
Thu Jul 30 16:17:02 EDT 2009


On Thu, Jul 30, 2009 at 03:57:01PM -0400, Charlton Galvarino wrote:
> Hi, all.  I'm having a mental block why I can't reverse engineer the directory- and file-naming conventions used on a completely seeded layer.
> 
> Say that my request is http://somwhere.com/nws-cgi/tilecache-2.10/tilecache.cgi/1.0.0/ww/5/8/13.png?type=google.  I'm not a python programmer, but I believe that this is the meat of what I'm after:
> 
>     def getKey (self, tile):
>         components = ( self.basedir,
>                        tile.layer.name,
>                        "%02d" % tile.z,
>                        "%03d" % int(tile.x / 1000000),
>                        "%03d" % (int(tile.x / 1000) % 1000),
>                        "%03d" % (int(tile.x) % 1000),
>                        "%03d" % int(tile.y / 1000000),
>                        "%03d" % (int(tile.y / 1000) % 1000),
>                        "%03d.%s" % (int(tile.y) % 1000, tile.layer.extension)
>                     )
>         filename = os.path.join( *components )
>         return filename
> 
> So by that logic, I believe the filename I want is /ww/05/000/000/008/000/000/013.png.  However that image doesn't exist on disk.  The one that visually matches that CGI request is really /ww/05/000/000/008/000/000/018.png which does exist and looks beautiful.

You're ignoring the fact that your 'type=google' 'flips' things, so you have to
subtract that y value from the maximum y value for the layer. In the case of
your layer, it appears that you have 2^5 tiles in this zoom level in each
direction, numbered 0-31 -- so the y is '31 - 13', or 18.

You might be interested in using the GoogleDisk cache, which will put 
things on disk the same way as you are accessing them via psuedo-TMS.

-- CHris

> What the devil am I doing wrong?
> 
> Note that everything works splendidly when preseeding as well as overlaying the tiles via CGI onto a google map.  That's not the issue.
> 
> And why am I doing this?  The eventual host is CGI-phobic but does play PHP.  Since all the images have been preseeded, I'll wrap the logic that I'm trying to reverse engineer above in a little PHP script and send the image along.
> 
> TIA,
> 
> Charlton
> 
> 
> 
> 
> 
> Charlton Galvarino
> 1 (803) 233-6205 : voice
> 1 (803) 223-9579 :   fax
> charlton at 2creek.com
> 
> P.O. Box 50960
> Columbia, SC 29250
> 
> _______________________________________________
> Tilecache mailing list
> Tilecache at openlayers.org
> http://openlayers.org/mailman/listinfo/tilecache

-- 
Christopher Schmidt
MetaCarta



More information about the Tilecache mailing list