[Tilecache] Mercator calculations ( GMaps ) for tilecache Layer.py

Bill Woodall bwoodall at wardrobe.dhs.org
Sun Mar 25 04:34:08 EDT 2007


Hi Christopher, Schuyler, & List

** Work in Progress **

Attached is the lastest working copy of Layer.py and might not be the
best form of python, but it works!   OK, with one small intermittent bug
when using MetaTiles which I'm still tracking down :(

To use the code, add a line to your tilecache.cfg in the layer section
like;

projtype=mercator

Here is a breakdown of the issues that stop the stock TC from generating
tiles for overlays on a Google baselayer;

  * Google does not use square tiles
  * Tiles lat changes as you move away from the equator
    ( gets smaller as you move away )
  * Tiles are number ( decimal degrees ) from North to 
    South and West to East

So to address these, here is what is needed to get a Gmaps baselayer and
overlays to play nice 
*NOTE: I have mainly tested on WMS overlays so you mileage may vary


Tile
  * new parameter "projtype"

  * new g2ll(self, x, y, z)   
	Takes in decimal degress and generates and return the lonlat as 
        minx, miny, maxx, maxy

  * changes to bounds()
        Added a test to see which projection type ( projtype ) is used
        which are currently; None, mercator    
	(None is the normal mode )

MetaTile
  * changes to bounds()
	Added the projection type test

	New code to calculate the corrent bbox in Gmap style with the
	added twist of being a MetaTile size

Layer
  * changes to getCell()
	Added the projection type test

	Code to calculate the decimal degrees Gmap style

MetaLayer
  * changes to getMetaTile()
	Added the projection type test

  * changes to renderMetaTile()
	Added the projection type test

	Code to generate the correct decimal degree for the tiles after
	the metatile is sliced and diced


Enjoy,

............Bill,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Layer.py
Type: text/x-python
Size: 15442 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/tilecache/attachments/20070325/2ce8c9f0/Layer.py


More information about the Tilecache mailing list