文章版權由做者李曉暉和博客園共有,若轉載請於明顯處標明出處:http://www.cnblogs.com/naaoveGIS/html
Web地圖服務(WMS)利用具備地理空間位置信息的數據製做地圖。其中將地圖定義爲地理數據可視的表現。這個規範定義了三個操做:GetCapabitities返回服務級元數據,它是對服務信息內容和要求參數的一種描述; GetMap返回一個地圖影像,其地理空間參考和大小參數是明肯定義了的;GetFeatureInfo(可選)返回顯示在地圖上的某些特殊要素的信息。json
GeoServer官網上對其WMS規範的描述地址爲http://docs.geoserver.org/stable/en/user/services/wms/index.html。微信
Web要素服務(WFS)返回的是要素級的GML編碼,並提供對要素的增長、修改、刪除等事務操做,是對Web地圖服務的進一步深刻。OGC Web要素服務容許客戶端從多個Web要素服務中取得使用地理標記語言(GML)編碼的地理空間數據,這個遠東定義了五個操做:GetCapabilites返回Web要素服務性能描述文檔(用XML描述);DescribeFeatureType返回描述能夠提供服務的任何要素結構的XML文檔;GetFeature爲一個獲取要素實例的請求提供服務;Transaction爲事務請求提供服務;LockFeature處理在一個事務期間對一個或多個要素類型實例上鎖的請求。app
GeoServer官網上對其WFS規範的描述地址爲http://docs.geoserver.org/stable/en/user/services/wfs/index.html。性能
URL例子:測試
http://localhost:8680/geoserver/wms?service=wms&version=1.1.1&request=GetCapabilities。編碼
參數意義:.net
返回結果:code
其返回結果爲一個描述性XML文檔,包含了如下三個要素:orm
URL例子:
參數意義:
這裏對返回的格式(format)有以下選擇:
返回結果:
注意:此請求一樣支持XML格式請求,以下:
URL例子:
參數意義:
這裏對返回的文本格式(info_format)有以下選擇:
返回結果(忽略中文亂碼):
URL例子:
http://localhost:8680/geoserver/wfs?service=wfs&version=1.1.0&request=GetCapabilities。
參數意義:
返回結果:
返回的結果爲描述性XML,包含如下五個主要部分:
URL例子:
參數意義:
返回結果:
這裏首先給出一個例子:
此請求常見的參數有:typeNames,featureID,propertyName,Filter, count, sortBy。其中Filter參數最爲重要,主要負責進行選擇過濾。關於Filter的具體描述可參考:http://docs.geoserver.org/stable/en/user/filter/function.html。
返回結果爲:
{"type":"FeatureCollection","features":[{"type":"Feature","id":"jianfudan.322","geometry":{"type":"MultiPolygon","coordinates":[[[[30.276436000822056,120.20021],[30.275750000822033,120.20021],[30.22768400082126,120.22562],[30.245537000821543,120.17343000000001],[30.276436000822056,120.20021]]]]},"geometry_name":"the_geom","properties":{"limitid":71,"displayorder":null,"regionid":3,"validfromdate":"2016-05-15Z","validtodate":"2016-06-14Z","validflag":1,"media":null,"shape_length":null,"shape_area":null,"graphicid":322,"regionname":"江乾區","eventtypes":null,"otherrequest":null,"limitname":"上報區域71"}},{"type":"Feature","id":"jianfudan.318","geometry":{"type":"MultiPolygon","coordinates":[[[[30.26407600082185,120.19668600000001],[30.26407600082185,120.196434],[30.262875000821833,120.20785],[30.24708200082157,120.203896],[30.255150000821704,120.187164],[30.26407600082185,120.19668600000001]]]]},"geometry_name":"the_geom","properties":{"limitid":72,"displayorder":null,"regionid":3,"validfromdate":"2016-05-04Z","validtodate":"2016-06-03Z","validflag":1,"media":"http://172.18.6.197:8081/MediaRoot/null/20160505/72/84989ee1-9bab-4640-8f24-4a7381f1c4e8/機票預訂.png","shape_length":null,"shape_area":null,"graphicid":318,"regionname":"江乾區","eventtypes":"亂搭亂建,暴露垃圾,積存垃圾渣土,路面不潔,河道不潔(含溝渠、湖面)","otherrequest":"測試","limitname":"上報區域72"}}],"crs":{"type":"EPSG","properties":{"code":"4490"}}}
<Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
<Intersects>
<PropertyName>the_geom</PropertyName>
<gml:Envelope srsName="EPSG:4326">
<gml:lowerCorner>120.15336460382575 30.2743621901609</gml:lowerCorner>
<gml:upperCorner>120.167097513982 30.28809510031715</gml:upperCorner>
</gml:Envelope>
</Intersects>
</Filter>
<Filter xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
<Intersects>
<PropertyName>the_geom</PropertyName>
<gml:MultiPolygon srsName="EPSG:4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts="">
120.15677,30.2557 120.15677,30.26351 120.16833,30.26351 120.16833,30.2557 120.15677,30.2557
</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</Intersects>
</Filter>
由於GET請求的數據量大小在4kb之內,因此Post爲更經常使用的方法。如下爲一個具體的例子:
其中直接發送的爲一個XML文件,其Filter中能夠填寫的內容和GET中的Filter同樣。
具體內容以下:
<?xml version='1.0' encoding='GBK'?><wfs:GetFeature service='WFS' version='1.0.0' outputFormat='JSON'
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.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd'>
<wfs:Query typeName='cell'>
<wfs:PropertyName>the_geom</wfs:PropertyName>
<wfs:PropertyName>test1</wfs:PropertyName>
<ogc:Filter>
<Or>
<PropertyIsEqualTo><PropertyName>test1</PropertyName><Literal>valuetest1</Literal></PropertyIsEqualTo>
<PropertyIsEqualTo><PropertyName>test2</PropertyName><Literal>valuetest2</Literal></PropertyIsEqualTo>
</Or>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
該方法支持對要素的增刪改。這裏直接給出Post請求中發送的XML組織格式:
<wfs:Transaction service="WFS" version="1.0.0"
outputFormat="GML2"
xmlns:opengis="http://www.cetusOpengis.com"
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.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
<wfs:Insert handle="someprj1">
<opengis:someprj>
<opengis:the_geom>
<gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#3395" >
<gml:coordinates decimal="." cs="," ts="">13404701.212,3850391.781</gml:coordinates>
</gml:Point>
</opengis:the_geom>
<opengis:ssds>13</opengis:ssds>
<opengis:qqybh>12</opengis:qqybh>
<opengis:status>0</opengis:status>
</opengis:someprj>
</wfs:Insert>
</wfs:Transaction>
<wfs:Transaction service="WFS" version="1.0.0"
outputFormat="GML2"
xmlns:opengis="http://www.cetusOpengis.com"
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.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
<wfs:Update typeName="opengis:qqyproject">
<wfs:Property>
<wfs:Name>qqybh</wfs:Name>
<wfs:Value>12</wfs:Value>
</wfs:Property>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>qqybh</ogc:PropertyName>
<ogc:Literal>0</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
</wfs:Update>
</wfs:Transaction>
<wfs:Transaction service="WFS" version="1.0.0"
outputFormat="GML2"
xmlns:opengis="http://www.cetusOpengis.com"
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.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
<wfs:Delete typeName="opengis:qqyproject">
<ogc:Filter>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>qqybh</ogc:PropertyName>
<ogc:Literal>12</ogc:Literal>
</ogc:PropertyIsLessThan>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>qqybh</ogc:PropertyName>
<ogc:Literal>0</ogc:Literal>
</ogc:PropertyIsGreaterThan>
</ogc:Filter>
</wfs:Delete>
</wfs:Transaction>
a.動態出圖可使用WMS中的GetMap請求。
b.矢量查詢可使用WFS中的GetFeature請求。
c.要素編輯可使用WFS中的Transaction請求。
-----歡迎轉載,但保留版權,請於明顯處標明出處:http://www.cnblogs.com/naaoveGIS/
若是您以爲本文確實幫助了您,能夠微信掃一掃,進行小額的打賞和鼓勵,謝謝 ^_^