Publisher With Map Server
Publisher With Map Server
Página 1
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
CONTENTS
Página 2
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
GRAPHIC LIST
CHART LIST
Página 3
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
Página 4
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
STRUCTURE
1.4.1. Mapfile
The Mapfile defines the data to be used in the application, sample and query
parameters. It also contains information about how to draw the map, legend and
result in a search. This file usually has the extension .map.
MapServer can create an image and store it in a local directory or sent directly to be
presented in a Web browser, via a URL. This URL is composed of 3 parts (the URL is
presented to the local path of the service):
The second part consists of the absolute path to the Mapfile file to view.
The third, indicates the way in which you want to display the information.
Página 5
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
We will charge the Departments of Colombia layer from a shape located in the data
folder that was set up, see Ex. 1. map. The mapfile is the basic configuration
mechanism is used to MapServer. The Mapfile is made of "objects" and each object has
keywords and other objects. It has a hierarchical structure where some objects are
above others, on top of this hierarchy is the MAP object, all other objects are under it.
If we review the file .map of example, we find the following structure:
In the browser URL is placed with the previously defined structure, as the following:
http://localhost/cgi-bin/mapserv?map=C:\servidorWMS\mapas\ejemplo1.map&mode=map
Página 6
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
Graphic 21. Map of Colombia showed in the browser with a shape information
EXTENT: This parameter specifies the output dimensions of the map. This needs to be
in the same units of data. In this case our output unit, are the degrees. To extract the
values of the extension, you can use ArcView or other GIS software.
SIZE: This is the size of the image (the map) that MapServer can generate, in pixels.
And the map is 800 pixels wide by 700 pixels high.
SHAPEPATH: This is the path to your data layers. You can provide absolute paths (C: \
servidorWMS \ data \ data processed) or relative paths to the location of your mapfile
(.. \ data \ data processed). This path should not be accessible to the Web. It doesn’t
Página 7
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
have to go directly to the Web, the user only has to make it run on the server, and data
can be read in the SHAPEPATH.
IMAGECOLOR: This is the background color of the map. The values are RGB values as
255 Red, 255 Green and 255 Black results in a white background.
NAME: This is the identifier of the name of each of the layers specified.
DATA: The name of the data (shapefile in this case). MapServer supports Vector
formats and other shapefiles that ESRI uses of ORG library (part of GDAL software).
TYPE: What kind of data is this? If this is a vector data, you can specify whether this is
a POLYGON, LINE (you use LINE if your data are technically POLYLINE), or a POINT.
You can also specify RASTER or ANNOTATION.
STATUS: The layer can be set to ON or OFF based on their STATUS. DEFAULT is
always in ON or visible. ON or OFF works when the LAYER name is passed as part of
query string parameter.
COLOR: This is the fill color of the polygon. In the event that the TYPE is LINE, this is
the line color. The values are in RGB format.
Using existing attributes in the shapefile, we can create a new mapfile (see example 2
.map), resulting in the run is:
Página 8
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
Graphic 22. Map showed in the browser with types of shape information
Página 9
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
EXPRESSION: For each type, we specify which attribute values we use. This is simply
way of the EXPRESSION value. EXPRESSION can be more complex even than this. You
can review materials relating to Mapfile to see what you can do with EXPRESSION.
MapServer can use raster data as vectors. Through the use of the GDAL library,
MapServer can enter and display multiple raster formats. Also it can attach labels to
the map, which is essential to identify geographic objects within a map. So, now you
could add a layer Raster located in the data folder. Also, it will add a layer to label the
Departments of Colombia layer. For this it must set up a new map-file (see example 3
.map).
Página 10
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
Graphic 25. Map showed in the browser with three loaded layers
IMAGETYPE: This is not new but the value PNG24 it is. PNG24 is the version of PNG
format 24-bit or true color. In return, instead of being limited to 256 color
combinations to output formats, MapServer now has millions of colors.
DATA “DTM1.JPG”: In the new object within LAYER, DATA parameter routed to a JPG
image. As sources of vector data, MapServer supports multiple raster file formats. This
support is accomplished through the GDAL library.
Página 11
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
TYPE RASTER: When using raster data (images) it must use the value RASTER of the
parameter TYPE, as opposed to POLYGON, LINE and POINT values vector data and
ANNOTATION for identification labels.
FONTSET: Here, it specifies the full path to our truetype FontList file (list of fonts).
This file lists each of the available fonts. View fonset documentation file for more
information. FONSET is a MAP object parameter.
LABELITEM: This specifies that data attributes are used for labeling, in this case
NOMBREDEPT. LABELITEM is a LAYER object parameter.
LABEL: Marks the beginning of the LABEL object. The LABEL object can be used under
other objects (example: the SCALEBAR object).
COLOR: In the LABEL object, COLOR specifies the text label color.
SHADOW COLOR: This specifies the shadow of the text label color.
SHADOWSIZE: It specifies the shadow size. The corresponding value for the variables
X and Y in pixels. For case 2.2 means two pixels wide and two pixels high.
TYPE: In the LABEL object, TYPE specifies which font type will be used. We can choose
between TRUETYPE or BITMAP (the builder in fonts) We will choose BITMAP.
FONT: If you specify TYPE as TRUETYPE, you need to specify what font you will use.
The value of this is the file alias in the font list.
SIZE: If you use TRUETYPE fonts, the value of the size is in pixels. If it is a BITMAP you
can write small, medium or large.
ANTIALIAS: This turns the TRUETYPE antialias from ON to OFF. Remember, the
value is not ON or OFF but is TRUE or FALSE.
POSITION: Where the text label position is in relation to items of the label. The values
are a combination of vertical and horizontal positions. You can choose the following
for a vertical alignment: C for center, L for left and R for right. For alignment of the text
label in the center of label ID you should use the value CC (center-center). Or if you
Página 12
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
want the bottom of the ID, you should use the LL. Another way is that the MapServer
decides the best position of your labels. For this, you must be using the AUTO value.
PARTIALS: Tells MapServer where generate the incomplete labels or no. By default
here are not generated fragments of a text label. The values of this are TRUE or FALSE.
MINDISTANCE: This is the minimum distance in pixels between duplicate labels. You
can increase this value and see what happens with the change.
BUFFER: The coverage (in pixels) of each label. This is used to enhance readability. A
BUFFER of 4 pixels ensures that no other label is drawn into the four pixels.
Based on the example 3, now we will add a fourth layer to our map, this time from a
database in PostgreSQL + PostGIS. (see Example 4 .map)
Página 13
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
Graphic 27. Map showed in the browser with four loaded layers
SYMBOLSET: Defining the path of the symbol file definition. The file symbol in this file
is referenced by the SYMBOL parameter in the CLASS object.
SYMBOL: Name of the symbol you want to use in the type. This symbol must be
contained in the file of symbols that are defined by SYMBOLSET.
Página 14
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
This service is based on international standard WMS 1.1.1, which defines a "map" as a
representation of geographic information in a digital image file suitable for display on
a computer screen. A map doesn’t consist in the own data. The maps produced by
WMS are generally generated in an image format such as PNG, GIF, TIFF or JPEG, and
occasionally as vector graphics in SVG format (Scalable Vector Graphics) or WebCGM
(Web Computer Graphics Metafile).
To operate our Mapfile and comply with the WMS 1.1.1 specification, we must modify
it by adding some information (see example 5 .map)
Página 15
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
Below is presented a description of each of these requests and apply them to our map
of example 5.
1.5.2. GetCapabilities
The answer would be an XML file with the Metadata Service. Then run the request and
parse the XML
1.5.3. GetMap
Página 16
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
For our example, the URL request would be (we will ask only 3 layers, the MDE, the
capitals and the departments of Colombia)
http://localhost/cgi-
bin/mapserv?map=C:\servidorWMS\mapas\ejemplo5.map&SERVICE=WMS&REQUEST=Get
Map&version=1.1.1&layers=Modelo_Digital_de_Elevacion,departamentos,capitales&styles=de
fault&srs=EPSG:4326&bbox=-80,-5,-65,14&width=700&weigth=800&formtat=image/png
The answer will be the map with layers that request, under the conditions we
specified in the parameters of the get map
Página 17
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
1.5.4. GetFeatureInfo
This operation is optional, and is available only to those layers where queryable
option is active.
Página 18
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
For GetFeatureInfo, we will use the file example6 .map, to which we add two new
parameters at the layer level, the parameter DUMP and the parameter TEMPLATE. For
this the department layer, which is what is going to be queryable (see example6.map):
The answer will be for the department that the pixel x = 300, y = 300.
Página 19
Engineer Alexander Diaz Mogollon Short overview and hands on-exercises
MapServer can also consume WMS services. Following is the configuration of a broker
or cascading WMS (see example7.map)
The request is in the same way as above. This allowed the request of 2 layers.
http://localhost/cgi-
bin/mapserv?map=C:\servidorWMS\mapas\ejemplo7.map&SERVICE=WMS&REQUEST=Get
Map&version=1.1.1&layers=modis_jpl,capitales&styles=default&srs=EPSG:4326&bbox=-80,-
5,-65,14&width=700&weigth=800&formtat=image/png
Graphic 31. Map showed in the browser consuming a WMS and reading the database
Página 20