[Tilecache] Configuration of TileCache and OpenLayers

Jonathan W. Lowe jlowe at giswebsite.com
Fri Feb 15 15:42:10 EST 2008


TileCachers:

Newbie support request...  Can anyone spot what must be a naive mistake
in how I've set up the following TileCache and OpenLayers test?  

The first two tests were encouraging, but the combining TileCache and
OpenLayers failed despite many tweaks to many configuration values.

To debug, I copied samples of the OpenLayers WMS requests from apache's
access_log into a browser and got a resolution error indicating that the
BBOX values OpenLayers requested did not match the fixed resolutions of
the TileCache layer.

For example:  

http://www.giswebsite.com/cgi-bin/tilecache/tilecache.cgi?
LAYERS=tcbox&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&
REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&
SRS=EPSG%3A26943&BBOX=1843540,654759,1843900,655119&WIDTH=256&HEIGHT=256

...returns:

An error occurred: can't find resolution index for 1.406250. 
Available resolutions are:  [40.0, 20.0, 10.0, 5.0, 2.5]

Looks like the tiles are not appearing in the html page because the WMS
requests fail.  So, I suspect some configuration error, although have
attempted to stick to the instructions, such as setting BBOX values
identically across all files. 

Thanks in advance,
Jonathan


Installation details:

TileCache version:  2.01
OpenLayers version: 2.5
MapServer version: 5.0.2
Python version: 2.4.4
OS: FreeBSD


Test details:

Test 1) Success!
http://www.giswebsite.com/cgi-bin/tilecache/tilecache.cgi/1.0.0/tcbox/0/0/0.png

Test 2) Success!
http://www.giswebsite.com/cgi-bin/tilecache/tilecache.cgi?
LAYERS=tcbox&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&
SRS=EPSG:26943&BBOX=1838500,648999,1848740,659239&WIDTH=256&HEIGHT=256&

Test 3) Failure!
http://www.giswebsite.com/demos/tcbox.html


Test 3 configuration details:

a) Contents of tilecache.cfg layer [tcbox]:

[tcbox]
type=MapServerLayer
mapfile=/home/gisweb/www/cgi-bin/tcbox.map
layers=parks
extension=png
size=256,256
bbox=1838500,648999,1848740,659239
srs=EPSG:26943
levels=5
metaTile=true
metaSize=5,5
metaBuffer=10
mime_type=image/png


b) Relevant contents of Mapserver mapfile, tcbox.map:

# Berkeley test area in California Stateplane, zone III, NAD83, Meters.
MAP
NAME "tcbox"
EXTENT 1838500 648999 1848740 659239
SIZE 256 256
IMAGETYPE PNG
IMAGEQUALITY 85
INTERLACE off
RESOLUTION 96
UNITS meters
TRANSPARENT off
OUTPUTFORMAT
  NAME png
  DRIVER "GD/PNG"
  MIMETYPE "image/png"
  IMAGEMODE RGB
  EXTENSION "png"
  FORMATOPTION  "INTERLACE=OFF"
END
PROJECTION
 "init=epsg:26943"
END
<...etc..>

c) Contents of OpenLayers page, tcbox.html:

<html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>TileCache PoC</title>
<link REL="shortcut icon" TYPE="image/ico" href="/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8"></meta>
    <style type="text/css">
        #map {
            width: 256px;
            height: 256px;
            border: 1px solid gray;
        }
    </style>
    <script type="text/javascript" src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
                var map, vectors, controls, match;
                var tilecacheBbox = new OpenLayers.Bounds(
					1838500,648999,1848740,659239);
                function init(){
                        var lon = 1843620;
                        var lat = 654119;
                        var zoom = 3
                        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 1;
                        var map_options = {
                                maxExtent: tilecacheBbox,
                                projection:"EPSG:26943",
                                units: "meters",
                                numZoomLevels: 5
                        };
                        map = new OpenLayers.Map("map", map_options);
                        layer = new OpenLayers.Layer.WMS(
                                "tcbox",
           "http://www.giswebsite.com/cgi-bin/tilecache/tilecache.cgi?",
                                {layers: 'tcbox', format: 'image/png' }
                        );
                        map.addLayers([layer]);
                        map.setCenter(
				new OpenLayers.LonLat(lon, lat), zoom);
                        map.addControl(
				new OpenLayers.Control.MousePosition());
                };
    </script>
</head>
<body onload="init()">
      <div id="map"></div>
</body>
</html>

-----------------------




More information about the Tilecache mailing list