WFS筛选器编码¶
- 作者
Jeff McKenna
- 联系方式
jmckenna at gatewaygeomatics.com
- 作者
Yewondwossen Assefa
- 联系方式
assefa at dmsolutions.ca
- 最后更新
2019-11-21
介绍¶
本文档描述了利用WFS GetFeature请求中的过滤器编码(FE)支持的过程,该请求已在4.2版中添加到MapServer中。
本文档假定您已经熟悉mapserver的以下方面:
MapServer应用程序开发和设置.map文件。
熟悉WFS规范将是一种优势。到MapServer WFS文档的链接包含在下一节中。
从MapServer 7.0开始, OGC Filter Encoding 2.0 specification 还用于评估WFS 2.0 GetFeature请求的筛选器。
当前支持的功能¶
下表列出了当前支持的FE功能。
表1。当前支持的功能
特征集 |
特征 |
---|---|
空间能力 |
|
等于 |
|
不相交 |
|
触摸 |
|
内 |
|
重叠 |
|
交叉 |
|
相交 |
|
包含 |
|
DWithin |
|
BBOX |
|
标量功能 |
|
逻辑运算符 |
|
和 |
|
或 |
|
不是 |
|
比较运算符 |
|
属性等同于(=) |
|
属性不等于(<>) |
|
属性Islessthan(<) |
|
属性大于(>) |
|
属性小于或等于(<=) |
|
属性大于或等于(>=) |
|
PropertyIsLike |
|
属性介于(范围) |
获取和发布请求¶
MapServer已经能够接收和分析GET请求和URL编码的POST请求。已经添加了MapServer能够使用请求正文中发送的XML编码信息接收POST请求的功能。此外,还增加了为WFS层生成XML编码的POST请求的能力。
现在,所有WFS请求都支持GET和POST请求:
GetCapabilities
GetFeatures
DescribeFeatureType
在Post中支持这些WFS请求是为了保持所有支持的WFS请求之间的一致性而实现的。
发送请求时,使用的默认请求方法是POST。为了改变这种行为,我们引入了一个层级的元数据,wfs_-request_方法,它可以设置为“get”。
在MapServer中使用过滤器编码¶
本节介绍如何在服务器和客户端上使用fe。
服务器端¶
为了能够使用过滤器编码,您需要使用mapserver创建一个有效的WFS服务器。请参阅 WFS Server HOWTO 具体情况。
对于筛选编码,不应该向WFS服务器添加任何特殊内容,但是您应该注意,在请求WFS服务器的功能时,返回的文档应该包含支持的筛选。以下是功能文档的一部分(请注意“筛选功能”部分):
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 61 62 63 64 65 66 | <?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://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd">
<!-- MapServer version 5.6.5 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE
SUPPORTS=ICONV SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT
SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER
SUPPORTS=GEOS SUPPORTS=RGBA_PNG INPUT=EPPL7 INPUT=POSTGIS INPUT=OGR
INPUT=GDAL INPUT=SHAPEFILE -->
<Service>
<Name>MapServer WFS</Name>
<Title>WMS Demo Server for MapServer</Title>
<Abstract>This demonstration server showcases MapServer (www.mapserver.org)
and its OGC support</Abstract>
<OnlineResource>https://demo.mapserver.org/cgi-bin/wfs?</OnlineResource>
</Service>
<Capability>
<Request>
<GetCapabilities>
<DCPType>
<HTTP>
<Get onlineResource="https://demo.mapserver.org/cgi-bin/wfs?"/>
</HTTP>
</DCPType>
<DCPType>
<HTTP>
<Post onlineResource="https://demo.mapserver.org/cgi-bin/wfs?"/>
</HTTP>
</DCPType>
</GetCapabilities>
...
</Request>
</Capability>
...
<ogc:Filter_Capabilities>
<ogc:Spatial_Capabilities>
<ogc:Spatial_Operators>
<ogc:Equals/>
<ogc:Disjoint/>
<ogc:Touches/>
<ogc:Within/>
<ogc:Overlaps/>
<ogc:Crosses/>
<ogc:Intersects/>
<ogc:Contains/>
<ogc:DWithin/>
<ogc:BBOX/>
</ogc:Spatial_Operators>
</ogc:Spatial_Capabilities>
<ogc:Scalar_Capabilities>
<ogc:Logical_Operators/>
<ogc:Comparison_Operators>
<ogc:Simple_Comparisons/>
<ogc:Like/>
<ogc:Between/>
</ogc:Comparison_Operators>
</ogc:Scalar_Capabilities>
</ogc:Filter_Capabilities>
</WFS_Capabilities>
|
客户端¶
为了能够为WFS服务器生成一个过滤器,调用了一个层级元数据 wfs_filter 已添加,其中应包含要发送到服务器的筛选器。下面是一个带有过滤器的有效WFS客户机层的示例:
LAYER
NAME "cities"
TYPE POINT
STATUS ON
CONNECTION "https://demo.mapserver.org/cgi-bin/wfs?"
CONNECTIONTYPE WFS
METADATA
"wfs_typename" "cities"
"wfs_version" "1.0.0"
"wfs_connectiontimeout" "60"
"wfs_maxfeatures" "100"
"wfs_filter" "<PropertyIsGreaterThan><PropertyName>POPULATION</PropertyName>
<Literal>10000000</Literal></PropertyIsGreaterThan>"
END
PROJECTION
"init=epsg:4326"
END
LABELITEM 'NAME'
CLASS
NAME 'World Cities'
STYLE
COLOR 255 128 128
OUTLINECOLOR 128 0 0
SYMBOL 'circle'
SIZE 9
END
LABEL
COLOR 0 0 0
OUTLINECOLOR 255 255 255
TYPE TRUETYPE
FONT sans
SIZE 7
POSITION UC
PARTIALS FALSE
END
END
END
注意:
作为wfs ou filter元数据值给定的筛选器不应包含<filter>开始和结束标记。
连接指向支持筛选器的有效WFS服务器
将使用层中定义的类绘制返回的形状。
测验¶
以下是不同支持的筛选器的一些测试URL:
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<PropertyIsEqualTo><PropertyName>NAME</PropertyName>
<Literal>Halifax</Literal></PropertyIsEqualTo></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<PropertyIsNotEqualTo><PropertyName>NAME</PropertyName>
<Literal>Halifax</Literal></PropertyIsNotEqualTo></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<PropertyIsLessThan><PropertyName>POPULATION</PropertyName>
<Literal>1000</Literal></PropertyIsLessThan></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<PropertyIsGreaterThan><PropertyName>POPULATION</PropertyName>
<Literal>10000000</Literal></PropertyIsGreaterThan></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<PropertyIsLessThanOrEqualTo><PropertyName>POPULATION</PropertyName>
<Literal>499</Literal></PropertyIsLessThanOrEqualTo></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<PropertyIsGreaterThanOrEqualTo><PropertyName>POPULATION</PropertyName>
<Literal>10194978</Literal></PropertyIsGreaterThanOrEqualTo></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<PropertyIsBetween><PropertyName>POPULATION</PropertyName>
<LowerBoundary>10194978</LowerBoundary>
<UpperBoundary>12116379</UpperBoundary></PropertyIsBetween></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<PropertyIsLike wildcard='*' singleChar='.' escape='!'>
<PropertyName>NAME</PropertyName><Literal>Syd*</Literal></PropertyIsLike>
</Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<OR><PropertyIsEqualTo><PropertyName>NAME</PropertyName>
<Literal>Sydney</Literal></PropertyIsEqualTo><PropertyIsEqualTo>
<PropertyName>NAME</PropertyName><Literal>Halifax</Literal>
</PropertyIsEqualTo></OR></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<AND><PropertyIsLike wildcard='*' singleChar='.' escape='!'>
<PropertyName>NAME</PropertyName><Literal>Syd*</Literal></PropertyIsLike>
<PropertyIsEqualTo><PropertyName>POPULATION</PropertyName>
<Literal>4250065</Literal></PropertyIsEqualTo></AND></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<AND><NOT><PropertyIsEqualTo><PropertyName>POPULATION</PropertyName>
<Literal>0</Literal></PropertyIsEqualTo></NOT><NOT><PropertyIsEqualTo>
<PropertyName>POPULATION</PropertyName><Literal>12116379</Literal>
</PropertyIsEqualTo></NOT></AND></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<BBOX><PropertyName>Name>NAME</PropertyName><Box%20srsName='EPSG:42304'>
<coordinates>135.2239,34.4879 135.8578,34.8471</coordinates></Box></BBOX>
</Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<DWithin><PropertyName>Geometry</PropertyName><gml:Point>
<gml:coordinates>135.500000,34.666667</gml:coordinates>
</gml:Point><Distance units='m'>10000</Distance></DWithin></Filter>
https://demo.mapserver.org/cgi-bin/wfs?&VERSION=1.0.0&SERVICE=WFS
&REQUEST=GetFeature&TYPENAME=cities&Filter=<Filter>
<Intersects><PropertyName>Geometry</PropertyName>
<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing>
<gml:coordinates>135.5329,34.6624 135.4921,34.8153 135.3673,34.7815
135.3800,34.6216 135.5361,34.6210 135.5329,34.6624</gml:coordinates>
</gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></Filter>
OGC一致性测试(http://cite.opengeospatial.org/test_engine)已在FE支持上运行。下表和注释反映了当前状态。
表2。WFS OGC测试套件(通过HTTP GET和POST方法)
测试用例 |
描述 |
#测试数量 |
#失败的测试 |
---|---|---|---|
1 |
HTTP GET和POST方法上的基本WFS测试 |
402 |
281 |
1.1 |
GetCapabilities |
16 |
0 |
1.2 |
DescribeFeatureType |
18 |
0 |
1.3 |
GetFeature |
368 |
281 |
1.3.1 |
基本WFS测试 |
20 |
1 |
1.3.2 |
复杂的WFS测试 |
18 |
18 |
1.3.3 |
算术滤波器WFS测试 |
8 |
8 |
1.3.4 |
比较WFS测试 |
50 |
26 |
1.3.4.1 |
GetFeature属性大于或等于筛选器 |
2 |
0 |
1.3.4.2 |
GetFeature属性在筛选器之间 |
6 |
2 |
1.3.4.3 |
GetFeature属性等同于筛选器 |
4 |
0 |
1.3.4.4 |
GetFeature属性大于筛选器 |
4 |
2 |
1.3.4.5 |
GetFeature属性大于或等于筛选器 |
6 |
6 |
1.3.4.6 |
GetFeature属性小于筛选器 |
6 |
4 |
1.3.4.7 |
GetFeature属性不等于或等于筛选器 |
6 |
4 |
1.3.4.8 |
GetFeature属性类似筛选器 |
2 |
0 |
1.3.4.9 |
GetFeature属性不等于筛选器 |
6 |
0 |
1.3.4.10 |
GetFeature属性为空筛选器 |
8 |
8 |
1.3.5 |
逻辑WFS测试 |
20 |
0 |
1.3.5.1 |
GetFeature和PropertyIsEquato PropertyIsEquato筛选器 |
8 |
0 |
1.3.5.2 |
GetFeature或PropertyIsEquato PropertyIsEquato筛选器 |
8 |
0 |
1.3.5.3 |
GetFeature不是PropertyIsNotEqualTo筛选器 |
4 |
0 |
1.3.6 |
空间算子WFS检验 |
252 |
228 |
1.3.6.1 |
获取功能bbox筛选器 |
36 |
12 |
1.3.6.2 |
使用其他筛选器类型获取功能 |
216 |
216 |
2 |
事务性WFS测试 |
69 |
69 |
ogc cite wfs测试套件可以在 OGC Cite portal .
以下是有关此测试套件的一些特定于MapServer的说明:
:
WFS/1.0.0/basic/getfeature/post/3断言与测试的xpath预期值之间存在矛盾。断言说:“测试未定义输出格式的GetFeature请求是否返回带有gml数据的wfs:FeatureCollection。”此请求的预期xpath值:“boolean(/ogc:serviceexceptionreport)”应为真。因此,断言意味着当WFS服务器收到包含未定义输出格式或根本没有输出格式的请求时,WFS服务器必须返回包含GML数据的WFS集合。xpath预期值意味着当WFS服务器收到一个输出格式未定义或根本没有输出格式的请求时,WFS服务器必须返回一个服务异常报告。
:
不支持。
:
不支持使用>、<、>=、<=进行字符串比较。
不支持日期比较。
参见
:
MapServer不支持此属性。
:
返回的功能XML不会验证,因为验证是针对特定的XSD(geomatry.xsd)完成的。
GDAL不支持多点和多层上的数据转换。
参见
:
不支持事务请求。