Author: | Jeff McKenna |
---|---|
Contact: | jmckenna at gatewaygeomatics.com |
Author: | Yewondwossen Assefa |
Contact: | assefa at dmsolutions.ca |
Revision: | $Revision: 8479 $ |
Date: | $Date: 2009-01-29 11:56:34 -0800 (Thu, 29 Jan 2009) $ |
Last Updated: | 2005/09/23 |
Table of Contents
This document describes the procedures for taking advantage of the Filter Encoding (FE) support in WFS GetFeature requests, which was added to MapServer in version 4.2.
This document assumes that you are already familiar with the following aspects of MapServer:
The following table lists the currently supported features for FE.
Table 1. Currently Supported Features
Feature Set | Feature |
---|---|
Spatial Capabilities | |
Equals | |
Disjoint | |
Touches | |
Within | |
Overlaps | |
Crosses | |
Intersects | |
Contains | |
DWithin | |
BBOX | |
Scalar Capabilities | |
Logical Operators | |
And | |
Or | |
Not | |
Comparison Operators | |
PropertyIsEqualTo (=) | |
PropertyIsNotEqualTo (<>) | |
PropertyIsLessThan (<) | |
PropertyIsGreaterThan (>) | |
PropertyIsLessThanOrEqualTo (<=) | |
PropertyIsGreaterThanOrEqualTo (>=) | |
PropertyIsLike | |
PropertyIsBetween (range) |
MapServer already has the capability to receive and parse Get requests and URL-encoded Post requests. The ability for MapServer to be able to receive Post requests with XML-encoded information sent in the body of the request has been added. Also, the ability to generate XML-encoded Post requests for WFS layers has been added.
Both Get and Post request are now supported for all WFS requests:
Supporting these WFS requests in Post was implemented to keep consistency between all supported WFS requests.
When sending requests, the default request method used is Post. To change this behavior, we have introduced a layer level meta data, wfs_request_method, which can be set to “GET”.
This section describes how to use FE on both the server and client sides.
To be able to use Filter Encoding, you need to create a valid WFS server using MapServer. Please refer to the WFS Server HOWTO for specifics.
There is nothing special that should be added to a WFS server for Filter Encoding, but you should note that, when requesting the capabilities of your WFS server, the document returned should contain the supported filters. Here is part of a Capabilities document as well as the Post support:
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <?xml version='1.0' encoding="ISO-8859-1" ?>
<WFS_Capabilities
version="1.0.0"
updateSequence="0"
xmlns="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://ogc.dmsolutions.ca/wfs/1.0.0/WFS-capabilities.xsd">
<!-- MapServer version 4.1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
OUTPUT=PDF OUTPUT=SWF SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER
SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT INPUT=POSTGIS
INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE -->
<Service>
<Name>MapServer WFS</Name>
<Title>GMap WMS Demo Server</Title>
<OnlineResource>http://localhost/cgi-bin/mapserv.exe?map=
c:/msapps/wfs_filter/htdocs/ns_wfsserver.map&</OnlineResource>
</Service>
<Capability>
<Request>
<GetCapabilities>
<DCPType>
<HTTP>
<Get onlineResource="http://localhost/cgi-bin/mapserv.exe?map=
c:/msapps/wfs_filter/htdocs/ns_wfsserver.map&" />
</HTTP>
</DCPType>
<DCPType>
<HTTP>
<Post onlineResource="http://localhost/cgi-bin/mapserv.exe?map=
c:/msapps/wfs_filter/htdocs/ns_wfsserver.map&" />
</HTTP>
</DCPType>
</GetCapabilities>
...
</Request>
</Capability>
...
<Filter_Capabilities>
<Spatial_Capabilities>
<Spatial_Operators>
<Intersect/>
<DWithin/>
<BBOX/>
</Spatial_Operators>
</Spatial_Capabilities>
<Scalar_Capabilities>
<Logical_Operators />
<Comparison_Operators>
<Simple_Comparisons />
<Like />
<Between />
</Comparison_Operators>
</Scalar_Capabilities>
</Filter_Capabilities>
</WFS_Capabilities>
|
To be able to generate a Filter to a WFS server, a layer level metadata called wfs_filter has been added, which should contain the filter to be sent to the server. Following is an example of a valid WFS client layer with a filter:
LAYER
NAME popplace
METADATA
"wfs_version" "1.0.0"
"wfs_typename" "popplace"
"wfs_filter" "<PropertyIsGreaterThan><PropertyName>POP_RANGE</PropertyName>
<Literal>4</Literal></PropertyIsGreaterThan>"
END
TYPE POINT
STATUS ON
PROJECTION
"init=epsg:42304"
END
CONNECTIONTYPE WFS
CONNECTION "http://www2.dmsolutions.ca:8090/cgi-bin/mswfs_filter?"
LabelItem "Name"
CLASSITEM "Capital"
CLASS
SYMBOL 2
SIZE 8
NAME "Cities"
LABEL
COLOR 255 0 0
FONT fritqat-italic
TYPE truetype
SIZE 8
POSITION AUTO
OUTLINECOLOR 255 255 255
FORCE TRUE
END
COLOR 0 0 0
END
END # Layer
Note:
Here are some test URLs for the different supported filters:
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><PropertyIsEqualTo><PropertyName>NAME</PropertyName>
<Literal>Digby</Literal></PropertyIsEqualTo></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><PropertyIsNotEqualTo><PropertyName>NAME</PropertyName>
<Literal>Digby</Literal></PropertyIsNotEqualTo></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><PropertyIsLessThan><PropertyName>POP_RANGE</PropertyName>
<Literal>2</Literal></PropertyIsLessThan></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><PropertyIsGreaterThan><PropertyName>POP_RANGE</PropertyName>
<Literal>5</Literal></PropertyIsGreaterThan></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><PropertyIsLessThanOrEqualTo><PropertyName>POP_RANGE</PropertyName>
<Literal>2</Literal></PropertyIsLessThanOrEqualTo></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><PropertyIsGreaterThanOrEqualTo><PropertyName>POP_RANGE</PropertyName>
<Literal>5</Literal></PropertyIsGreaterThanOrEqualTo></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><PropertyIsBetween><PropertyName>POP_RANGE</PropertyName>
<LowerBoundary>5</LowerBoundary><UpperBoundary>6</UpperBoundary></PropertyIsBetween></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><PropertyIsLike wildcard='*' singleChar='.' escape='!'>
<PropertyName>NAME</PropertyName><Literal>Syd*</Literal></PropertyIsLike></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><OR><PropertyIsEqualTo><PropertyName>NAME</PropertyName>
<Literal>Sydney</Literal></PropertyIsEqualTo><PropertyIsEqualTo><PropertyName>NAME</PropertyName>
<Literal>Digby</Literal></PropertyIsEqualTo></OR></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><AND><PropertyIsLike wildcard='*' singleChar='.' escape='!'>
<PropertyName>NAME</PropertyName><Literal>Syd*</Literal></PropertyIsLike><PropertyIsEqualTo>
<PropertyName>POP_RANGE</PropertyName><Literal>4</Literal></PropertyIsEqualTo></AND></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&
TYPENAME=popplace&Filter=<Filter><AND><NOT><PropertyIsEqualTo><PropertyName>POP_RANGE</PropertyName>
<Literal>2</Literal></PropertyIsEqualTo></NOT><NOT><PropertyIsEqualTo><PropertyName>POP_RANGE</PropertyName>
<Literal>3</Literal></PropertyIsEqualTo></NOT></AND></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=popplace&
Filter=<Filter><BBOX><PropertyName>Name>NAME</PropertyName><Box%20srsName='EPSG:42304'>
<coordinates>2518000,150000 2918000,450000</coordinates></Box></BBOX></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=popplace&Filter=
<Filter><DWithin><PropertyName>Geometry</PropertyName><gml:Point><gml:coordinates>2587598.000000,404010.531250</gml:coordinates>
</gml:Point><Distance units='m'>1000</Distance></DWithin></Filter>
http://www2.dmsolutions.ca/cgi-bin/mswfs_filter?&VERSION=1.0.0&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=popplace&Filter=<Filter>
<Intersect><PropertyName>Geometry</PropertyName><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing>
<gml:coordinates>2488789,289552 2588789,289552 2588789,389552 2488789,389552 2488789,289552</gml:coordinates>
</gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersect></Filter>
Table 2. WFS OGC test suite (over the HTTP Get and Post method)
Test # | Description | # of Tests | # of Failed Tests |
---|---|---|---|
1 | Basic WFS tests over the HTTP Get and Post method | 402 | 281 |
1.1 | GetCapabilities | 16 | 0 |
1.2 | DescribeFeatureType | 18 | 0 |
1.3 | GetFeature | 368 | 281 |
1.3.1 | Basic WFS tests | 20 | 1 |
1.3.2 | Complex WFS tests | 18 | 18 |
1.3.3 | Arithmetic filter WFS tests | 8 | 8 |
1.3.4 | Comparison WFS tests | 50 | 26 |
1.3.4.1 | GetFeature PropertyIsGreaterThanOrEqualTo filter | 2 | 0 |
1.3.4.2 | GetFeature PropertyIsBetween filter | 6 | 2 |
1.3.4.3 | GetFeature PropertyIsEqualTo filter | 4 | 0 |
1.3.4.4 | GetFeature PropertyIsGreaterThan filter | 4 | 2 |
1.3.4.5 | GetFeature PropertyIsGreaterThanOrEqualTo filter | 6 | 6 |
1.3.4.6 | GetFeature PropertyIsLessThan filter | 6 | 4 |
1.3.4.7 | GetFeature PropertyIsLessThanOrEqualTo filter | 6 | 4 |
1.3.4.8 | GetFeature PropertyIsLike filter | 2 | 0 |
1.3.4.9 | GetFeature PropertyIsNotEqualTo filter | 6 | 0 |
1.3.4.10 | GetFeature PropertyIsNull filter | 8 | 8 |
1.3.5 | Logical WFS test | 20 | 0 |
1.3.5.1 | GetFeature AND PropertyIsEqualTo PropertyIsEqualTo filter | 8 | 0 |
1.3.5.2 | GetFeature OR PropertyIsEqualTo PropertyIsEqualTo filter | 8 | 0 |
1.3.5.3 | GetFeature NOT PropertyIsNotEqualTo filter | 4 | 0 |
1.3.6 | Spatial operator WFS test | 252 | 228 |
1.3.6.1 | GetFeature BBOX filter | 36 | 12 |
1.3.6.2 | GetFeature with other filter types | 216 | 216 |
2 | Transactional WFS test | 69 | 69 |
The OGC Cite WFS test suite can be found on the OGC Cite portal.
Following are some MapServer specific notes on this test suite:
Test number 1.3.1:
Tests number 1.3.2 and 1.3.3:
Tests number 1.3.4.2, 1.3.4.4 to 1.3.4.7:
See also
Test number 1.3.4.10:
Test number 1.3.6.1:
See also
Test number 2: