WMS GetFeatureInfo 访问

这里说明发布的 MapServer WMS 服务的 GetFeatureInfo 访问。

首先是 Mapfile:

01 MAP
02     NAME "EX2_"
03     IMAGETYPE "png24"
04     EXTENT -97.5 41.619778 -82.122902 49.38562
05     SIZE 400 300
06     SHAPEPATH "../data"
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 "/oswebgis/ms_tmp/"
20         IMAGEURL "/ms_tmp/"
21         METADATA
22             "wms_title" "WMS Demo Server"
23             "wms_version" "1.3.0"
24             "wms_onlineresource" "http://192.168.56.1/cgi-bin/mapserv?map=/oswebgis/example_ogc.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 "states"
37         DATA "states_ugl"
38         STATUS ON
39         TYPE POLYGON
40         TEMPLATE "tmpl_ogc.html"
41         METADATA
42             "wms_title" "test2"
43             "wms_version" "1.3.0"
44             "wms_srs" "EPSG:4326"
45             "wms_enable_request" "*"
46             "ows_enable_request" "*"
47             "wms_feature_info_mime_type" "text/html"
48             "wms_format" "image/png"
49         END
50         PROJECTION
51             "init=epsg:4326"
52         END
53         CLASSITEM "CLASS"
54         CLASS
55             EXPRESSION "land"
56             STYLE
57                 SYMBOL 0
58                 COLOR 100 200 200
59             END
60         END
61         CLASS
62             EXPRESSION "water"
63             STYLE
64                 SYMBOL 0
65                 COLOR 0 200 0
66             END
67         END
68     END
69 END

与前面 xmfb1.map 相比:

f1MAPf1MAP
nn2    NAME "EX2_"
2    IMAGETYPE "PNG"3    IMAGETYPE "png24"
3    EXTENT -97.238976 41.619778 -82.122902 49.385624    EXTENT -97.5 41.619778 -82.122902 49.38562
4    SIZE 400 3005    SIZE 400 300
5    SHAPEPATH "../data"6    SHAPEPATH "../data"
n6    IMAGECOLOR 255 255 255n7    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    WEB17    WEB
nn18        TEMPLATE "tmpl_ogc.html"
19        IMAGEPATH "/oswebgis/ms_tmp/"
20        IMAGEURL "/ms_tmp/"
8        METADATA21        METADATA
9            "wms_title" "WMS Demo Server"22            "wms_title" "WMS Demo Server"
nn23            "wms_version" "1.3.0"
10            "wms_onlineresource" "http://webgis.osgeo.cn/cgi-bin/mapserv?map=/oswebgis/xmfb1.map&"24            "wms_onlineresource" "http://192.168.56.1/cgi-bin/mapserv?map=/oswebgis/example_ogc.map&"
11            "ows_onlineresource" "http://webgis.osgeo.cn/cgi-bin/mapserv?map=/oswebgis/xmfb1.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        END30        END
nn31    END
32    PROJECTION
33        "init=epsg:4326"
15    END34    END
18        DATA "states_ugl"37        DATA "states_ugl"
n19        STATUS OFFn38        STATUS ON
20        TYPE POLYGON39        TYPE POLYGON
nn40        TEMPLATE "tmpl_ogc.html"
41        METADATA
42            "wms_title" "test2"
43            "wms_version" "1.3.0"
44            "wms_srs" "EPSG:4326"
45            "wms_enable_request" "*"
46            "ows_enable_request" "*"
47            "wms_feature_info_mime_type" "text/html"
48            "wms_format" "image/png"
49        END
50        PROJECTION
51            "init=epsg:4326"
52        END
53        CLASSITEM "CLASS"
21        CLASS54        CLASS
n22            NAME "The Upper Great Lakes States"n55            EXPRESSION "land"
23            STYLE56            STYLE
t24                COLOR 232 232 232t57                SYMBOL 0
25                OUTLINECOLOR 32 32 3258                COLOR 100 200 200
59            END
60        END
61        CLASS
62            EXPRESSION "water"
63            STYLE
64                SYMBOL 0
65                COLOR 0 200 0
26            END66            END

这个 Mapfile 配置了 WMS 服务。查看功能:

打开链接

查看地图

查看地图

使用 GetFeatureInfo 访问

使用 GetFeatureInfo

上面的结果使用模板输出 。

说明

WMS,Web Mapping Server,属于 OGC 发布的规范。

GetFeatureInfo 是 WMS 支持的访问方法。