MapServer

From Seven

Jump to: navigation, search

http://www.mapserver.org

Contents

Installation

You need a running CGI server to use MapServer. Apache HTTP Server works just fine:

install apt-get mapserver

To install MapServer 5.0.3 on Ubuntu 9.0.4 type:

sudo apt-get install cgi-mapserver

Ready. Add some tools by installing binaries:

sudo apt-get install mapserver-bin

Serving Maps

The MapServer software is installed a binary executable file. It typically resides in /usr/lib/cgi-bin/mapserv . There are two basic operations that any OGC WMS service must be able to answer and several optional extra requests:

The GetCapabilities request returns the OGC WMS Capabilities document. It contains all the information that an OGC WMS client needs to be able to ask for maps via the GetMap request. MapServer has an extra request parameter (mandatory) that allows to pass a configuration file along with the GetCapabilites request. This configuration file is called the MAP file, it typically ends with the extension ".map". This file contains all the information that MapServer needs to access data and create an image that is returned as a map. Find the full documentation of the MAP file on the MapServer web sites:

A good introduction to the information that MapServer needs to generate maps can be found here:

Data

This tutorial will use a set of roads, railways, populated places, rivers and topography from the CIA factbook and postal codes, all for Germany. Download

The MAP file contains all the necessary information to access a data source and render cartographic map images. This workshop uses vector data:

Flat file format
Databases

MapServer supports many more file formats as it uses GDAL/OGR.

Testing the Service

Query for an OGC WMS Capabilities document, it is the standard format for web map services. A correct Capabilities document tells you that the service is set up correctly but not whether the data can be read and rendered as a map. For that you need an application like Quantum GIS or Mapbender. Once you have installed MapServer on your local machine you can request for the Capabilities document using your browser: http://localhost/cgi-bin/mapserv?map=<enter-your-map-file-name-here>&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities

Exchange <enter-your-map-file-name-here> with the name and path to your MapServer MAP-file.

http://www.metaspatial.net/cgi-bin/mapserv?map=/home/data/germany/germany.map
http://www.metaspatial.net/cgi-bin/mapserv?map=/home/data/germany/germany.map&SERVICE=wms&REQUEST=GetCapabilities&VERSION=1.1.1

Using the Map Service

To use the OGC Web Map Service simply load the Capabilities of the corresponding service into your OGC WMS client.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox