Archive

Posts Tagged ‘openlayers’

Transparent Overlays in TileCache

March 31st, 2007 rupert Comments off

From the tilecache mailing list….

Hi Everyone,

Really appreciate all the replies…

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

[root@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
     NAME png
     DRIVER "GD/PNG"
     MIMETYPE "image/png"
     IMAGEMODE RGB
     EXTENSION "png"
     FORMATOPTION "INTERLACE=OFF"
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

On Fri, Mar 30, 2007 at 01:57:43PM +0800, Rupert de Guzman Jr wrote:
> Hi Everyone,
>
> Really appreciate all the replies…
> 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…

TileCache pays almost no attention to the URL: Only the BBOX and the layername matter. Anything else is simply ignored: so your transparency being set in OpenLayers actually has 0 affect.

The reason for this is that TileCache can only store one copy of an image. If the URL parameters modified the content, you could get an inconsistent cache.

This is ‘by design’, insofar as there is no obvious solution (other than to complain more loudly when TC Gets parameters it isn’t expecting, which is an outstanding FIXME in the code). The lack of error message is not by design, and I’m sorry you got bit by the poorly documented behavior.

Regards,

Christopher Schmidt
MetaCarta

OpenLayers and Google Layer Zoom fix

February 20th, 2007 rupert Comments off

I have finally fixed the disappearing layer on the layer switch when we try to overlay the layer on top of Google. I edited Google.js to reflect the ff:

 
    MAX_ZOOM_LEVEL: 22,
 
    /** Hardcode these resolutions so that they are more closely
     *   tied with the standard wms projection
     *
     * @final @type Array(float) */
/*    RESOLUTIONS: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125],*/
 
RESOLUTIONS:[1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625,0.010986328125,0.0054931640625,0.00274658203125,0.001373291015625,0.0006866455078125,0.00034332275390625,0.000171661376953125,0.0000858306884765625,0.00004291534423828125,0.0000214576721191140625,0.000107288360595703125,0.0000053644182978515625,0.000002682209014892578125,0.0000013411045074462890625,0.00000067055225372314453125],
Categories: openlayers Tags: ,

TileCache Experiment

February 16th, 2007 rupert Comments off

I am now able to do tilecache using TileCache1.3 from metacarta. Base from archives (archive-user.txt)

From crschmidt at metacarta.com  Wed Nov 22 17:54:29 2006
From: crschmidt at metacarta.com (Christopher Schmidt)
Date: Wed, 22 Nov 2006 17:54:29 -0500
Subject: [OpenLayers-Users] TileCache - Tiling issues
In-Reply-To: <4564D326.6020607@refractions.net>
References: <4564D326.6020607@refractions.net>
Message-ID: <20061122225429.GA18180@metacarta.com>
 
On Wed, Nov 22, 2006 at 02:45:58PM -0800, Ben Brehmer wrote:
> Hello everyone,
>
> I have setup a basic OpenLayers application with TileCache doing the
> server-side caching. I was wondering if there is a way to pre-cache all
> the tiles (besides panning/zooming everywhere on the map)? I know in
> kamap there is a script that can be run to pre-cache all the tiles. Is
> there something similair for TileCache?
 
In the TileCache directory, there is a 'Client.py' script. To pre-cache
your data, use it in the following manner:
 
python Client.py "http://example.com/tilecachelocation/tilecache.cgi?"
"layername" startzoomlevel endzoomlevel [BBOX]
 
Something like:
 
python Client.py "http://labs.metacarta.com/wms-c/Basic.py?" "basic" 0 16
 
Is what we used to precache all of the Vmap0 data in the MetaCarta VMap0
layer.
 
> Also, I have attached two jpegs. Each has part of a symbol or label
> chopped off. I believe that the "chopping" occurs at the edge of a tile.
> Has anyone ever experience something like this in OpenLayers?
 
This is based on your Mapserver setup, rather than something specific in
OpenLayers. Using WMS would result in the same visual result. Labels can
have this prevented using the "PARTIALS OFF" on your label layer, if
you're using Mapserver. I'm not aware of a way to prevent this in symbol
generation. 
 
We are currently working on ka-map style rendering to add to TileCache,
to help people not run into this issue. No timeframe available yet on
when that'll be released. 
 
Regards,
--
Christopher Schmidt
MetaCarta

1. TileCache Configuration: tilecache.cfg

[cache]
type=DiskCache
base=E:\\usr\\local\\apache2\\htdocs\\tmp\\
 
[basemap]
type=WMSLayer
url=http://127.0.0.1/cgi-bin/mapserv.exe?map=/home/basemap/wmstest_longlat.map
layers=district,greens,major_river,minor_river
extension=png
 
[roads]
type=WMSLayer
url=http://127.0.0.1/cgi-bin/mapserv.exe?map=/home/basemap/wmstest_longlat.map
layers=road4,road4label,road3,road3label,road2,road2label,road1,road1label,road11,road11label
extension=png

2. Calling CFM Script: Test.cfm

    <cfset request.mapserv="http://127.0.0.1/tilecache/tilecache.py"> 
 
    <script src="/OpenLayers-2.2/lib/OpenLayers.js"></script>
    <script type="text/javascript"></script>
        <!--<br /-->        //var lon = 116.3842;
        //var lat = 39.9150;
        var lon = 116.3846;
        var lat = 39.9202;
        var zoom = 16;
        var map, markers;
 
        function init(){
      	    map = new OpenLayers.Map( $('map'), { maxResolution: 'auto'});
 
	    var layer_base = new OpenLayers.Layer.WMS(
					"Base Layer",
					"#request.mapserv#",
					{
						layers: 'basemap',
						format: 'png', 'transparent': 'off'
					}
					);
 
                map.addLayer(layer_base);
	   layer_base.setIsBaseLayer(true);	
 
               ...more code here...
 
       }
</cfset>

I want to fine tune this script since I am getting odd tiles like duplicate tiles or tiles shown of different scale on the same scale.

3. Precaching:
/d/Python24/python.exe Client.py “http://127.0.0.1/tilecache/tilecache.py” “roads” 14 16 116.35397,39.88984,116.42988,39.91918

I need to understand the “cache hit” or “cache miss” during execution.

Categories: mapserver, tilecache Tags: ,