GeoServer的WFS服務詳細介紹——空間關係查詢

       WFS,即Web要素服務,支持對地理要素的插入,更新,刪除,檢索和發現服務。不一樣於WMS(Web地圖服務)的是,該服務專一於要素的地理信息,而忽略其渲染信息,簡化了返回信息。html

       一個圖層的WFS服務查看方法是在Layer Preview頁面,選擇WFS下的GeoJSON(以JSON數據形式展示要素信息,方便解析),查看該圖層的要素信息。json

       

      解析的參數爲:數組

http://localhost:28080/geoserver/topp/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=topp:states&maxFeatures=50&outputFormat=application%2Fjsonapp

       其中各個參數意義能夠參照此篇文章:http://www.cnblogs.com/naaoveGIS/p/5508882.htmlless

       這個請求,查詢的是此圖層的全量數據(返回要素數量受maxFeatures參數限制),咱們能夠添加過濾條件,獲得咱們想要的數據(很是強大的功能,能夠實現很是多的地理查詢操做),下面我就以幾個空間查詢的例子來舉例說明一下。ide

       一、劃分區域,查詢區域內的點idea

        

http://localhost:28080/geoserver/sf/ows?service=WFS&version=1.0.0
&request=GetFeature
&typeName=sf:bugsites
&maxFeatures=50
&outputFormat=application%2Fjson
&filter=  
<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">  
    <Intersects>
	<PropertyName>the_geom</PropertyName>
	<gml:Polygon>  
        <gml:outerBoundaryIs> 
	<gml:LinearRing>   
          <gml:coordinates>604264,4919992 604340,4913350 611059,4915487 604264,4919992</gml:coordinates> 
    </gml:LinearRing> 
        </gml:outerBoundaryIs> 
 </gml:Polygon>		
    </Intersects>
</Filter>

          空間關係spa

          

        參數說明.net

        A:這次採起的幾何方式是Intersects,即採用面與點相交,獲得這個面裏面的點數據code

        B:多邊形經緯度爲一個數組,第一個點經緯度要與最後一個點一致,保證多邊形的閉合

       C:過濾條件裏有一個PropertyName屬性,爲必須字段,根據圖層的屬性來查看,具體查看方式爲點擊圖層,而後點及要查詢的圖層名稱,要素類型的第一個屬性,即爲該字段的值,過程以下圖所示

       

         

         查詢結果

         

          二、  傳入點座標,查詢該點所在的區域信息 

http://localhost:28080/geoserver/topp/ows?service=WFS&version=1.0.0
&request=GetFeature&typeName=topp:tasmania_water_bodies&maxFeatures=50
&outputFormat=application%2Fjson
&filter=<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">  
    <Intersects>
	<PropertyName>the_geom</PropertyName>
	<gml:Point>   
          <gml:coordinates>146.200,-42.700</gml:coordinates> 
    </gml:Point> 	
    </Intersects>
</Filter>

       

         空間關係

      查詢說明:

      A:這次採起的幾何方式是Intersects,即採用點與面相交,獲得包含這個點的面數據

      查詢結果:

     

      三、  查看被線穿過的區域

      

http://localhost:28080/geoserver/topp/ows?service=WFS&version=1.0.0
&request=GetFeature&typeName=topp:tasmania_water_bodies&maxFeatures=50
&outputFormat=application%2Fjson
&filter=
    <Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">  
        <Crosses>  
            <PropertyName>the_geom</PropertyName>  
            <gml:LineString>  
        <gml:coordinates>146.62903,-41.85171 147.27448,-42.18130</gml:coordinates>  
            </gml:LineString>  
        </Crosses>  
</Filter>

         空間關係

                 

         查詢結果

            

         

下面是全部的空間關係介紹

Name

Arguments

Description

contains

a:Geometry, b:Geometry

Returns true if the geometry a contains b

crosses

a:Geometry, b:Geometry

Returns true if a crosses b

disjoint

a:Geometry, b:Geometry

Returns true if the two geometries are disjoint, false otherwise

equalsExact

a:Geometry, b:Geometry

Returns true if the two geometries are exactly equal, same coordinates in the same order

equalsExactTolerance

a:Geometry, b:Geometry, tol:Double

Returns true if the two geometries are exactly equal, same coordinates in the same order, allowing for a tol distance in the corresponding points

intersects

a:Geometry, b:Geometry

Returns true if a intersects b

isWithinDistance

a: Geometry, b:Geometry, distance: Double

Returns true if the distance between a and b is less than distance (measured as an euclidean distance)

overlaps

a: Geometry, b:Geometry

Returns true a overlaps with b

relate

a: Geometry, b:Geometry

Returns the DE-9IM intersection matrix for a and b

relatePattern

a: Geometry, b:Geometry, pattern:String

Returns true if the DE-9IM intersection matrix for aand b matches the specified pattern

touches

a: Geometry, b: Geometry

Returns true if a touches b according to the SQL simple feature specification rules

within

a: Geometry, b:Geometry

Returns true is fully contained inside b

相關文章
相關標籤/搜索