Lesson 3 - Web Feature Servers

The GetFeature request

As with a WMS getMap request, the getFeature request of the WFS specification is what actually requests the data. In a WFS you actually get back the data rather than the picture of the data that a WMS gives you.

GetFeature

GetFeature

  • version (required) attribute (either 1.0.0 or 1.1.0)
  • service (required and always WFS) attribute
  • outputformat (optional) – which of the formats listed in the capabilities response would you like the data in (default is GML)
  • maxfeatures (optional) – what is the maximum number of features you would like returned (default is unlimited)

query (required)

  • typename (required) – which feature type do you want back
  • featureVersion (optional) – provides support for versioned feature stores, 1 is the oldest (default is newest).
  • propertyName (optional) – which properties of the features would you like to get back for each feature.
  • filter (optional) – a filter that selects which features to return. A filter can be spatial or be based on attribute values.

Request

<wfs:GetFeature service="WFS"  version="1.0.0"
  outputFormat="GML2"  – we would like gml2 as the return format
  xmlns:topp="http://www.openplans.org/topp"
  xmlns:wfs="http://www.opengis.net/wfs"
  xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opengis.net/wfs
  http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
  <wfs:Query typeName="topp:bc_roads">  we want to query 
				bc_roads features
    <ogc:Filter>
      <ogc:FeatureId fid="bc_roads.1"/> only return features 
                                        with an ID of bc_roads.1
    </ogc:Filter>
    </wfs:Query>
</wfs:GetFeature>

The response from the server is a GML encoded feature collection. Compare this feature to the schema that describeFeature returned on the page before this.

Response

<wfs:FeatureCollection  
	xsi:schemaLocation="http://www.openplans.org/topp  
	http://localhost:8080/geoserver/wfs/DescribeFeatureType
?typeName=topp:bc_roads http://www.opengis.net/wfs http://localhost:8080/geoserver/data/capabilities/wfs/1
.0.0/WFS-basic.xsd"> <gml:boundedBy>the bounds of the features returned <gml:Box srsName="http://www.opengis.net/gml/srs/eps
g.xml#27354"> <gml:coordinates decimal="." cs="," ts=" "> 494475.71056415,5433016.8189323 494982.7
0115662,5435041.95096618 </gml:coordinates> </gml:Box> </gml:boundedBy> <gml:featureMember>the first feature <topp:bc_roads fid="bc_roads.1"> - its ID <topp:the_geom> - the geometry <gml:MultiLineString – a multistring srsName="http://www.opengis.net/gml/srs/epsg.xml#27354"> <gml:lineStringMember> <gml:LineString> <gml:coordinates decimal="." cs="
," ts=" "> the actual coordinates 494475.71056415,5433016.8189323 494982.70115662,5435041.95096618 </gml:coordinates> </gml:LineString> </gml:lineStringMember> </gml:MultiLineString> </topp:the_geom> <topp:LENGTH>2163.48</topp:LENGTH>
the length of the road
<topp:BTRN_BC_ID>13166</topp:BTRN_BC_ID> th
e road name/ID
</topp:bc_roads> </gml:featureMember> </wfs:FeatureCollection>