Home | Docs | Issue Tracker | FAQ | Download
MapServer logo

Table Of Contents

Previous topic

MapInfo

Next topic

GML

This Page

Quick search

Enter search terms or a module, class or function name.

WFS

WFS is an Open Geospatial Consortium (OGC) specification. For more information about the format itself, see: http://www.opengeospatial.org/standards/wfs

WFS allows a client to retrieve geospatial data encoded in Geography Markup Language (GML) from multiple Web Feature Services. GML is built on the standard web language XML.

WFS differs from the popular Web Map Service (WMS) specification in that WFS returns a subset of the data in valid GML format, not just a graphic image of data.

Capabilities

Requesting the capabilities using the GetCapabilities request to a WFS server returns an XML document showing what layers and projections are available, etc. Example of a WFS GetCapabilities URL:

http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap?VERSION=1.0.0&SERVICE=wfs&REQUEST=GetCapabilities

Example of the Resulting XML from GetCapabilties:

...
<FeatureTypeList>
<Operations>
        <Query/>
</Operations>
<FeatureType>
        <Name>park</Name>
        <Title>Parks</Title>
        <SRS>EPSG:42304</SRS>
        <LatLongBoundingBox minx="-173.433" miny="41.4271" maxx="-13.0481" maxy="83.7466" />
</FeatureType>
<FeatureType>
        <Name>road</Name>
        <Title>Roads</Title>
        <SRS>EPSG:42304</SRS>
        <LatLongBoundingBox minx="-148.059" miny="35.882" maxx="-33.7745" maxy="72.5503" />
</FeatureType>
<FeatureType>
        <Name>popplace</Name>
        <Title>Cities</Title>
        <SRS>EPSG:42304</SRS>
        <LatLongBoundingBox minx="-172.301" miny="36.3541" maxx="-12.9698" maxy="83.4832" />
</FeatureType>
</FeatureTypeList>
...

Data Access / Connection Method

  • WFS access is a core MapServer feature. MapServer currently supports WFS version 1.0.0
  • The CONNECTIONTYPE WFS parameter must be used.
  • WFS layers can be requested through a layer in a map file, or you can request the GML directly through the browser with a GetFeature request. You can specify a specific layer with the TypeName request. In a map file the name/value pairs should be put into a METADATA object.
  • You can limit the number of features returned in the GML by using the MaxFeatures option (e.g. &MAXFEATURES=100).

Example of a WFS Request Directly Through the Browser:

The following URL requests the GML for the layer road. (see the GetCapabilities above for the possible layers available on this test server) . The URL is all one line, broken up here for readability.

http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap
?VERSION=1.0.0
&SERVICE=wfs
&REQUEST=getfeature&TYPENAME=road

Map File Example:

LAYER
NAME "wfs_gmap_roads"
STATUS DEFAULT
TYPE LINE
CONNECTIONTYPE WFS
CONNECTION "http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap?
METADATA
        "wfs_version" "1.0.0"
        "wfs_srs" "EPSG:42304"
        "wfs_typename" "road"
        "wfs_request_method" "GET"
        "wfs_service" "WFS"
END
CLASS
        NAME "roads"
        STYLE
                COLOR 0 0 0
        END
END
END  # layer