MAP corresponds to "root" in MapFile, which contains all other objects, and is an application-level MAP-level parameter.
Some general parameters are listed in the first part, and the detailed parameters are explained in a later section.
[name]
.[feet|inches|kilometers|meters|miles|dd]
.[minx] [miny] [maxx] [maxy]
/
). Value: [path/filename.ext
./
). Value: [path/filename.ext]
.Example:
# =======================================================
# General Settings of the MapFile:
# NAME: Name of the Map [keep short!]
# EXTENT of the Map: minY minY maxX maxY
# STATUS: normally on, just use for testing
# SHAPEPATH: Path to the root dir of the data
# =======================================================
NAME "hangzhou"
UNITS METERS
EXTENT 745000 156000 758000 165000
STATUS ON
FONTSET d:/mapserver/sym_fonts/fonts.txt
SYMBOLSET d:/mapserver/sym_fonts/shade.sym
SHAPEPATH d:/gis_data/hangzhou/
Example:
# ======================================================= # General
Output Settings of the MapFile:
# OUTPUTFORMAT specifications
# SIZE of the output map in pixel
# WEB: output location definition
# QUERYMAP: highlight color of selected objects
# =======================================================
IMAGETYPE PNG
SIZE 600 518
WEB
IMAGEPATH "/home/gronline/mapimage/"
IMAGEURL "/mapimage/"
END
QUERYMAP
COLOR 255 0 0
STYLE hilite
END
The following components can be defined in the MapFile file:
Fig. 1 Eagle eye diagram example
Scale Bar Toolbar
Example:
# ================================================================
# Components: Reference Map, Legend, Scale Bar
# ================================================================
# ------------------------------------
# Reference Map Definition
# ------------------------------------
REFERENCE
IMAGE images/overview_wormerl.png
EXTENT 114052 499083 124436 505124
STATUS ON
COLOR -1 -1 -1
OUTLINECOLOR 255 0 0
SIZE 150 130
END
# ------------------------------------ # Legend Definition
# ------------------------------------
LEGEND
STATUS embed
POSITION ur
END
# ------------------------------------
# Scale Bar Definition
# ------------------------------------
This section includes instructions for projection in the process of generating a map from a layer.
CONFIG: ~ Used to configure the location of EPSG files in the ~PROJ.4 library. Using this configuration allows PROJ.4 to use the files you specify. One of the advantages is that you can avoid setting the corresponding environment variables. For example: CONFIG PROJ_LIB /tmp/proj/
. Setting other values will be passed to CPLSetConfigOption()
so that you can control the behavior of the GDAL and OGR drivers. Please refer to the GDAL documentation for details. Value: [key] [value]
.
DATAPATTERN:This defines a regular expression to be applied To requests to change DATA parameters via URL requests (i.e. map_layername _data=...
)。 If a pattern doesn't exist then web users Can't monkey with support files via URLs. This allows you to isolate one Application from another if you desire, with the default operation being Very conservative. See also TEMPLATEPATTERN below. Value:\ [regular expression
DEBUG: Enable debugging on the MAP object. The detailed information of the system operation will be output to the LOG file specified by the WEB object. See the DEBUG section for details.
IMAGECOLOR: Initialize the color of the map, such as the background color. When transparency is enabled (TRANSPARENT ON), the specified color is applied to transparent areas. Values: [r] [g] [b]
.
SACLE: Computed scale of the map. Usually used in programs rather than in MapFile.
TEMPLATEPATTERN:This defines a regular expression to be applied to Requests to change TEMPLATE parameters via URL requests (即 map_layername_template=...
)。 If a pattern doesn't exist then web users Can't monkey with support files via URLs. This allows you to isolate one Application from another if you desire, with the default operation being Very conservative. See also DATAPATTERN above. Value: [regular expression]
Generally consider that when customizing the output format, you need to use the IMAGETYPE keyword, OUTPUTFORMAT object. Set it only if you need to change the default output format, and you should refer to it before setting it:
GD is an open source library for dynamically creating images. GD can create images in PNG, JPEG, GIF and other formats. GD raw support for the generation of GIF images. However, since its acquisition by Unisys, it has informally supported "Graphics Draw".
Anti-Grain Geometry (AGG) is a high-quality 2D image rendering library developed using C++. It has anti-aliasing and sub-pixel resolution. This allows you to create high-quality images. The MapServer5.0 version and its higher versions support AGG. For the same MapFile, you can use either AGG for rendering or GD.
Fig. 2 Image processed by AGG
A MapFile can define one or more OUTPUTFORMAT objects, and the supported output formats include PNG, GIF, JPEG, GeoTiff, Flash, etc.
Flash (swf) requires support from the MING library.
[name]
.GD/Gif
, GD/PNG
, GD/WBMP
and GD/JPEG
; the driver name for Flasf is SWF. GDAL's driver name is GDAL/GTiff. PNG, JPEG, GIF can be generated using GDAL or GD (GD is more efficient). Value: [name]
IMAGEMODE: The image mode for generating the output image. Not all non-raster images are the same as Flash. Not all supported formats have all combinations. E.g. GD/GIF only supports PC256.
[type]
。Example:
MIMETYPE "application/x-shockwave-flash"
MIMETYPE "application/x-pdf"
MIMETYPE "image/gif"
MIMETYPE "image/jpeg" MIMETYPE "image/png"
EXTENSION: generates suffixes for files of the corresponding file type, such as .png, .gif, etc. Value: [type]
.
TRANSPARENT: use this parameter to indicate whether transparency is enabled for images in this format. Note: Transparency is not available when IMAGEMODE is RGB, not all formats support transparency. When using transparency, an 8-bit false color image is generated in the transparent areas, so filling other parts of the map with this color will also be transparent, so a suitable color should be used as the background color.
FORMATOPTION: optional parameter for driver or format. Zero or more FORMATOPTION can appear in the definition of an OUTPUTFORMAT.
-GD/JPEG: the "QUALITY=n" option can be used to set the generation quality of JPEG images. Values range from 0 to 100. -GD/PNG: "INTERLACE= [ON/OFF]", which sets whether to render the image interlaced. -GDAL/GIF: "INTERLACE= [ON/OFF]", which sets whether to render the image interlaced. -the parameters supported by GDAL/GTiff:~ are as follows ~ -TILED=YES -BLOCKXSIZE=n -BLOCKYSIZE=n -INTERLEAVE= [PIXEL/BAND] -COMPRESS= [NONE,PACKBITS,JPEG,LZS,DEFAULT]
GDAL: all FORMATOPTION are processed using GDAL. Refer to the GDAL documentation for details. Value: [option]
. If the defined OUTPUTFORMAT is not defined in the MapFile, the program will use it implicitly.
The following definitions:
Related to the AGG library:
OUTPUTFORMAT
NAME 'AGG_PNG'
DRIVER AGG/PNG
IMAGEMODE RGB
FORMATOPTION "QUANTIZE_FORCE=ON"
FORMATOPTION "QUANTIZE_DITHER=OFF"
FORMATOPTION "QUANTIZE_COLORS=256"
END
OUTPUTFORMAT
NAME 'AGG_JPEG'
DRIVER AGG/JPEG
IMAGEMODE RGB
FORMATOPTION "QUALITY=100"
END
Related to the GD Graphics library:
OUTPUTFORMAT
NAME **gif**
DRIVER "GD/GIF"
MIMETYPE "image/gif"
IMAGEMODE PC256
EXTENSION "gif"
END
OUTPUTFORMAT
NAME **png**
DRIVER "GD/PNG"
MIMETYPE "image/png"
IMAGEMODE PC256
EXTENSION "png"
END
OUTPUTFORMAT
NAME **png24**
DRIVER "GD/PNG"
MIMETYPE "image/png"
IMAGEMODE RGB
EXTENSION "png"
END
OUTPUTFORMAT
NAME **jpeg**
DRIVER "GD/JPEG"
MIMETYPE "image/jpeg"
IMAGEMODE RGB
EXTENSION "jpg"
END
OUTPUTFORMAT
NAME **wbmp**
DRIVER "GD/WBMP"
MIMETYPE "image/wbmp"
IMAGEMODE PC256
EXTENSION "wbmp"
END
OUTPUTFORMAT
NAME **swf**
DRIVER "SWF"
MIMETYPE "application/x-shockwave-flash"
EXTENSION "swf" IMAGEMODE PC256
FORMATOPTION "OUTPUT\_MOVIE=SINGLE"
END
OUTPUTFORMAT
NAME **GTiff**
DRIVER "GDAL/GTiff"
MIMETYPE "image/tiff"
IMAGEMODE RGB
EXTENSION "tif"
END
Defines a parameter for the WEB interface runtime. To WEB
Start with END
End.
/
. Value: [path
[url|virtual directory]
[url]
[url]
[filename]
[double]
.[file|url]
[double]
.[file|url
] .[file|url]
.[filename]
[filename]
METADATA: Use this identifier to store arbitrary key-value pairs. Often used when configuring OGC WMS. It is also very flexible when creating templates, and any content entered here can be obtained through template transitions. example:
METADATA title “Map of China” autor “YanMing” END
Example:
WEB
IMAGEPATH "f:/mapserver/mapimages/"
IMAGEURL "/mapimages/"
ERROR http://www.mapserver.ch/mapserver/ms_error.htm
EMPTY http://www.mapserver.ch/mapserver/ms_empty.htm
LOG f:/mapserver/logs/mapserver.log
END
Define how query results are rendered
[r] [g] [b]
[x][y]
STYLE: Set the realistic way of querying the obtained map. Maps or map parts that are not selected are not processed.
Value: [normal|hilite|selected]
Example:
QUERYMAP
COLOR 255 0 0
STYLE hilite
END
It is a preview showing the location of the map in the main window.
Begins with a REFERENCE and ends with an END. Three types of reference maps are supported. The most common is to show the extent of the map being interacted with in the preview. It is also possible to include a reference map as part of a query. Point query will generate an icon (an image with a marker) on the query point; face query will highlight the queried area; query given to feature will display the selected part.
Example:
# ------------------------------------
# Reference Map Definition
# ------------------------------------
REFERENCE
IMAGE images/overview\_wormerl.png
EXTENT 114052 499083 124436 505124
STATUS ON
COLOR -1 -1 -1
OUTLINECOLOR 255 0 0
SIZE 150 130
END
Define the mode of production of the legend file, and the CLASS object creates the corresponding legend component for each individual highlight. Start with LEGEND and end with END. The size of the legend image is not unknown before it is created, so do not use the <img>
The width and height of the hard-coded image in the tag.
Example 1:
# ------------------------------------
# Legend Definition
# ------------------------------------
LEGEND
STATUS embed
POSITION ur
END
This legend is automatically created for all layers, the legend contains the layer name.
Example 2:
LAYER
NAME "Restaurants"
STATUS ON
TYPE POINT
DATA "restaurants.shp"
CLASS
NAME "Restaurants"
COLOR 255 127 127
SIZE 14
SYMBOL "restaurants"
END
END
This legend will create a legend with the "restaurants" symbol and restaurants text.
As shown below:
MapServer version 3.5 and above can use template files to generate legends. In MapFile The TEMPLATE parameter is used in the file to enable template-based legend generation. Set up TEMPLATE file, the file will replace main HTML The content referred to by the\ [legend] tag in the file. Template files must have an. Html extension.
The HTML legend template file contains 0 or one of the following tags, and the program will use the corresponding tags
Generate the legend:
\[leg\_group\_html\] ... \[/leg\_group\_html\]
\[leg\_layer\_html <OPTIONAL PARAMS>\] ... \[/leg\_layer\_html\]
\[leg\_class\_html <OPTIONAL PARAMS>\] ... \[/leg\_class\_html\]
Anything in the legend file except the label pair above will be ignored
1) GROUP block tag: [leg_group_html]...[leg_group_html]
The HTML block that uses this tag in a group of layers is that the layers will appear in the legend. When using the [leg_group_html]
tag, styles for layers that do not belong to any group (LAYER GROUP not set in the MapFile) are also not displayed in the legend. The list of groups is determined by order_metadata
, which is explained later....
Tags that can appear in [leg_group_html] blocks:
[leg_group_name]
Name of the group[layer_status]
The state of the first layer in the group[leg\_icon width=<optional\_width> height=<optional\_height>\]
The icon of the legend, [leg_icon] is the URL of the icon.metadata name=<metadata_field_to_display>]
Returns the specified metadataExample: show layer group
[leg_group_html]
<tr><td colspan=2><b>[leg_group_name]</b></td></tr>
[leg_group_html]
2) LAYER block tag: [leg_layer_html <OPTIONAL PARAMS>] ... [/leg_layer_html]When this ~ tag is not set, no ~layer header will be displayed.
The optional parameters are as follows:
l order_metadata = <field_to_order_by> You can use the value of <field_to_order_by> to control the display order and visibility of layers in the legend.
When the value of <field_to_order_by> is greater than zero, sort by this value.
If the value of <field_to_order_by> of two layers is the same, then the order of MAP LAYER is used.
<field_to_order_by> will not be displayed in the legend if the value is less than zero.
l opt_flag = <bit_mask> Controls the display process of the layer. The values are as follows:
1. : Legend is still shown when out of Scale (default is out of Scale, no legend is shown)
2. : The corresponding legend is still displayed when the layer status is OFF (by default, the corresponding legend is not displayed when STATUS is OFF).
4. : The legend is still displayed when the layer type is QUERY (the default is not displayed when the TYPE is QUERY)
8. : The legend is still displayed when the ~layer type is ~ANNOTATION (the legend is not displayed when the TYPE is ANNOTATION by default) Example: opt\_flag=12 means to display all ~layer types, including ~QUERY and ANNOTATION.(4 +8)
The tags that can appear in the [leg_layer_html] block are as follows:~
a) [leg_layer_name] returns the value of the layer name
b) [leg_icon width=<option_width> height=<option_height>] returns the URL of the legend icon
c) [metadata name=<metadata_field_to_display>] Returns the specified metadata value and WEB metadata Example: Display layer title with href link
[leg_layer_html order_metadata=WMS_ORDER visibility_flag=15]
<a href="[leg_layer_name]">[metadata name=WMS_TITLE]</a><BR> [/leg_layer_html]
3) CLASS block tag:[leg\ _ class\ _ html & lt;OPTIONAL PARAMS>] .[/ leg\ _ class\ _ html]
If not set, no style will be displayed.
CLASS whose NAME is NULL will not be displayed
Optional parameters:
l opt_flag = <bit_mask> controls the display of layers. The values are as follows:
- 1 : Legend is still shown when out of Scale (default is out of Scale, no legend is shown)
- 2 : The corresponding legend is still displayed when the layer status is OFF (by default, the corresponding legend is not displayed when STATUS is OFF).
- 4 : The legend is still displayed when the layer type is QUERY (by default it is not displayed when the TYPE is QUERY)
- 8 : The legend is still displayed when the layer type is ANNOTATION (by default, the legend is not displayed when the TYPE is ANNOTATION)
Example: opt_flag=12
means to show all layer types, including QUERY and ANNOTATION. (4x8)
Tags that can be used under [leg_class_html]:
[leg_class_name] Value of CLASS NAME
[leg_class_title] Value of CLASS TITLE
[leg_icon width=<option_width> height=<option_height>] Returns the URL of the legend icon
[metadata name=<metadata_field_to_display>] Returns the specified metadata value
and WEB metadata ~data~
Example:
\[leg\_class\_html opt\_flag=15\]
<img src=[leg_icon]> [leg_class_name]<br>
[/leg_class_html]
4) CONDITIONAL text
Label:
[if name=<field_to_check> oper=<eq|neq|isset|isnull>
value=<to_compare_with_field>]
...
[/if] The [if] tag can be inside the [leg_*_html] tag, and nesting is recommended. The value of the parameter oper can be eq (equal), neq (not equal), isset, isnull. Defaults to equal.
This is another way to create a legend. Pre-processed, use HTML, PHTML, PHP, etc.
Example:
SCALEBAR defines the mode of production of map scales. Start with SCALEBAR and end with END. The size of the legend image is not unknown before creation, so do not hard-code the width and height of the image in the & lt;img> tag of the template file.
Note: fonts of TrueType type are currently not available.
Example 1:
# ------------------------------------
# Scale Bar Definition - STYLE 0
# ------------------------------------
SCALEBAR
INTERVALS 5
UNITS kilometers
OUTLINECOLOR 0 0 0
STYLE 0
STATUS embed
LABEL
SIZE small
COLOR 0 0 0
END
END
The illustration bar is as follows:
Example 2:
# ------------------------------------
# Scale Bar Definition - STYLE 1
# ------------------------------------
SCALEBAR
INTERVALS 5
UNITS meters
STYLE 1
STATUS embed
LABEL
SIZE small
COLOR 0 0 0
END
END
The illustration bar is as follows: