I. WFS-要素Web服务
· 概述
WFS(OpenGIS® Web Feature Service)当前版本是1.1.0。WFS标准定义了一些操作,这些操作允许用户在分布式的环境下通过HTTP对空间数据进行查询、编辑等操作。
WFS服务要求服务的接口必须由XML描述,另外数据交互必须由GML进行,数据过滤采用CQL[1]语言。
· WFS种类与操作
当一个客户端想要访问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操作
1. KVP格式请求
GetCapabilities操作需要以下的参数:
参数 | 是否必须 | 默认值 |
SERVICE | 是 | WFS |
REQUEST=GetCapabilities | 是 |
以下是一个WFS使用KVP格式的GetCapabilities操作示例:
http://www.someserver.com/wfs?
SERVICE=WFS&
REQUEST=GetCapabilities
2. XML格式请求
以下是一个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" />
3. 响应示例
以下是一个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>WFS
ows:ServiceType>
<ows:ServiceTypeVersion>1.1.0
ows:ServiceTypeVersion>
<ows:Title>OGC Member WFS
ows:Title>
...
ows:ServiceIdentification>
<ows:ServiceProvider>
<ows:ProviderName>BlueOx
ows: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:4326
ows:Value>
ows:Parameter> <ows:Constraint name="DefaultMaxFeatures"> <ows:Value>10000
ows:Value>
ows:Constraint> ...
ows:OperationsMetadata>
<wfs:FeatureTypeList> <wfs:FeatureType xmlns:bo="http://www.BlueOx.org/BlueOx"> <wfs:DefaultSRS>EPSG:62696405
wfs:DefaultSRS> <wfs:OutputFormats> <wfs:Format>text/xml; subtype=gml/3.1.1
wfs:Format>
wfs:OutputFormats> <ows:WGS84BoundingBox> <ows:LowerCorner>-180 -90
ows:LowerCorner> <ows:UpperCorner>180 90
ows:UpperCorner>
ows:WGS84BoundingBox> ...
wfs:FeatureType>
wfs:FeatureTypeList>
<wfs:ServesGMLObjectTypeList> <wfs:GMLObjectType xmlns:bo="http://www.BlueOx.org/BlueOx"> <wfs:Name>bo:OxType
wfs:Name> <wfs:Title>Babe's Lineage
wfs:Title> <wfs:OutputFormats> <wfs:Format>text/xml; subtype=gml/3.1.1
wfs:Format> <wfs:Format>text/xhmtl
wfs:Format>
wfs:OutputFormats>
wfs:GMLObjectType>
wfs:ServesGMLObjectTypeList>
<wfs:SupportsGMLObjectTypeList> <wfs:GMLObjectType> <wfs:Name>gml:PointType
wfs:Name> <wfs:OutputFormats> <wfs:Format>text/xml; subtype=gml/3.1.1
wfs:Format> <wfs:Format>text/xhtml
wfs:Format>
wfs:OutputFormats>
wfs:GMLObjectType> ...
wfs:SupportsGMLObjectTypeList>
<ogc:Filter_Capabilities> <ogc:Spatial_Capabilities> <ogc:GeometryOperands> <ogc:GeometryOperand>gml:Envelope
ogc:GeometryOperand> <ogc:GeometryOperand>gml:Point
ogc:GeometryOperand> <ogc:GeometryOperand>gml:LineString
ogc:GeometryOperand> <ogc:GeometryOperand>gml:Polygon
ogc: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>LessThan
ogc:ComparisonOperator> <ogc:ComparisonOperator>GreaterThan
ogc:ComparisonOperator> <ogc:ComparisonOperator>LessThanEqualTo
ogc:ComparisonOperator> <ogc:ComparisonOperator>GreaterThanEqualTo
ogc:ComparisonOperator> <ogc:ComparisonOperator>EqualTo
ogc:ComparisonOperator> <ogc:ComparisonOperator>NotEqualTo
ogc:ComparisonOperator> <ogc:ComparisonOperator>Like
ogc:ComparisonOperator> <ogc:ComparisonOperator>Between
ogc:ComparisonOperator> <ogc:ComparisonOperator>NullCheck
ogc:ComparisonOperator>
ogc:ComparisonOperators> <ogc:ArithmeticOperators> <ogc:SimpleArithmetic /> <ogc:Functions> <ogc:FunctionNames> <ogc:FunctionName nArgs="1">MIN
ogc:FunctionName> <ogc:FunctionName nArgs="1">MAX
ogc:FunctionName> <ogc:FunctionName nArgs="1">SIN
ogc:FunctionName> <ogc:FunctionName nArgs="1">COS
ogc:FunctionName> <ogc:FunctionName nArgs="1">TAN
ogc: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章节。