OGC标准介绍 14
目录
· Transaction操作
1. KVP格式请求
Transaction操作使用KVP格式请求目前只支持Delete(Insert和Update必须通过XML格式请求发送)。Transaction操作需要以下的参数:
参数
是否必须
默认值
VERSION
是
1.1.0
SERVICE
是
WFS
REQUEST=Transaction
是
OPERATION=Delete
是
TYPENAME
是
RELEASEACTION
FILTER
BBOX
FEATUREID
以下是一个WFS使用KVP格式的Transaction操作示例:
http://www.someserver.com/wfs?
SERVICE=WFS&
VERSION=1.1.0&
REQUEST=Transaction&
OPERATION=Delete&
TYPENAME=InWaterA_1M,BuiltUpA_1M&
FILTER=(<Filter><Within><PropertyName>InWaterA_1M/wkbGeom<PropertyName>
<gml:Envelope>
<gml:lowerCorner>10 10</gml:lowerCorner>
<gml:upperCorner>20 20</gml:upperCorner></gml:Envelope></Within>
</Filter>)(< Filter><Within><PropertyName>BuiltUpA_1M/wkbGeom
<PropertyName><gml:Envelope><gml:lowerCorner>10 10</gml:lowerCorner>
<gml:upperCorner>20,20</gml:upperCorner>
</gml:Envelope></Within></Filter>)
2. XML格式请求
以下是一个WFS使用XML格式的Transaction操作示例:
<?xml version="1.0" ?> <wfs:Transaction version="1.1.0" service="WFS" handle="Transaction 01" xmlns="http://www.someserver.com/myns" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.someserver.com/myns http://www.someserver.com/wfs/cwwfs.cgi? request=DESCRIBEFEATURETYPE& typename=ELEVP_1M,RoadL_1M,BuiltUpA_1M http://www.opengis.net/wfs ../wfs/1.1.0/WFS.xsd"> <!-- Create a new instance of feature type RoadL_1M which has complex properties segment and roadType. --> <wfs:Insert handle="ComplexInsert"> <RoadL_1M> <name>Highway 401</name> <segement> <designation>SEG_A41</designation> <geometry> <gml:LineString gid="e3" srsName="http://www.opengis.net/gml/srs/epsg.xml#63266405"> <gml:posList>...</gml:posList> </gml:LineString> </geometry> </segment> <roadType> <surfaceType>Asphalt</surfaceType> <nLanes>12</nLanes> <grade>15</grade> </roadType> </RoadL_1M> </wfs:Insert> <!-- Update the designation of a particular range of segments which are now being collapsed into a single segment. The The filter uses an XPath expression to reference the designation property --> <wfs:Update typeName="RoadL_1M"> <wfs:Property> <wfs:Name>RoadL_1M/segment/designation</wfs:Name> <wfs:Value>SEG_A60</wfs:Value> </wfs:Property> <ogc:Filter> <ogc:PropertyIsBetween> <ogc:PropertyName>RoadL_1M/segment/designation</ogc:PropertyName> <ogc:LowerBoundary> <ogc:Literal>SEG_A60</ogc:Literal> </ogc:LowerBoundary> <ogc:UpperBoundary> <ogc:Literal>SEG_A69</ogc:Literal> </ogc:UpperBoundary> </ogc:PropertyIsBetween> </ogc:Filter> </wfs:Update> <!-- Delete the feature instance BuiltUpA_1M.1013. --> <wfs:Delete typeName="BuiltUpA_1M"> <ogc:Filter> <ogc:GmlObjectId gml:id="BuiltUpA_1M.1013" /> </ogc:Filter> </wfs:Delete> </wfs:Transaction>
3. 响应示例
以下是一个WFS的Transaction操作的响应示例:
<?xml version="1.0" ?> <wfs:TransactionResponse version="1.1.0" 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 ../wfs/1.1.0/WFS.xsd"> <wfs:TransactionSummary> <wfs:totalInserted>1</wfs:totalInserted> <wfs:totalUpdated>1</wfs:totalUpdated> <wfs:totalDeleted>1</wfs:totalDeleted> </wfs:TransactionSummary> <wfs:InsertResults> <wfs:Feature handle="ComplexInsert"> <ogc:FeatureId fid="RoadL_1M.1553" /> </wfs:Feature> <wfs:Feature handle="Statement 2"> <ogc:FeatureId fid="RoadL_1M.509876" /> </wfs:Feature> <wfs:Feature handle="Statement 2"> <ogc:FeatureId fid="BuiltUpA_1M.509877" /> </wfs:Feature> </wfs:InsertResults> </wfs:TransactionResponse>
· ArcGIS Server对WFS的支持
ArcGIS Server 10中支持的WFS版本为最新的1.1.0。在ArcGIS Server中,只需简单地勾选的Capabilities选项卡中可以选择支持WFS,如图 19。如果勾选了Transaction复选框,那么通过该WFS还可以进行数据更新(注意,需要是SDE数据源)。
图 19 ArcGIS Server发布WFS服务
现在我们在浏览器中执行一个GetFeature操作,查询名为“Beijing”的对象:
http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer?
request=getfeature&
typename=test_wfsTest:sde_cities&
filter=(
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>CITY_NAME</ogc:PropertyName>
<ogc:Literal>Beijing</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
)
这个操作返回如下的结果:
<wfs:FeatureCollection xsi:schemaLocation='http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer?request=DescribeFeatureType%26version=1.1.0%26typename=sde_cities http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd' xmlns:test_wfsTest='http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer' xmlns:gml='http://www.opengis.net/gml' xmlns:wfs='http://www.opengis.net/wfs' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> <gml:boundedBy> <gml:Envelope srsName='urn:ogc:def:crs:EPSG:6.9:4326'> <gml:lowerCorner>-86.002616990000007 -176.15156363599999</gml:lowerCorner> <gml:upperCorner>102.93161888100001 179.22188769499999</gml:upperCorner> </gml:Envelope> </gml:boundedBy> <gml:featureMember> <test_wfsTest:sde_cities gml:id='F3__474'> <test_wfsTest:OBJECTID>474</test_wfsTest:OBJECTID> <test_wfsTest:CITY_NAME>Beijing</test_wfsTest:CITY_NAME> <test_wfsTest:GMI_ADMIN>CHN-BJN</test_wfsTest:GMI_ADMIN> <test_wfsTest:ADMIN_NAME>Beijing</test_wfsTest:ADMIN_NAME> <test_wfsTest:FIPS_CNTRY>CH</test_wfsTest:FIPS_CNTRY> <test_wfsTest:CNTRY_NAME>China</test_wfsTest:CNTRY_NAME> <test_wfsTest:STATUS>National and provincial capital</test_wfsTest:STATUS> <test_wfsTest:POP_RANK>1</test_wfsTest:POP_RANK> <test_wfsTest:POP_CLASS>5,000,000 and greater</test_wfsTest:POP_CLASS> <test_wfsTest:PORT_ID>0</test_wfsTest:PORT_ID> <test_wfsTest:LABEL_FLAG>1</test_wfsTest:LABEL_FLAG> <test_wfsTest:NEAR_FID>40</test_wfsTest:NEAR_FID> <test_wfsTest:NEAR_DIST>185.74736243999999</test_wfsTest:NEAR_DIST> <test_wfsTest:Shape> <gml:Point> <gml:pos>39.906189088000019 116.38803663600004</gml:pos> </gml:Point> </test_wfsTest:Shape> </test_wfsTest:sde_cities> </gml:featureMember> </wfs:FeatureCollection>
接着,我想删掉这个对象,就要使用Transaction操作。在ArcGIS Server中,执行删除之前还需要lockId属性,因此还需要通过GetFeatureWithLock操作获取一个锁:
http://localhost:8399/arcgis/services/test/wfsTest/MapServer/WFSServer?
request=getfeaturewithlock&
typename=test_wfsTest:sde_cities&
filter=(
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>CITY_NAME</ogc:PropertyName>
<ogc:Literal>Beijing</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
)
这个操作返回lockId值为”{CEBC222E-00AD-49F5-A0E9-9F4CB98EE07E}”,接下来,我们通过一个POST请求对这个对象进行删除,请求体内容如下:
<wfs:Transaction version="1.1.0" service="WFS" xmlns="http://www.someserver.com/myns" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <wfs:LockId>{CEBC222E-00AD-49F5-A0E9-9F4CB98EE07E}</wfs:LockId> <wfs:Delete typeName="test_wfsTest:sde_cities"> <ogc:Filter> <ogc:GmlObjectId gml:id="F3__474" /> </ogc:Filter> </wfs:Delete> </wfs:Transaction>
删除成功后将会返回如下的结果:
<wfs:TransactionResponse version='1.1.0' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:gml='http://www.opengis.net/gml' xmlns:ogc='http://www.opengis.net/ogc' xmlns:wfs='http://www.opengis.net/wfs'> <wfs:TransactionSummary> <wfs:totalDeleted>1</wfs:totalDeleted> </wfs:TransactionSummary> </wfs:TransactionResponse>
我们也可以在其它的客户端中直接加载这个WFS服务,比如使用uDig:
图 20 uDig中加载ArcGIS Server发布的WFS服务