[Tilecache] Google Maps Overlay (image offset)

Josh Livni josh at umbrellaconsulting.com
Mon Jul 16 12:38:12 EDT 2007


Hi Steven,

I wouldn't go so far as to say I solved it, as much as I just made hack 
that worked for my use case.

Basically I modified tilecache so it would call my wms with the exact 
bounds that were originally passed to it, rather than use those bounds 
as a basis for deciding what would be the 'correct' tile to create, 
based on the tms grid defined by the resolutions.  This probably goes 
against what some people might think tilecache is all about, and breaks 
all kinds of things, not the least of which include metatiling, and who 
knows what else.  However - worked for my needs.

If I recall correctly, what I basically did was modify Layer.Tile such 
that it gets passed the original bounds (in a new parameter), and then 
modifed its bbox method to return the original bounds.  I also had to 
play with the threshold value, and the check value under the getLevel 
method, making both a bit larger depending on zoom level.

Again, this is probably _not_ the best way to solve this, I just needed 
to get some layers cached in a hurry.  I've been meaning to get time to 
try implement a more robust solution, but in the meantime you may want 
to use tschaubs method (meaning you have to use openlayers as a wrapper 
for google maps).  I'm also happy to email you my modified tilecache 
files if you want them, but I take no responsibility for whatever 
results might occur.

Finally, my tilecache.cfg has the following config:
================
[layername]
layers=some layers
type=WMSLayer
srs=EPSG:54004
bbox=-20040000,-28334952,20035017,13440066
resolutions=156543.031524,78271.515762,.....,0.298582137
================

Hope this helps,

 -Josh

Steven M. Ottens wrote:
> Hi Josh,
>
> Did you solve your googlemaps/tilecache problem? If so I'm interested in
> your configuration; I want to use tilecache to cache layers which are
> overlayed on top of google maps. So I need to know the resolutions to
> set in tilecache.cfg
>
> Regards,
> Steven
>
> Josh Livni wrote:
>   
>> Hi,
>>
>> I'm trying to overlay some tilecache images w/Google Maps.  It's 
>> certainly theoretically possible (see Tim Schaub's demo at 
>> http://dev.openlayers.org/sandbox/tschaub/google/examples/google-mercator.html) 
>>
>>
>> However, when I try use the Google API outside of OpenLayers, I get 
>> strange results.  Mainly, it seems the tiles that tilecache returns are 
>> shifted a bit - by a consistent geographical amount for most zoom 
>> levels, and by a large amount for a few zoomed out levels.
>> I spent much of yesterday looking at the code and setting some more 
>> debug notes, but ended up almost as confused as when I started. Here are 
>> a couple examples showing level 0.  The first one, a direct mapserver 
>> request, aligns perfectly on GMaps.  The 2nd, to Tilecache, has the same 
>> bbox but returns an offset image:
>> http://mapserver.eactive.org/cgi-bin/mapserv?map=/home/josh/tmp/world.map&TRANSPARENT=true&&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=world&STYLES=&FORMAT=image/gif&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&SRS=EPSG:54004&BBOX=-20037508.03516647,-19994872.957813744,20037508.03516647,19994874.171103183&WIDTH=256&HEIGHT=256&reaspect=false 
>>
>>
>> http://mapserver.eactive.org/tilecache/tilecache.py?TRANSPARENT=true&REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&LAYERS=world&STYLES=&FORMAT=image/gif&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&SRS=EPSG:54004&BBOX=-20037508.03516647,-19994872.957813744,20037508.03516647,19994874.171103183&WIDTH=256&HEIGHT=256&reaspect=false 
>>
>>
>> An example showing these two layers together can be found at 
>> http://gmaps.eactive.org/tctest.html
>>
>> It seems strange to me that not only does tilecache returns an offset 
>> image, but that OpenLayers deals with that perfectly - aligning the 
>> offset images nicely on top of Google Maps as shown in Tim's demo.
>> My tilecache layer config is:
>> [world]
>> type=WMSLayer
>> srs=EPSG:54004
>> bbox=-20040000,-26334952,20035017,13740066
>> resolutions=156543.031524,78271.515762,....,4.77731419445801
>> levels=16
>> url=http://mapserver.eactive.org/cgi-bin/mapserv?map=/home/josh/tmp/world.map&TRANSPARENT=true& 
>>
>> extension=gif
>> debug=true
>>
>> If anyone has any clues as to how to get tilecache's grid cells(?) to 
>> align more nicely with the GMap layout of the world, it would be greatly 
>> appreciated.
>>
>> Thanks,
>>
>>  -Josh
>>
>> _______________________________________________
>> Tilecache mailing list
>> Tilecache at openlayers.org
>> http://openlayers.org/mailman/listinfo/tilecache
>>   
>>     
>
>
>
>
> _______________________________________________
> Tilecache mailing list
> Tilecache at openlayers.org
> http://openlayers.org/mailman/listinfo/tilecache
>   



More information about the Tilecache mailing list