Creating a WFS Server
The MapServer software can be configured to offer the OGC standardised service interfaces for a Web Feature Service (WFS). Note that this will only work properly for LAYERs that meet the following conditions:
- The data source is of a vector type (points, lines, polygons from e.g. shapefiles or PostGIS);
LAYER TYPE
therefore is one of:POINT, LINE
, orPOLYGON
; LAYER NAME
must be set; Layer names must start with a letter (not a number) and must not have spaces in them;- In the layer definition, the statement
DUMP TRUE
is included; - The
wfs_onlineresource
metadata is set in theWEB
objectsMETADATA
and specifies the URL that should be used to access your server.
Listing 1 below is an example of a bare minimum WFS Map File with just one layer.
Create a file in the root of your Thailand site with the name configWFS.map
and copy the contents of Listing 1 into it. Do not forget to exchange the [NETPATH]
parameters with its proper value, as you should have learned in the earlier WMS exercise...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
MAP NAME Thailand PROJECTION "init=epsg:4326" END EXTENT 97.3 5.6 105.7 20.5 # lon/lat extents of Thailand WEB METADATA "ows_enable_request" "*" "map" "[NETPATH]/configWFS.map" "ows_title" "Thailand WFS Server" "ows_service" "WFS" "wfs_onlineresource" "https://gisedu.itc.utwente.nl/cgi-bin/mapserv.exe?map=[NETPATH]/configWFS.map&" "ows_srs" "EPSG:4326" #latlon END #metadata VALIDATION "map" "*" END END #web LAYER NAME airportsWFS TYPE POINT STATUS ON CONNECTIONTYPE postgis CONNECTION "user=exercises password=exercises dbname=exercises host=gisedu.itc.utwente.nl port=5434 options='-c client_encoding=UTF8'" DATA "geom FROM thailand.airports USING UNIQUE id USING srid=4326" METADATA "wfs_title" "airportsWFS" "gml_include_items" "all" "gml_featureid" "id" "wfs_srs" "EPSG:4326" "wfs_extent" "97.3 5.6 105.7 20.5" END #metadata END #layer airportsWFS END #map |