0

I am trying to create a filter to show only specific features based on an attribute query within a WFS using QGIS. This works fine when using the standard WFS loader and creating a filter (based on the type "attribute"='value'). However this only works when the features are cached.

I want to be able to use a filter like this for an uncached WFS layer. Does anyone have any idea how to do this?

Example using a BGS public WFS.

A standard cached query would look like this:

http://ogc.bgs.ac.uk/cgi-bin/BGS_Bedrock_and_Superficial_Geology/wms?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=GBR_BGS_625k_SLS&SRSNAME=CRS:84&FILTER=<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
 <ogc:PropertyIsEqualTo>
  <ogc:PropertyName>LEX_ROCK_D</ogc:PropertyName>
  <ogc:Literal>PEAT</ogc:Literal>
 </ogc:PropertyIsEqualTo>
</ogc:Filter>

When I untick the cached option, the layer source is as follows:

http://ogc.bgs.ac.uk/cgi-bin/BGS_Bedrock_and_Superficial_Geology/wms?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=GBR_BGS_625k_SLS&SRSNAME=CRS:84&BBOX=-3.4085901736001083,57.05755199511002473,-2.94851240830698069,57.42328922738386154&FILTER=<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
 <ogc:PropertyIsEqualTo>
  <ogc:PropertyName>LEX_ROCK_D</ogc:PropertyName>
  <ogc:Literal>PEAT</ogc:Literal>
 </ogc:PropertyIsEqualTo>
</ogc:Filter>

The main difference is the bounding box. What happens with the second layer definition is that the layer loads but has no features within it.

I am able to create a GeoServer layer within my WFS that meets this query, but I am trying to find a way that users will be able to replicate without intervention at the GeoServer end.

1
  • Could it be because of SRSNAME=CRS:84? Because it is WFS 1.0.0 you can have a try with EPSG:4326 because WFS 1.0.0 was unaware about flipping axis. Or you could drop the whole SRSNAME because WFS 1.0.0 does not support it officially.
    – user30184
    Commented Nov 17, 2014 at 15:53

1 Answer 1

1

The problem is that the WFS provider of QGIS appends BBOX element to the main URL for unchached features request and if a filter exists it produces:

msWFSGetFeature(): WFS server error. BBOX parameter and FILTER parameter are mutually exclusive in GetFeature.

So to solve the problem the BBOX element should be included in the FILTER element to get a request like:

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
 <ogc:PropertyIsEqualTo>
  <ogc:PropertyName>batimetria</ogc:PropertyName>
  <ogc:Literal>200</ogc:Literal>
 </ogc:PropertyIsEqualTo>
 <gml:Box>
  <gml:coordinates>0.49585,34.1375 23.50415,49.3625</gml:coordinates>
 </gml:Box>
</ogc:Filter>

In current version it is not possible, you could file a ticket in the bug tracker

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.