GeoServer通過WFS服務(wù)獲取Feature
根據(jù)官方文檔總結(jié)出如何獲取feature。
執(zhí)行獲取feature請求時壶谒,需要指定namespace:featuretype
.
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype
namespace:featuretype
在我們的geoserver主頁的layer perview中甚淡。如下圖所示
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0
根據(jù)id獲取feature
設(shè)置featureID
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype&
featureID=feature
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0&featureID=0.134
查詢指定數(shù)量feature
設(shè)置count
WFS2.0.0支持
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype&
count=N
WFS2.0.0以下支持
http://example.com/geoserver/wfs?
service=wfs&
version=1.1.0&
request=GetFeature&
typeName=namespace:featuretype&
maxFeatures=N
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0&count=3
按某屬性順序查詢
使用該字段sortBy=attribute
诫给。attribute
可以換成要素中的屬性嫂丙。
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype&
count=N&
sortBy=attribute
該例子使用sortBy=NAME_2
查詢
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0&count=3&sortBy=NAME_2
按某屬性排序(升序或降序)查詢
在sortBy=attribute+D
加一個參數(shù)
-
sortBy=attribute+A
升序 -
sortBy=attribute+D
降序
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype&
count=N&
sortBy=attribute+D
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0&count=3&sortBy=NL_NAME_1+D
獲取某個屬性
可以使用propertyName=attribute
指定單獨或者幾個屬性,只顯示該屬性內(nèi)容
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype&
propertyName=attribute
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0&propertyName=NL_NAME_1
只顯示指定要素的指定屬性
同時指定這兩個值featureID
和 propertyName
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype&
featureID=feature&
propertyName=attribute
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0&featureID=0.134&propertyName=NL_NAME_1
查詢多個屬性
在propertyName
使用,
分隔
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype&
featureID=feature&
propertyName=attribute1,attribute2
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0&featureID=0.134&propertyName=NL_NAME_1,NL_NAME_2
查詢指定區(qū)域內(nèi)所有的feature
上面的GetFeature
操作是利用非空間參數(shù)進行查詢惶翻。接下來是根據(jù)feature的幾何性質(zhì)進行查詢杨箭。比如空間位置∫依欤可以通過BBOX查詢指定區(qū)域內(nèi)的要素级历。
這里介紹一個概念 bounding box (BBOX) 。指定的一個區(qū)域
BBOX的參數(shù)
BBOX的參數(shù)是bbox=a1,b1,a2,b2,[crs]
,a1, b1, a2, b2
表示的是坐標(biāo)值(經(jīng)過測試叭披,ab分別代表緯度精度且必須滿足 a2>a1, b2>b1)寥殖, crs
代表的是坐標(biāo)參考系統(tǒng)(Coordinate Reference System)
http://example.com/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetFeature&
typeNames=namespace:featuretype&
srsName=CRS
bbox=a1,b1,a2,b2
示例
http://localhost:8080/geoserver/cesium/wms?service=wfs&version=2.0.0&request=GetFeature&typeNames=cesium:0&bbox=29.81506157,115.70956848,29.82217026,115.71960449
Transaction(重點,以后講解)
該功能支持對feauter進行增刪改查操作,具體操作可以看官方參考涩蜘,或者GeoServer通過WFS對feature實現(xiàn)增刪改查