GetFeaturelnfo
操作(可选)返回地图上指定点附近要素的信息。使用户可以点击像素查询要素的模式和元数据。
GetFeaturelnfo
是一个可选的操作。该操作只支持对于属性 queryable="1"
(真)的图层。如果一个WMS客户端向不支持该操作的图层发出请求,将返回一个格式化的服务异常信息。GetFeaturelnfo
操作要求客户端指定查询的图层(或图层列表)以及要素信息的返回格式。
一个WMS可以提供可选的 GetFeaturelnfo
操作,对提供这种操作的WMS,称其地图为“可查询的”。客户机可以通过增加一个位置参数(如(X,Y)值,即距图片左上角的偏移量)或该点附近需要查询信息的要素的数量等参数,到所请求地图的URL中,就可以请求地图上相应要素的信息了。
由于WMS是无状态的,所以在 GetFeaturelnfo
请求中还应包括原始的
GetMap
请求中所有的参数(除Version和Request外)。根据 GetMap
请求中的空间上下文信息(BBOX、SRS、Width和Height)和用户选择的 (X, Y)
位置,WMS返回该位置更多的信息。
在 GetFeaturelnfo
请求参数中还包括 Query_Layers
参数,该参数列表指明获取要素信息的图层。该参数列表中的图层必须是WMS的 Capabilities
XML文档中包含的图层。
GetFeaturelnfo
请求中可选的 Info_Format
参数指明用什么格式返回要素的信息。该格式在WMS的 Capabilities
XML文档中定义为MIME类型。如 Info_Format=application/vnd.ogc.gml
表不返回结果用GML描述。
GetFeaturelnfo
请求中 Feature_Count
可选的参数表明返回要素信息的最大要素数量。默认值为 1
。X,Y
参数表示地图上感兴趣点的像素坐标。X,Y
值分别在 Width
和 Height
参数值内。坐标原点在图片的左上角。
如果 GetFeaturelnfo
请求有效,WMS将根据 Info_Format
作出响应。响应的性质将由WMS服务器作出判断,但一般与点 (X,Y)
最近的要素相对应。
GetFeatureInfo
请求这里说明发布的 MapServer WMS 服务的 GetFeatureInfo
访问。
首先是 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.cn/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
与前面 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.cn/cgi-bin/mapserv?map=/owg/mfb1.map&" | 24 | "wms_onlineresource" "http://webgis.cn/cgi-bin/mapserv?map=/owg/mfb2.map&" | ||
11 | "ows_onlineresource" "//webgis.cn/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 |
这个 Mapfile 配置了 WMS 服务。查看功能:
上面的结果使用模板输出 。
WMS,Web Mapping Server,属于 OGC 发布的规范。
GetFeatureInfo
是 WMS 支持的访问方法。