[mapserver-users] TileCache + MapServer + Openalyers + WMS (Google Mercator)

Òscar Vidal Calbet oscarblo at gmail.com
Mon Feb 28 07:33:06 PST 2011


Hi everyone!

I'm using TileCache + MapServer + OpenLayers and trying to publish a
WMS from Geotiff in Mercator (EPSG:900913).  I'm having difficulties
and the result is not that I expect. Below are the different parts of
my problems.


Bathymetry.tif
================================
Geotiff file in  EPSG:900913
Corner Coordinates:
Upper Left  (-5038852, 5970000)
Lower Left  (-5038852, 3420000)
Upper Right (-1412452, 5970000)
Lower Right (-1412452, 3420000)


WMS.map
================================
MAP
       NAME "WMS-test"
       STATUS ON
       SIZE 600 400

       # its The same extend that the file Bathymetry.tif in projected
coordinates.  Have to be in geographic?
       EXTENT -5038852 3420000 -1412356 5970000
       # Bathymetry.tif extend in geographic coordinates
       # EXTENT -45.26477766016219 29.347893202612525 -12.687409814179109
47.1708141841107

       UNITS METERS
       SHAPEPATH "/data/coverages/zoomazores/"
       IMAGECOLOR 255 255 255
       OUTPUTFORMAT
               NAME png24
               DRIVER "GD/PNG24"
               MIMETYPE "image/png"
               IMAGEMODE RGB

               EXTENSION "png"
       END
       WEB
               METADATA
               "wms_title"                     "WMSDemo"
               "wms_onlineresource"
       "http://localhost/cgi-bin/mapserv?map=/var/www/mapserver/WMS.map"
               "wms_srs"                       "EPSG:900913"
               "wms_format"            "image/png"
               END
       END
       PROJECTION
               "init=epsg:900913"
       END
       LAYER
               NAME "bathymetry"
               # The same extend that the file Bathymetry.tif in
projected coordinates.
               EXTENT -5038852 3420000 -1412356 5970000
               # Bathymetry.tif extend in geographic coordinates
               # EXTENT -45.26477766016219 29.347893202612525
-12.687409814179109
47.1708141841107
               # Mercator full extend in projected coordinates.
               # EXTENT -20037508.34 -20037508.34 20035017.34 20035017.34
               METADATA
                       "wms_title"    "bathymetryshaded"
                END
                TYPE RASTER
                STATUS ON
               DATA "Bathymetry.tif"
               PROJECTION
                        "init=epsg:900913"
               END
       END
END


Tilecache.cfg
================================
[bathymetryshaded]
size = 256,256
srs = EPSG:900913
type = WMS
url = http://localhost/cgi-bin/mapserv?map=/var/www/mapserver/WMS.map
layers = bathymetryshaded
mapfile = /var/www/mapserver/WMS.map
# bbox = -20037508.34, -20037508.34, 20035017.34, 20035017.34
# bbox = -45.26477766016219,29.347893202612525,-12.687409814179109,47.1708141841107
bbox = -5038852, 3420000, -1412356, 5970000
extension = png
# extent_type = loose
levels = 11
maxresolution = 7083 ## maxResolution = (max-X – min-X) / 512
# maxresolution = 1222.992452344 # google
metaTile=true
tms_type=google
spherical_mercator=true


1 Request URL
================================
http://localhost/cgi-bin/tilecache.cgi?LAYERS=bathymetryshaded&SERVICE=WMS&SRS=EPSG:900913&BBOX=-5038852,
3420000, -1412356, 5970000

# PROBLEM (1)
An error occurred: can't find resolution index for 14166.000000.
Available resolutions are:
[156543.03390000001, 78271.516950000005, 39135.758475000002,
19567.879237500001, 9783.9396187500006, 4891.9698093750003,
2445.9849046875001, 1222.9924523437501,


2 Request URL
================================
http://localhost/cgi-bin/tilecache.cgi?LAYERS=bathymetryshaded&SERVICE=WMS&SRS=EPSG:900913&BBOX=-20037508.34,
-20037508.34, 20035017.34, 20035017.34

# PROBLEM (2)
# The image (SIZE 600 400) that I can visualize in the browser is
white having inside my data in a small really part.



OpenLayers
================================
function init(){

       var maxbounds = new OpenLayers.Bounds(-20037508.34,-20037508.34,
20037508.34, 20037508.34);

       zoomBbox = new OpenLayers.Bounds(-5038852, 3420000, -1412356, 5970000);

       var options = {
               controls: [],
               maxExtent: maxbounds,
               restrictedExtent: zoombounds,
               projection: new OpenLayers.Projection('EPSG:900913'),
               units: 'metres',
               minZoomLevel:7,
               maxZoomLevel:17,
               numZoomLevels:10,
               maxResolution: 1222.992452344
       };

       map = new OpenLayers.Map('map', options);

       var tiled = new OpenLayers.Layer.TileCache(
               "teste",
               "http://localhost/cgi-bin/tilecache.cgi?",
               {
                       layers: 'bathymetryshaded',
                       format: 'image/png',
                       srs: 'EPSG:900913',
                       serverResolutions: [1222.992452344,
611.496226172, 305.748113086,
152.874056543, 76.437028271, 38.218514136, 19.109257068, 9.554628534,
4.777314267, 2.388657133, 1.194328567],
                       tileSize: new OpenLayers.Size(512,512)
               },
               {
                       isBaseLayer: true
               }
       );

       map.addLayers([tiled]);
       map.zoomToExtent(zoomBbox);
}

# PROBLEM (3)
# I only can see transparent tiles, there is not map.


Questions
================================
Is it possible to specify the bbox on projected coordinates in
tilecache.cfg file?

Am I missing something?

It's a good approach?

I think until the MapServer side it's right because it can show the
image on the browser with the following request:
http://localhost/cgi-bin/mapserv?map=/var/www/mapserver/WMS.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=bathymetryshaded&STYLES=&SRS=EPSG:900913&BBOX=-3586380.0348868947,4286595.390705814,-2690369.4534918354,4996719.237946053&WIDTH=600&HEIGHT=400&FORMAT=image/png

I tried creating the tiles with the tilecache_seed, specifying the
-bbx option, but I only get withe/transparent tiles.   Its related
with the problem (2) our (3)

Right now I have no ideas on how to solve it and so I feel lost.

I will really appreciate some help.
Thanks in advance!
Oscar



More information about the MapServer-users mailing list