FILTER 示例

发送反馈


示例

本示例中对 WFS 服务 data-world/wfs200进行了3次 GetFeature 操作,可对 http://localhost:8090/iserver/services/data-world/wfs200 执行 POST 请求。

  1. BBOX

执行 POST 请求,在 World:Capitals 获取BBOX=50,40,100,60范围内的 Feature,请求体为:

<?xml version="1.0" ?>

<GetFeature

   version="2.0.0"

   service="WFS"

   xmlns="http://www.opengis.net/wfs/2.0"

   xmlns:fes="http://www.opengis.net/fes/2.0"

   xmlns:gml="http://www.opengis.net/gml/3.2"

   xmlns:World="http://www.someserver.example.com/World"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd

                       http://www.opengis.net/gml/3.2

                       http://schemas.opengis.net/gml/3.2.1/gml.xsd">

   <Query typeNames="World:Capitals">

      <PropertyName>World:SMID</PropertyName>

      <fes:Filter>

         <fes:BBOX>

            <fes:ValueReference>World:Capitals</fes:ValueReference>

               <gml:Envelope>

                  <gml:lowerCorner>50 40</gml:lowerCorner>

                  <gml:upperCorner>100 60</gml:upperCorner>

               </gml:Envelope>

         </fes:BBOX>

      </fes:Filter>

   </Query>

</GetFeature>

      响应结果如下:

        

 

  1. Disjoint

执行 POST 请求,在 World:Capitals 获取与指定几何对象相离的 Feature,请求体为:

<?xml version="1.0" ?>

<GetFeature

   version="2.0.0"

   service="WFS"

   xmlns="http://www.opengis.net/wfs/2.0"

   xmlns:fes="http://www.opengis.net/fes/2.0"

   xmlns:gml="http://www.opengis.net/gml/3.2"

   xmlns:World="http://www.someserver.example.com/World"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd

                       http://www.opengis.net/gml/3.2

                       http://schemas.opengis.net/gml/3.2.1/gml.xsd">

   <Query typeNames="World:Ocean">

      <PropertyName>World:SMID</PropertyName>

      <PropertyName>World:SMUSERID</PropertyName>

      <fes:Filter>

         <fes:Disjoint>

               <fes:ValueReference>the_geom</fes:ValueReference>

               <gml:Envelope srsName="urn:ogc;def:crs:EPSG::4326">

                  <gml:lowerCorner>-100 -90</gml:lowerCorner>

                  <gml:upperCorner>100 90</gml:upperCorner>

               </gml:Envelope>

            </fes:Disjoint>

      </fes:Filter>

   </Query>

</GetFeature>

响应结果如下:

        

  1. AndLessThan

执行 POST 请求,在 World:Capitals 获取 SMID 小于500,且CAP_POP小于等于10000的 Feature,请求体为:

<?xml version="1.0"?>

<GetFeature

   service="WFS"

   version="2.0.0"

   xmlns="http://www.opengis.net/wfs/2.0"

   xmlns:World="http://www.someserver.example.com/World"

   xmlns:fes="http://www.opengis.net/fes/2.0"

   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd">

   <Query typeNames="World:Capitals">

      <fes:Filter>

         <fes:And>

            <fes:PropertyIsLessThan>

               <fes:ValueReference>/World:Capitals/World:SMUSERID</fes:ValueReference>

               <fes:Literal>500</fes:Literal>

            </fes:PropertyIsLessThan>

            <fes:PropertyIsLessThanOrEqualTo>

               <fes:ValueReference>/World:Capitals/World:CAP_POP</fes:ValueReference>

               <fes:Literal>10000</fes:Literal>

            </fes:PropertyIsLessThanOrEqualTo>

         </fes:And>

      </fes:Filter>

   </Query>

</GetFeature>

响应结果如下: