6.2. Use MapServer as the WFS client#

WFS can be added as a layer in MapServer. In this way, it is used as a WFS client.

Since WFS needs to transfer data over the network, it is best to use smaller amounts of data. The selection here is to use point feature data.

6.2.1. Writting way of 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.pub/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.pub/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. Example effect#

The effect is:

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

Note that the above graph is a traditional MapServer generated map. Defined by the WFS point layer in front, so it’s mostly occluded by polygons.