deegree / deegree3

Official deegree repository providing geospatial core libraries, data access and advanced OGC web service implementations
https://www.deegree.org
GNU Lesser General Public License v2.1
146 stars 99 forks source link

how to use filter in wfs getfeature request url ? #235

Closed curious-boy closed 10 years ago

curious-boy commented 10 years ago

i can get feature by featureid and bbox. example: 1 by featureid http://127.0.0.1:8088/services/wfs?service=WFS&request=GetFeature&version=1.1.0&TypeName=topp:hztl&featureid=HZTL_0 2 by bbox http://127.0.0.1:8088/services/wfs?service=WFS&request=GetFeature&version=1.1.0&TypeName=topp:hztl&BBOX=120.200000,30.3,120.080000,30.500000,EPSG:4326 but i can't use other filter (Disjoint Intersects Crosses Within DWithin and so on) correctly. Are they supported by deegree ? Thank you for your time!

curious-boy commented 10 years ago

if they were supported in deegree? Can you give me example url ? Many thanks

MrSnyder commented 10 years ago

Yes, this is supported as defined in the WFS specification (otherwise deegree WFS wouldn't be compliant). The filter can be specified via the FILTER parameter in a KVP GetFeature request.

There are two common caveats:

Example Filter:

<Filter xmlns="http://www.opengis.net/ogc">
  <And>
    <BBOX>
      <PropertyName>app:geometry</PropertyName>
      <Envelope xmlns="http://www.opengis.net/gml">
        <coord>
          <X>432604.0</X>
          <Y>4647889.0</Y>
        </coord>
        <coord>
          <X>5647889.0</X>
          <Y>5647889.0</Y>
        </coord>
      </Envelope>
    </BBOX>
    <Or>
      <PropertyIsEqualTo>
        <PropertyName>OBJECTID</PropertyName>
        <Literal>446</Literal>
      </PropertyIsEqualTo>
      <PropertyIsGreaterThan>
        <PropertyName>SHAPE_LEN</PropertyName>
        <Literal>10000</Literal>
      </PropertyIsGreaterThan>
    </Or>
  </And>
</Filter>

URL-encoded XML:

%3CFilter%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%3E%0A%20%20%3CAnd%3E%0A%20%20%20%20%3CBBOX%3E%0A%20%20%20%20%20%20%3CPropertyName%3Eapp%3Ageometry%3C%2FPropertyName%3E%0A%20%20%20%20%20%20%3CEnvelope%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fgml%22%3E%0A%20%20%20%20%20%20%20%20%3Ccoord%3E%0A%20%20%20%20%20%20%20%20%20%20%3CX%3E432604.0%3C%2FX%3E%0A%20%20%20%20%20%20%20%20%20%20%3CY%3E4647889.0%3C%2FY%3E%0A%20%20%20%20%20%20%20%20%3C%2Fcoord%3E%0A%20%20%20%20%20%20%20%20%3Ccoord%3E%0A%20%20%20%20%20%20%20%20%20%20%3CX%3E5647889.0%3C%2FX%3E%0A%20%20%20%20%20%20%20%20%20%20%3CY%3E5647889.0%3C%2FY%3E%0A%20%20%20%20%20%20%20%20%3C%2Fcoord%3E%0A%20%20%20%20%20%20%3C%2FEnvelope%3E%0A%20%20%20%20%3C%2FBBOX%3E%0A%20%20%20%20%3COr%3E%0A%20%20%20%20%20%20%3CPropertyIsEqualTo%3E%0A%20%20%20%20%20%20%20%20%3CPropertyName%3EOBJECTID%3C%2FPropertyName%3E%0A%20%20%20%20%20%20%20%20%3CLiteral%3E446%3C%2FLiteral%3E%0A%20%20%20%20%20%20%3C%2FPropertyIsEqualTo%3E%0A%20%20%20%20%20%20%3CPropertyIsGreaterThan%3E%0A%20%20%20%20%20%20%20%20%3CPropertyName%3ESHAPE_LEN%3C%2FPropertyName%3E%0A%20%20%20%20%20%20%20%20%3CLiteral%3E10000%3C%2FLiteral%3E%0A%20%20%20%20%20%20%3C%2FPropertyIsGreaterThan%3E%0A%20%20%20%20%3C%2FOr%3E%0A%20%20%3C%2FAnd%3E%0A%3C%2FFilter%3E

Full KVP-request:

http://deegree3-demo.deegree.org/utah-workspace/services?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=SGID100_RailroadsDLG100&FILTER=%3CFilter%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22%3E%0A%20%20%3CAnd%3E%0A%20%20%20%20%3CBBOX%3E%0A%20%20%20%20%20%20%3CPropertyName%3Eapp%3Ageometry%3C%2FPropertyName%3E%0A%20%20%20%20%20%20%3CEnvelope%20xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fgml%22%3E%0A%20%20%20%20%20%20%20%20%3Ccoord%3E%0A%20%20%20%20%20%20%20%20%20%20%3CX%3E432604.0%3C%2FX%3E%0A%20%20%20%20%20%20%20%20%20%20%3CY%3E4647889.0%3C%2FY%3E%0A%20%20%20%20%20%20%20%20%3C%2Fcoord%3E%0A%20%20%20%20%20%20%20%20%3Ccoord%3E%0A%20%20%20%20%20%20%20%20%20%20%3CX%3E5647889.0%3C%2FX%3E%0A%20%20%20%20%20%20%20%20%20%20%3CY%3E5647889.0%3C%2FY%3E%0A%20%20%20%20%20%20%20%20%3C%2Fcoord%3E%0A%20%20%20%20%20%20%3C%2FEnvelope%3E%0A%20%20%20%20%3C%2FBBOX%3E%0A%20%20%20%20%3COr%3E%0A%20%20%20%20%20%20%3CPropertyIsEqualTo%3E%0A%20%20%20%20%20%20%20%20%3CPropertyName%3EOBJECTID%3C%2FPropertyName%3E%0A%20%20%20%20%20%20%20%20%3CLiteral%3E446%3C%2FLiteral%3E%0A%20%20%20%20%20%20%3C%2FPropertyIsEqualTo%3E%0A%20%20%20%20%20%20%3CPropertyIsGreaterThan%3E%0A%20%20%20%20%20%20%20%20%3CPropertyName%3ESHAPE_LEN%3C%2FPropertyName%3E%0A%20%20%20%20%20%20%20%20%3CLiteral%3E10000%3C%2FLiteral%3E%0A%20%20%20%20%20%20%3C%2FPropertyIsGreaterThan%3E%0A%20%20%20%20%3C%2FOr%3E%0A%20%20%3C%2FAnd%3E%0A%3C%2FFilter%3E

[1] http://meyerweb.com/eric/tools/dencoder/