Integrating with MapServer

To be used by TileCache, MapServer needs to be configured to work as a Web Map Service (WMS) provider. A complete treatment of using MapServer as a WMS provider is beyond the scope of this work, but a thorough document is available on the MapServer web site at http://mapserver.gis.umn.edu/docs/howto/wms_server. To started enough for TileCache, however, only a few additional parameters in a map file are necessary.

First, there must be a METADATA section within the WEB section of your map file listing several required attributes. In this METADATA section, there must be the following: wms_title, wms_srs, wms_onlineresource. wms_title is a free-form title identifying your resource. wms_srs is the projection of your map as an EPSG code, such as "EPSG:4326.

Within each layer, there must also be a METADATA section with the attribute wms_title. If the layer has a different projection than the default for the map, then it must also have an wms_srs attribute with the EPSG code.

The following is an example mapfile that to be used with the subsequent TileCache and OpenLayers examples.

Figure 2.  Example METADATA sections in a MapServer map file to support WMS

MAP
    ...
    WEB
        ...
        METADATA
            "wms_title" "Example WMS Service"
            "wms_srs" "EPSG:4326"
            "wms_onlineresource" "http://servername/cgi-bin/mapserv?map=/home/username/mapfile.map"
        END # METADATA
    END #web
    ...
    LAYER
        ...
        METADATA
            "wms_title" "example_layer"
        END # METADATA
    END # layer
END # Map File

The following is an example TileCache configuration that uses MapServer as a WMS provider.

Figure 3.  Example TileCache Configuration

[example-wms]
size    = 256,256
type    = WMSLayer
url     = http://servername/cgi-bin/mapserv?map=/home/username/public_html/example.map
layers  = layer_name
bbox    = -130,38,-110,47
srs     = EPSG:4326
extension = png
description = Example WMS Map
extent_type = loose
maxresolution = 0.015800781250000007
resolutions =
    0.015800781250000007,
    0.0039501953125000017,
    0.0019750976562500008