WMS GetMap 访问

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

首先是 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

与前面 xmfa1.map 相比:

2    IMAGETYPE "PNG"2    IMAGETYPE "PNG"
n3    EXTENT 73 8 136 53n3    EXTENT -97.238976 41.619778 -82.122902 49.38562
4    SIZE 400 3004    SIZE 400 300
6    IMAGECOLOR 255 255 2556    IMAGECOLOR 255 255 255
nn7    WEB
8        METADATA
9            "wms_title" "WMS Demo Server"
10            "wms_onlineresource" "http://webgis.osgeo.cn/cgi-bin/mapserv?map=/oswebgis/xmfb1.map&"
11            "ows_onlineresource" "http://webgis.osgeo.cn/cgi-bin/mapserv?map=/oswebgis/xmfb1.map&"
12            "wms_srs" "EPSG:4269 EPSG:4326"
13            "wms_enable_request" "* !GetFeatureInfo"
14        END
15    END
7    LAYER16    LAYER
8        NAME "states"17        NAME "states"
t9        DATA "China4326"t18        DATA "states_ugl"
10        STATUS OFF19        STATUS OFF

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

打开链接

查看地图

查看地图

配置使用 GetMap

不开启 GetMap 的情况

要使用 GetMap , 需要在 WMS 中开启 GetMap 选项:

如果不开启的话,访问 URL 会显示 :

<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>

点击查看

未设置好投影

注意,使用 GetMap , 必须设置好投影。如果没设置好,访问会出现 :

<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>

点击查看

正确的访问

下面是正确的:

使用 GetMap

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 and CRS=CRS:84 for 1.3.0

使用 GetMap 获取部分地图

上面使用范围与整个数据的范围一致,结果看起来没什么不一样。下面缩小一下范围,来获取地图中的某一部分。

使用 GetMap 获取部分地图

see mapserver wms

根据说明,使用参数 CRS=EPSG:4326 也是可以的。但我未成功。 可能需要配置 MapFile.