The GetFeatureInfo
operation (optional) returns information about features near the specified point on the map. Allows users to click on a pixel to query a feature's schema and metadata.
GetFeatureInfo
is an optional operation. This operation is only supported for layers with the attribute queryable="1"
(true). If a WMS client makes a request to a layer that does not support this operation, a formatted service exception will be returned.
TA WMS may provide the optional GetFeatureInfo
operation, and a WMS that provides this operation calls its map "queryable". The client can add a position parameter (such as (X, Y) value, that is, the offset from the upper left corner of the picture) or the number of elements that need to query information near the point, to the URL of the requested map, information about the corresponding feature on the map can now be requested.
Since WMS is stateless, the GetFeatureInfo
request should also include all the parameters in the original GetMap
request (except Version and Request). Based on the spatial context information (BBOX, SRS, Width and Height) in the GetMap
request and the (X, Y)
location selected by the user, the WMS returns more information about that location.
Also included in the GetFeatureInfo
request parameter is the Query_Layers
parameter, which specifies the layers from which feature information is obtained. The layers in this parameter list must be those contained in the WMS Capabilities
XML document.
The optional Info_Format
parameter in the GetFeatureInfo
request specifies the format in which the feature's information is returned. The format is defined as a MIME type in the WMS Capabilities
XML document. Such as Info_Format=application/vnd.ogc.gml
table does not return results described in GML.
The optional Feature_Count
parameter in the GetFeatureInfo
request indicates the maximum number of features to return feature information. The default value is 1
. The X,Y
parameters represent the pixel coordinates of the point of interest on the map. The X,Y
values are within the Width
and Height
parameter values, respectively. The origin of the coordinates is in the upper left corner of the picture.
If GetFeatureInfo
request is valid, WMS will respond according to Info_Format
. The nature of the response will be at the discretion of the WMS server, but generally corresponds to the closest element to the point (X,Y)
.
GetFeatureInfo
request using WMS service in MapServerThis describes the GetFeatureInfo
access to the published MapServer WMS service.
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 mfb1.map
:
f | 1 | MAP | f | 1 | MAP |
n | n | 2 | NAME "EX2_" | ||
2 | IMAGETYPE "PNG" | 3 | IMAGETYPE "png24" | ||
3 | EXTENT -180 -90 180 90 | 4 | EXTENT -180 -90 180 90 | ||
5 | SHAPEPATH "/gdata" | 6 | SHAPEPATH "/gdata" | ||
n | 6 | IMAGECOLOR 255 255 255 | n | 7 | SYMBOLSET "../symbols/symbols35.sym" |
8 | FONTSET "../fonts/fonts.list" | ||||
9 | 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 | ||||
7 | WEB | 17 | WEB | ||
n | n | 18 | TEMPLATE "tmpl_ogc.html" | ||
19 | IMAGEPATH "/owg/ms_tmp/" | ||||
20 | IMAGEURL "/ms_tmp/" | ||||
8 | METADATA | 21 | METADATA | ||
9 | "wms_title" "WMS Demo Server" | 22 | "wms_title" "WMS Demo Server" | ||
n | n | 23 | "wms_version" "1.3.0" | ||
10 | "wms_onlineresource" "//webgis.pub/cgi-bin/mapserv?map=/owg/mfb1.map&" | 24 | "wms_onlineresource" "http://webgis.pub/cgi-bin/mapserv?map=/owg/mfb2.map&" | ||
11 | "ows_onlineresource" "//webgis.pub/cgi-bin/mapserv?map=/owg/mfb1.map&" | ||||
12 | "wms_srs" "EPSG:4269 EPSG:4326" | 25 | "wms_srs" "EPSG:4326" | ||
13 | "wms_enable_request" "* !GetFeatureInfo" | 26 | "wms_enable_request" "*" | ||
27 | "ows_enable_request" "*" | ||||
28 | "wms_feature_info_mime_type" "text/html" | ||||
29 | "wms_format" "image/png" | ||||
14 | END | 30 | END | ||
n | n | 31 | END | ||
32 | PROJECTION | ||||
33 | "init=epsg:4326" | ||||
15 | END | 34 | END | ||
30 | TYPE POLYGON | 49 | TYPE POLYGON | ||
n | n | 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 | ||||
31 | CLASS | 63 | CLASS | ||
n | 32 | NAME "The Upper Great Lakes States" | n | 64 | NAME "States" |
33 | STYLE | 65 | STYLE | ||
38 | END | 70 | END | ||
t | t | 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 | ||||
39 | END | 96 | END |
This Mapfile is configured with the WMS service. View function:
The above results are output using a template.
WMS, Web Mapping Server, is a specification published by OGC.
GetFeatureInfo
is an access method supported by WMS.