WFS(OpenGIS® Web Feature Service)当前版本是1.1.0。WFS标准定义了一些操作,这些操作允许用户在分布式的环境下通过HTTP对空间数据进行查询、编辑等操作。
WFS服务要求服务的接口必须由XML描述,另外数据交互必须由GML进行,数据过滤采用CQL[1]语言。
当一个客户端想要访问WFS服务时,一般会涉及到以下的流程:
1. 通过操作获取WFS服务支持的操作和要素类(Feature Type,可以理解为WFS中的数据集)。
2. (可能)通过操作获取WFS服务支持的要素类的定义。
3. 客户端发送某个操作的请求。
4. WFS服务处理请求。
5. WFS服务返回处理的结果和状态。
上面几个步骤中所提到的“操作”包括:
1. GetCapabilities(获取服务中的要素类及支持的操作)
2. DescribeFeatureType(描述要素类的信息)
3. GetFeature(获取要素)
4. GetGmlObject(通过XLink获取GML对象)
5. Transaction(创建、更新、删除数据的事务操作)
6. LockFeature(在事务过程中锁定要素)
但是,这些操作并不是必须全部实现,而是实现全部或部分。根据所支持的操作不同,WFS可以分为3类:
1. Basic WFS(就是最常被提及的WFS,必须支持GetCapabilities/ DescribeFeatureType/ GetFeature操作,在功能上意味着提供一个只读的数据服务)
2. XLink WFS(必须在Basic WFS基础上加上GetGmlObject操作)
3. Transaction WFS(也有称为WFS-T,必须在Basic WFS基础上加上Transaction操作以支持编辑数据,另外也可以加上GetGmlObject/LockFeature操作)
关于服务涉及的基本元素,可以参考前面的章节:《服务涉及的基本元素》。注意,在后面的内容中,服务的操作只介绍Basic WFS和Transaction WFS中需要实现的操作,也就是说GetCapabilities、DescribeFeatureType、GetFeature和Transaction操作。
GetCapabilities操作需要以下的参数:
参数 |
是否必须 |
默认值 |
SERVICE |
是 |
WFS |
REQUEST=GetCapabilities |
是 |
以下是一个WFS使用KVP格式的GetCapabilities操作示例:
http://www.someserver.com/wfs?
SERVICE=WFS&
REQUEST=GetCapabilities
以下是一个WFS使用XML格式的GetCapabilities操作示例:
xml version="1.0" ?>
<GetCapabilities service="WFS" xmlns="http://www.opengis.net/wfs"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs ../wfs/1.1.0/WFS.xsd" />
以下是一个WFS的GetCapabilities操作的响应示例:
xml version="1.0" encoding="UTF-8"?>
<wfs:WFS_Capabilites xmlns:ows="http://www.opengis.net/ows"
xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs"
xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs ../wfs.xsd" version="1.1.0"
updateSequence="0">
<ows:ServiceIdentification>
<ows:ServiceType>WFSows:ServiceType>
<ows:ServiceTypeVersion>1.1.0ows:ServiceTypeVersion>
<ows:Title>OGC Member WFSows:Title>
...
ows:ServiceIdentification>
<ows:ServiceProvider>
<ows:ProviderName>BlueOxows:ProviderName>
<ows:ServiceContact>
...
ows:ServiceContact>
ows:ServiceProvider>
<ows:OperationsMetadata>
<ows:Operation name="GetCapabilities">
...
ows:Operation>
<ows:Operation name="DescribeFeatureType">
...
ows:Operation>
<ows:Operation name="GetFeature">
...
ows:Operation>
<ows:Operation name="GetFeatureWithLock">
...
ows:Operation>
<ows:Operation name="GetGMLObject">
...
ows:Operation>
<ows:Operation name="LockFeature">
...
ows:Operation>
<ows:Operation name="Transaction">
...
ows:Operation>
<ows:Parameter name="srsName">
<ows:Value>EPSG:4326ows:Value>
ows:Parameter>
<ows:Constraint name="DefaultMaxFeatures">
<ows:Value>10000ows:Value>
ows:Constraint>
...
ows:OperationsMetadata>
<wfs:FeatureTypeList>
<wfs:FeatureType xmlns:bo="http://www.BlueOx.org/BlueOx">
<wfs:DefaultSRS>EPSG:62696405wfs:DefaultSRS>
<wfs:OutputFormats>
<wfs:Format>text/xml; subtype=gml/3.1.1wfs:Format>
wfs:OutputFormats>
<ows:WGS84BoundingBox>
<ows:LowerCorner>-180 -90ows:LowerCorner>
<ows:UpperCorner>180 90ows:UpperCorner>
ows:WGS84BoundingBox>
...
wfs:FeatureType>
wfs:FeatureTypeList>
<wfs:ServesGMLObjectTypeList>
<wfs:GMLObjectType xmlns:bo="http://www.BlueOx.org/BlueOx">
<wfs:Name>bo:OxTypewfs:Name>
<wfs:Title>Babe's Lineagewfs:Title>
<wfs:OutputFormats>
<wfs:Format>text/xml; subtype=gml/3.1.1wfs:Format>
<wfs:Format>text/xhmtlwfs:Format>
wfs:OutputFormats>
wfs:GMLObjectType>
wfs:ServesGMLObjectTypeList>
<wfs:SupportsGMLObjectTypeList>
<wfs:GMLObjectType>
<wfs:Name>gml:PointTypewfs:Name>
<wfs:OutputFormats>
<wfs:Format>text/xml; subtype=gml/3.1.1wfs:Format>
<wfs:Format>text/xhtmlwfs:Format>
wfs:OutputFormats>
wfs:GMLObjectType>
...
wfs:SupportsGMLObjectTypeList>
<ogc:Filter_Capabilities>
<ogc:Spatial_Capabilities>
<ogc:GeometryOperands>
<ogc:GeometryOperand>gml:Envelopeogc:GeometryOperand>
<ogc:GeometryOperand>gml:Pointogc:GeometryOperand>
<ogc:GeometryOperand>gml:LineStringogc:GeometryOperand>
<ogc:GeometryOperand>gml:Polygonogc:GeometryOperand>
...
ogc:GeometryOperands>
<ogc:SpatialOperators>
<ogc:SpatialOperator name="BBOX" />
<ogc:SpatialOperator name="Equals" />
<ogc:SpatialOperator name="Disjoint" />
<ogc:SpatialOperator name="Intersects" />
<ogc:SpatialOperator name="Touches" />
<ogc:SpatialOperator name="Crosses" />
<ogc:SpatialOperator name="Within" />
<ogc:SpatialOperator name="Contains" />
<ogc:SpatialOperator name="Overlaps" />
<ogc:SpatialOperator name="Beyond" />
ogc:SpatialOperators>
ogc:Spatial_Capabilities>
<ogc:Scalar_Capabilities>
<ogc:LogicalOperators />
<ogc:ComparisonOperators>
<ogc:ComparisonOperator>LessThanogc:ComparisonOperator>
<ogc:ComparisonOperator>GreaterThanogc:ComparisonOperator>
<ogc:ComparisonOperator>LessThanEqualToogc:ComparisonOperator>
<ogc:ComparisonOperator>GreaterThanEqualToogc:ComparisonOperator>
<ogc:ComparisonOperator>EqualToogc:ComparisonOperator>
<ogc:ComparisonOperator>NotEqualToogc:ComparisonOperator>
<ogc:ComparisonOperator>Likeogc:ComparisonOperator>
<ogc:ComparisonOperator>Betweenogc:ComparisonOperator>
<ogc:ComparisonOperator>NullCheckogc:ComparisonOperator>
ogc:ComparisonOperators>
<ogc:ArithmeticOperators>
<ogc:SimpleArithmetic />
<ogc:Functions>
<ogc:FunctionNames>
<ogc:FunctionName nArgs="1">MINogc:FunctionName>
<ogc:FunctionName nArgs="1">MAXogc:FunctionName>
<ogc:FunctionName nArgs="1">SINogc:FunctionName>
<ogc:FunctionName nArgs="1">COSogc:FunctionName>
<ogc:FunctionName nArgs="1">TANogc:FunctionName>
ogc:FunctionNames>
ogc:Functions>
ogc:ArithmeticOperators>
ogc:Scalar_Capabilities>
<ogc:Id_Capabilities>
<ogc:EID />
<ogc:FID />
ogc:Id_Capabilities>
ogc:Filter_Capabilities>
wfs:WFS_Capabilites>
[1] OGC Common Query Language,参考《OGC Catalogue Service 2.0.2》标准的6.2章节。