Example 1.7: Adding OGC WMS Layers
Another exciting feature of MapServer is its ability to use layers from other map servers. In this case, a MapServer application becomes a WMS (or WFS) client. MapServer can also share (or serve up) the layers in the mapfile to other map servers. This makes an application a WMS (or WFS) server. What is WMS or WFS? These are "web-based interoperability service" specifications published by the Open Geospatial Consortium (OGC). WMS stands for Web Map Service and WFS for Web Feature Service. The difference between these two specifications, in simple terms, is that WMS uses web raster formats (PNG, GIF, JPEG) to share layers while WFS uses GML, the Geography Markup Language. A third OGC interoperability specification is the Web Coverage Services specification or WCS--MapServer supports this at the server level only. To find more information about WMS, WFS, and WCS go the the OGC's web site and look for the OGC Implementation Specifications or OGC Abstract Specifications. The MapServer web site also has documentation for these specifications.
This example shows you how to add a WMS layer in your mapfile.
This is what the mapfile looks like (Example1-7.map):
Let's have a look at the WMS layer:
LAYER # MODIS WMS map from JPL
OFFSITE 0 0 0
To know more about adding WMS layers to your applications, please visit the WMS Client HOW-TO document.
In addition to adding the WMS layer object, there's also a new object under MAP. This is the WEB object. Within the WEB object are two parameters:
Finally, within the MAP object, I added a new parameter: NAME. This is the identifier for the MAP object. MapServer uses this as prefix to all images it creates and dumps to the "tmp" directory. It's not needed at this point but it also doesn't hurt to have it.
If you would like to share your data layers to other map servers, you will need to add METADATA objects within your MAP object and within each of the LAYER objects you would like to share. All the WMS layers that you added from another server will automatically be cascaded and will also become available to others. To know more about how to make your MapServer application become a WMS server, please read the WMS Server HOW-TO documentation. Documentations also exist for configuring MapServer application to support the WFS standard, both as a WFS server and as a WFS client.