6.2. 使用MapServer作为WFS客户端

WFS可以作为图层添加到MapServer中。通过这种方式,它被用作WFS客户端。

由于WFS需要通过网络传输数据,因此最好使用较少的数据量,此处的选择是使用点要素数据。

6.2.1. MapFile的写入方式

 1MAP
 2    IMAGETYPE "PNG"
 3    EXTENT -180 -90 180 90
 4    SIZE 600 300
 5    SHAPEPATH "/gdata"
 6    IMAGECOLOR 100 100 100
 7    WEB
 8        IMAGEPATH "/owg/ms_tmp/"
 9        IMAGEURL "/ms_tmp/"
10        METADATA
11            "wfs_title" "world country"
12            "wfs_onlineresource" "http://webgis.cn/cgi-bin/mapserv?map=/owg/mft6.map"
13            "wfs_srs" "EPSG:4326"
14            "wfs_abstract" "This text describes your wfs service"
15            "wfs_enable_request" "*"
16            "wms_enable_request" "*"
17            "ows_keywordlist" "world"
18            "gml_include_items" "all"
19        END
20    END
21    PROJECTION
22        "init=epsg:4326"
23    END
24    SYMBOL
25        NAME "circle"
26        TYPE ELLIPSE
27        FILLED TRUE
28        POINTS
29            10 10
30        END
31    END
32    LAYER
33        NAME "wcity_wfs"
34        TYPE POINT
35        OFFSITE 0 0 0
36        STATUS ON
37        CONNECTIONTYPE WFS
38        CONNECTION "http://webgis.cn/cgi-bin/mapserv?map=/owg/mft2.map&"
39        METADATA
40            "wfs_version" "1.0.0"
41            "wfs_srs" "EPSG:4326"
42            "wfs_typename" "world-city"
43            "wfs_request_method" "GET"
44            "wfs_connectiontimeout" "60"
45        END
46        PROJECTION
47            "init=epsg:4326"
48        END
49        CLASS
50            NAME "cities"
51            SYMBOL "circle"
52            SIZE 6
53            COLOR 255 255 0
54        END
55    END
56    LAYER
57        NAME "wcountry"
58        DATA "wcountry.shp"
59        STATUS OFF
60        TYPE POLYGON
61        CLASS
62            NAME "The Upper Great Lakes States"
63            STYLE
64                COLOR 232 232 232
65                OUTLINECOLOR 32 32 32
66            END
67        END
68    END
69END

6.2.2. 范例效果

其效果是:

http://webgis.cn/cgi-bin/mapserv?map=/owg/mft6.map&layers=states%20wcity_wfs&mode=map

请注意,上图是传统的MapServer生成的地图。由前面的WFS点层定义,因此它主要被多边形遮挡。