The GetMap
operation is used to generate a map, which can be a picture or a set of graphic elements. GetMap
allows clients to request multiple servers to make overlapping map layers, processing pixel geometry with the same frame of reference, size, and scale. These layers can be displayed in a certain order on the client side, and transparent pixel technology can be used to display map information from different sources according to human visual requirements.
The GetMap
request usually uses HTTP/GET to call a basic WMS via URL encoding, and can also use HTTP/POST encoding to communicate with an SLD-capable WMS. The GetMap
request must specify the requested layers (Layers), the styles used by each layer (Styles), the spatial reference system (SRS), the bounding rectangle (BBox), the image format (Format) and size (Width, Height) and other parameters.
Web map services support the display of map views in picture or graphic format. Image formats include public image formats such as GIF, PNG, JPEG, etc. These formats are supported by most Web browsers, and the display of other graphic formats may also require some helper programs to support. Graphics formats include SVG and WebCGM formats, which are not commonly used in WMS.
In addition, the optional Transparent
parameter is used to specify whether the background of the map is transparent. The default value is False
. A function that allows the returned result to be drawn transparently, so that maps for different requests can be overlaid. Each WMS preferably provides an image format that supports transparent display for overlaying with other map images.
A valid GetMap
request will return a map consisting of georeferenced layers with the specified style, spatial reference system, bounding rectangle, size, format, and transparency. An invalid GetMap
request returns a formatted error message. In the HTTP context, the content type of the return value is a MIME type.
GetMap access to the published MapServer WMS service is described here.
The first is Mapfile:
01 MAP
02 NAME "EX2_"
03 IMAGETYPE "png24"
04 EXTENT -180 -90 180 90
05 SIZE 600 300
06 SHAPEPATH "/gdata"
07 SYMBOLSET "../symbols/symbols35.sym"
08 FONTSET "../fonts/fonts.list"
09 OUTPUTFORMAT
10 NAME "png"
11 DRIVER "AGG/PNG"
12 MIMETYPE "image/png"
13 IMAGEMODE RGB
14 EXTENSION "png"
15 FORMATOPTION "GAMMA=0.75"
16 END
17 WEB
18 TEMPLATE "tmpl_ogc.html"
19 IMAGEPATH "/owg/ms_tmp/"
20 IMAGEURL "/ms_tmp/"
21 METADATA
22 "wms_title" "WMS Demo Server"
23 "wms_version" "1.3.0"
24 "wms_onlineresource" "http://webgis.pub/cgi-bin/mapserv?map=/owg/mfb2.map&"
25 "wms_srs" "EPSG:4326"
26 "wms_enable_request" "*"
27 "ows_enable_request" "*"
28 "wms_feature_info_mime_type" "text/html"
29 "wms_format" "image/png"
30 END
31 END
32 PROJECTION
33 "init=epsg:4326"
34 END
35 LAYER
36 NAME "topo"
37 DATA "land_shallow_topo_8192.tif"
38 STATUS OFF
39 TYPE RASTER
40 PROCESSING "BANDS=1,2,3"
41 PROJECTION
42 "init=epsg:4326"
43 END
44 END
45 LAYER
46 NAME "states"
47 DATA "wcountry.shp"
48 STATUS OFF
49 TYPE POLYGON
50 TEMPLATE "tmpl_ogc.html"
51 METADATA
52 "wms_title" "test2"
53 "wms_version" "1.3.0"
54 "wms_srs" "EPSG:4326 EPSG:3857"
55 "wms_enable_request" "*"
56 "ows_enable_request" "*"
57 "wms_feature_info_mime_type" "text/html"
58 "wms_format" "image/png"
59 END
60 PROJECTION
61 "init=epsg:4326"
62 END
63 CLASS
64 NAME "States"
65 STYLE
66 COLOR 232 232 232
67 OUTLINECOLOR 32 32 32
68 END
69 END
70 END
71 LAYER
72 NAME "states_line"
73 DATA "wcountry.shp"
74 STATUS OFF
75 TYPE LINE
76 TEMPLATE "tmpl_ogc.html"
77 METADATA
78 "wms_title" "test3"
79 "wms_version" "1.3.0"
80 "wms_srs" "EPSG:4326 EPSG:3857"
81 "wms_enable_request" "*"
82 "ows_enable_request" "*"
83 "wms_feature_info_mime_type" "text/html"
84 "wms_format" "image/png"
85 END
86 PROJECTION
87 "init=epsg:4326"
88 END
89 CLASS
90 NAME "State Boundary"
91 STYLE
92 COLOR 132 132 32
93 END
94 END
95 END
96 END
Compared to the previous mfa1.map
:
6 | IMAGECOLOR 255 255 255 | 6 | IMAGECOLOR 255 255 255 | ||
n | n | 7 | WEB | ||
8 | METADATA | ||||
9 | "wms_title" "WMS Demo Server" | ||||
10 | "wms_onlineresource" "//webgis.pub/cgi-bin/mapserv?map=/owg/mfb1.map&" | ||||
11 | "ows_onlineresource" "//webgis.pub/cgi-bin/mapserv?map=/owg/mfb1.map&" | ||||
12 | "wms_srs" "EPSG:4269 EPSG:4326" | ||||
13 | "wms_enable_request" "* !GetFeatureInfo" | ||||
14 | END | ||||
15 | END | ||||
7 | LAYER | 16 | LAYER | ||
n | 8 | NAME "world-country" | n | 17 | NAME "topo" |
18 | DATA "land_shallow_topo_8192.tif" | ||||
19 | STATUS OFF | ||||
20 | TYPE RASTER | ||||
21 | PROCESSING "BANDS=1,2,3" | ||||
22 | PROJECTION | ||||
23 | "init=epsg:4326" | ||||
24 | END | ||||
25 | END | ||||
26 | LAYER | ||||
27 | NAME "states" | ||||
9 | DATA "wcountry.shp" | 28 | DATA "wcountry.shp" | ||
12 | CLASS | 31 | CLASS | ||
t | 13 | NAME "World Countries" | t | 32 | NAME "The Upper Great Lakes States" |
14 | STYLE | 33 | STYLE |
This Mapfile is configured with the WMS service. View function:
Here, use the map
mode of MapServer to view.
GetMap
enabledTo use GetMap
, you need to enable the GetMap
option in WMS:
If not enabled, the access URL will display :
<ServiceExceptionReport version="1.3.0" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd"><ServiceException>
msWMSDispatch(): WMS server error. WMS request not enabled. Check wms/ows_enable_request settings.
</ServiceException></ServiceExceptionReport>
Note that to use GetMap
, the projection must be set. If it is not set, the access will appear:
<ServiceExceptionReport version="1.3.0" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd"><ServiceException code="InvalidCRS">
msWMSLoadGetMapParams(): WMS server error. Cannot set new CRS on a map that doesn't have any projection set. Please make sure your mapfile has a projection defined at the top level.
</ServiceException></ServiceExceptionReport>
Here is the correct way to access it. Note that the length and width parameters passed to the server graph in URL.
It looks like GETMAP
is similar to MapServer's mode=map
.
Noteļ¼
Version of WMS 1.1.1 and WMS 1.3.0 have different request parameter for coordinate system :
SRS=EPSG:4326
for 1.1.1 CRS=CRS:84
for 1.3.0The range used above is consistent with the range of the entire data, and the results look no different. Let's zoom out to get a section of the map.
According to the description, the parameter CRS = EPSG: 4326
can also be used. But I didn't succeed. You may need to configure mapfile.
The above effect can also be achieved in MapServer CGI control, by setting the zoom
level of browsing, the x
and y
coordinates of the map but GetMap
is obviously more flexible. In addition to these, WMS has more advantages as a standard.