[Tilecache] TileCache Transparent Overlays. Is it possible?

Rupert de Guzman Jr rupert at mapcentral.ph
Fri Mar 30 01:57:43 EDT 2007


Hi Everyone,

Really appreciate all the replies...

1. Installed Imaging-1.1.6.tar.gz (PIL).

[root at rupert-linux ~]# python
Python 2.3.4 (#1, Mar 10 2006, 06:12:09)
[GCC 3.4.5 20051201 (Red Hat 3.4.5-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python23.zip', '/usr/lib/python2.3',
'/usr/lib/python2.3/plat-linux2', '/usr/lib/python2.3/lib-tk',
'/usr/lib/python2.3/lib-dynload', '/usr/lib/python2.3/site-packages',
'/usr/lib/python2.3/site-packages/PIL',
'/usr/lib/python2.3/site-packages/gtk-2.0']
>>> 

2. Modified test1.cfm 
     41         var options = {
     42                         controls: [new
OpenLayers.Control.MouseDefaults()]
     43                       };
     44
     45         map = new OpenLayers.Map( $('map'), options);
     46
     47         var layer_base = new OpenLayers.Layer.WMS(
     48                     "Base Layer",
     49                     "#request.mapserv_tile#",
     50                     {
     51                         map: '/home/map/beijing/new/wms.map',
     52                         layers: '#request.basemap_tile#',
     53                         format: 'image/png', 'transparent': 'false'
     54                     }
     55                     );
     56
     57         var layer_road = new OpenLayers.Layer.WMS(
     58                     "Road Layer",
     59                     "#request.mapserv_tile#",
     60                     {
     61                         map: '/home/map/beijing/new/wms.map',
     62                         layers: '#request.roads_tile#',
     63                         format: 'image/png', 'transparent': 'true'
     64                     },
     65                     {
     66                         reproject: false
     67                     }
     68                     );
     69
     70         map.addLayer(layer_base);
     71         layer_base.setIsBaseLayer(true);
     72
     73         layer_road.setIsBaseLayer(false);
     74         map.addLayer(layer_road);

3. tilecache.cfg. Commented metaTile=true
http://222.128.19.19/tilecache/tilecache.cfg
     47 [basemap]
     48 type=WMSLayer
     49
url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/wms.map
     50 layers=district,greens,major_river,minor_river
     51 #bbox=-180,-90,180,90
     52 #metaTile=true
     53 extension=png
     54
     55 [roads]
     56 type=WMSLayer
     57
url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/wms.map
     58
#layers=road4,road4label,road3,road3label,road2,road2label,road1,road1label,
road11,road11label
     59 #bbox=116.1737,39.8211,116.5640,40.0799
     60 #maxresolution=1.40625
     61 #bbox=-180,-90,180,90
     62 layers=road1,road1label,road11,road11label
     63 extension=png
     64 #metaTile=true

4. Modified wms.map http://222.128.19.19/tilecache/wms.map
 OUTPUTFORMAT
      9   NAME png
     10   DRIVER "GD/PNG"
     11   MIMETYPE "image/png"
     12   IMAGEMODE RGB
     13   EXTENSION "png"
     14   FORMATOPTION "INTERLACE=OFF"
     15 END

5. Checked access_log. "transparent=true" exists...

192.168.1.150 - - [30/Mar/2007:13:46:26 +0800] "GET
/tilecache/tilecache.py?MAP=%2Fhome%2Fmap%2Fbeijing%2Fnew%2Fwms.map&LAYERS=r
oads&FORMAT=image%2Fpng&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=G
etMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BB
OX=116.334229%2C39.891357%
2C116.345215%2C39.902344&WIDTH=256&HEIGHT=256 HTTP/1.1" 200 14580

Now, this is really weird. I have "transparent": true in test1.cfm all the
time. That didn't worked. 

For every test iteration i made, I always tried clearing the cache, removing
the python
compiled scripts, then restarting Apache just to get a clean state..

rm -Rf /usr/local/apache2/htdocs/tmp/*
rm /wwwroot/tilecache/TileCache/*.pyc
/etc/init.d/httpd restart

Then I tried appending "transparent=true" to tilecache.cfg based on Eric's
suggestion...
That worked. Now I wonder why... Nevertheless, its working now. Again many
thanks
to everyone...

Rupert


> -----Original Message-----
> From: Bill Woodall [mailto:bwoodall at wardrobe.dhs.org] 
> Sent: Friday, March 30, 2007 10:02 AM
> To: Rupert de Guzman Jr
> Cc: tilecache at openlayers.org
> Subject: Re: [Tilecache] TileCache Transparent Overlays. Is 
> it possible?
> 
> Hi Rupert,
> 
> Yes, several of us have TC with tranparent overlays.
> 
> First, looking at our test1.cfm;
> Lines 56,57 and 70,71 go into options{}
> 
> Second try running TC without metaTile, to see if is an issue 
> with Python Image Lib (PIL).
> 
> Last, how are your PNG images set?
> here is a FAQ by hobu
> http://mapserver.gis.umn.edu/docs/faq/pil_mapscript
> 
> 
> ......Bill,
> 
> On Fri, 2007-03-30 at 09:08 +0800, Rupert de Guzman Jr wrote:
> > Hi Everybody,
> > 
> > Has anyone ever displayed a transparent overlay using TileCache 1.4?
> > It just doesn't seem to work for me.. 
> > 
> > Anyhow, I have two files up for viewing. "test1.cfm" is using 
> > tilecache both on the baselayer (basemap) and the overlay 
> (roads). The 
> > baselayer shows up without any problems. The roads shows up 
> but the layer is not transparent..
> > 
> > http://222.128.19.19/tilecache/test1.cfm
> > 
> > I have added "test2.cfm" which shows transparent layers but 
> not using TC...
> > 
> > http://222.128.19.19/tilecache/test2.cfm
> > 
> > tilecache.cfg http://222.128.19.19/tilecache/ (viewable)
> > +++++++++++++++++++++++++++++++++++
> > [basemap]
> > type=WMSLayer
> > 
> url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/wms.map
> > layers=district,greens,major_river,minor_river
> > bbox=-180,-90,180,90
> > #maxresolution=1.40625
> > metaTile=true
> > extension=png
> > 
> > [roads]
> > type=WMSLayer
> > 
> url=http://127.0.0.1/cgi-bin/mapserv?map=/home/map/beijing/new/wms.map
> > 
> #layers=road4,road4label,road3,road3label,road2,road2label,road1,road1
> > label,
> > road11,road11label
> > #bbox=116.1737,39.8211,116.5640,40.0799
> > #maxresolution=1.40625
> > bbox=-180,-90,180,90
> > layers=road1,road1label,road11,road11label
> > extension=png
> > metaTile=true
> > 
> > test1.cfm
> > +++++++++++++++++++++++++++++++++++++
> > 
> >      13     <cfset request.mapserv_plain = "/cgi-bin/mapserv" />
> >      14     <cfset request.mapserv_tile = 
> "/tilecache/tilecache.py" />
> >      15
> >      16     <cfset request.basemap_plain =
> > "district,greens,major_river,minor_river" />
> >      17     <cfset request.basemap_tile = "basemap" />
> >      18
> >      19     <cfset request.roads_plain =
> > 
> "road4,road4label,road3,road3label,road2,road2label,road1,road1label,r
> > oad11,
> > road11label" />
> >      20     <cfset request.roads_tile = "roads" />
> >      21
> >      22     <script src="/OpenLayers/lib/OpenLayers.js"></script>
> >      23     <script type="text/javascript">
> >      24         <!--
> >      25         //var lon = 116.3842;
> >      26         //var lat = 39.9150;
> >      27         var lon = 116.3846;
> >      28         var lat = 39.9202;
> >      29         var zoom = 15;
> >      30         var map;
> > .....
> >      36         function init(){
> >      37
> >      38         OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
> >      39
> >      40         var options = {
> >      41                         controls: [new
> > OpenLayers.Control.MouseDefaults()],
> >      42                         'numZoomLevels': 20
> >      43                       };
> >      44
> >      45         map = new OpenLayers.Map( $('map'), options);
> >      46
> >      47         var layer_base = new OpenLayers.Layer.WMS(
> >      48                     "Base Layer",
> >      49                     "#request.mapserv_tile#",
> >      50                     {
> >      51                         map: 
> '/home/map/beijing/new/wms.map',
> >      52                         layers: '#request.basemap_tile#',
> >      53                         format: 'image/png', 
> 'transparent': 'false'
> >      54                     },
> >      55                     {
> >      56                         'numZoomLevels': 20 ,
> >      57                         maxExtent: new 
> OpenLayers.Bounds(-180, -90,
> > 180, 90)
> >      58                     }
> >      59                     );
> >      60
> >      61         var layer_road = new OpenLayers.Layer.WMS(
> >      62                     "Road Layer",
> >      63                     "#request.mapserv_tile#",
> >      64                     {
> >      65                         map: 
> '/home/map/beijing/new/wms.map',
> >      66                         layers: '#request.roads_tile#',
> >      67                         format: 'image/png', 
> 'transparent': 'TRUE'
> >      68                     },
> >      69                     {
> >      70                         'numZoomLevels': 20 ,
> >      71                         maxExtent: new 
> OpenLayers.Bounds(-180, -90,
> > 180, 90),
> >      72                         reproject: false
> >      73                     }
> >      74                     );
> >      75
> >      76         map.addLayer(layer_base);
> >      77         layer_base.setIsBaseLayer(true);
> >      78
> >      79         layer_road.setIsBaseLayer(false);
> >      80         map.addLayer(layer_road);
> >      81
> >      82
> >      83         map.setCenter(new OpenLayers.LonLat(lon, 
> lat), zoom);
> >      84         map.addControl( new 
> OpenLayers.Control.LayerSwitcher() );
> >      85         map.addControl( new 
> OpenLayers.Control.PanZoomBar());
> >      86
> >      87         }
> > 
> > Appreciate it if someone could post some code snippets showing 
> > transparent overlays in TC..
> > 
> > Best Regards,
> > 
> > Rupert
> > 
> > _______________________________________________
> > Tilecache mailing list
> > Tilecache at openlayers.org
> > http://openlayers.org/mailman/listinfo/tilecache
> 
> 




More information about the Tilecache mailing list