我的github

WFS,即Web要素服务,支持对地理要素的插入,更新,删除,检索和发现服务。不同于WMS(Web地图服务)的是,该服务专注于要素的地理信息,而忽略其渲染信息,简化了返回信息。

一个图层的WFS服务查看方法是在Layer Preview页面,选择WFS下的GeoJSON(以JSON数据形式展现要素信息,方便解析),查看该图层的要素信息。

http://localhost:5566/geoserver/topp/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=topp%3Astates&maxFeatures=50&outputFormat=application%2Fjson

 这个请求,查询的是此图层的全量数据(返回要素数量受maxFeatures参数限制),我们可以添加过滤条件,得到我们想要的数据(非常强大的功能,可以实现非常多的地理查询操作),下面我就以几个空间查询的例子来举例说明一下。

1、划分区域,查询区域内的点

http://localhost:5566/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>

空间关系:(postgis要把the_geom改为geom)

参数说明

        A:此次采取的几何方式是Intersects,即采用面与点相交,得到这个面里面的点数据

        B:多边形经纬度为一个数组,第一个点经纬度要与最后一个点一致,保证多边形的闭合

        C:过滤条件里有一个PropertyName属性,为必须字段,根据图层的属性来查看,具体查看方式为点击图层,然后点及要查询的图层名称,要素类型的第一个属性,即为该字段的值,过程如下图所示

这个操作是直接前端实现,还是由后端转发?

 2、  传入点坐标,查询该点所在的区域信息 

http://localhost:5566/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,即采用点与面相交,得到包含这个点的面数据

3、  查看被线穿过的区域

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>

 

 

参考:https://my.oschina.net/u/588631/blog/884481

例子:https://geoserver.hydroshare.org/geoserver/HS-2ecc916894fe4fde8fb33c63dedb7ac5/wfs?request=GetCapabilities

参数解析:https://www.cnblogs.com/qxiniu/archive/2010/11/09/1872813.html

http://39.106.90.21/newdataset.html

>>Geoserver数据存储和图层的区别和关系:

数据存储和工作区差不多一个意思。。是一个目录。。而图层是目录下面的一个个shp文件。。

设置图层样式 修改图层样式。。重新发布

>>GeoServer通过WFS服务获取Feature:https://www.jianshu.com/p/3160dc274d07

>>GeoServer对feature实现增删改查:https://www.jianshu.com/p/27420699c1e5

>>GeoServer和REST服务:https://www.jianshu.com/p/954ea8fa7279(使用REST接口玩转GeoServer)

>>GeoserverManager:使用java发布shp数据:https://www.jianshu.com/p/cfd48aab9e12

posted on 2022-01-12 10:37  XiaoNiuFeiTian  阅读(1497)  评论(0编辑  收藏  举报