Select to view content in your preferred language

How to construct a WFS-URL that both filters on an attribute and uses a boudingbox filter

14445
1
Jump to solution
02-06-2015 02:00 PM
basboers1
New Contributor

Dear community,

 

In an attempt not to request too many features from a WFS i'd like to apply both a attribute filter and a bounding box/envelope. Although these two types of filters seem to be "mutually exclusive" according to the OGC specification, I was wondering if they could somehow be combined within a single filter through for example the use of the AND-operator. Anyone any advise? I am working on the following WFS: http://geodata.nationaalgeoregister.nl/bag/wfs?request=getcapabilities

 

What I've tried, but doesn't work out is:

 

1:Via the url

 

http://geodata.nationaalgeoregister.nl/bag/wfs?&typename=bag:pand&version=2.0.0&request=getfeature&F... xmlns=&quot;http://www.opengis.net/wfs/2.0 xmlns:gml=http://schemas.opengis.net/gml xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bag=http://bag.geonovum.nl xsi:schemaLocation=http://www.opengis.net/wfs/2.0 &quot;><And><ogc:BBOX><ogc:PropertyName>Shape</ogc:PropertyName><gml:Box srsName=&quot;urn:x-ogc:def:crs:EPSG:28992&quot;><gml:coordinates>508576,107240 510167,109000</gml:coordinates></gml:Box></ogc:BBOX><Within><PropertyIsEqualTo><PropertyName>status</PropertyName><Literal>Bouwvergunning verleend</Literal></PropertyIsEqualTo></Within></And></ogc:Filter>

 

2:via use of the xml-filter expression

 

<ogc:Filter>

  <ogc:And>

    <ogc:PropertyIsEqualTo>

      <ogc:PropertyName>status</ogc:PropertyName>

      <ogc:Literal>Bouwvergunning verleend</ogc:Literal>

    </ogc:PropertyIsEqualTo>

    <gml:boundedBy>

      <gml:Envelope srsDimension="2" srsName="urn:ogc:def:crs:EPSG::28992">

        <gml:lowerCorner>107240 508576</gml:lowerCorner>

        <gml:upperCorner>109000 510167</gml:upperCorner>

      </gml:Envelope>

    </gml:boundedBy>

    </ogc:And>

</ogc:Filter>

 

source used: http://gdsc.nlr.nl/gdsc/en/software/excat/manual/ogcfilter_examples

 

Any advice is much appreciated!

 

Cheers!

0 Kudos
1 Solution

Accepted Solutions
basboers1
New Contributor

Together with my colleague Gert-Jan van Weijden I found a solution for combining a spatial filter and an attribute filter in a WFS-request. As expected this only works when integrating both query-expressions within the filter-statement, as these criteria rule eachother out otherwise:

After extensive experimenting with formulating ogc-compliant requests, Gert-Jan pointed out the option of using a much more straightforward CQL-filter, which is an extension on Geoserver.

Using the cql-approach worked fine when combining a bounding box with an attribute filter for: http://geodata.nationaalgeoregister.nl/bestuurlijkegrenzen/wfs?

The full successful request (which as intended renders only the municipality of Almere and not Breda, because only Almere lies within de defined bounding box):

http://geodata.nationaalgeoregister.nl/bestuurlijkegrenzen/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=Get...

However using the same formula for the BAG-WFS, wasn’t directly successful. As it turned out “geom.”  - from the URL above - refers to the property name of the geometry-field (and should do so). Since the geometry-field of the BAG-WFS is “geometrie” , “geom” should be replaced here for “geometrie”. Having made this substitution renders the following successful request for the BAG-WFS.

http://geodata.nationaalgeoregister.nl/bag/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=2.0.0&TYPENAME...,107240,507000,109000,509000,%27EPSG:28992%27)and(status=%27Bouwvergunning verleend%27))

View solution in original post

0 Kudos
1 Reply
basboers1
New Contributor

Together with my colleague Gert-Jan van Weijden I found a solution for combining a spatial filter and an attribute filter in a WFS-request. As expected this only works when integrating both query-expressions within the filter-statement, as these criteria rule eachother out otherwise:

After extensive experimenting with formulating ogc-compliant requests, Gert-Jan pointed out the option of using a much more straightforward CQL-filter, which is an extension on Geoserver.

Using the cql-approach worked fine when combining a bounding box with an attribute filter for: http://geodata.nationaalgeoregister.nl/bestuurlijkegrenzen/wfs?

The full successful request (which as intended renders only the municipality of Almere and not Breda, because only Almere lies within de defined bounding box):

http://geodata.nationaalgeoregister.nl/bestuurlijkegrenzen/wfs?SERVICE=WFS&VERSION=2.0.0&REQUEST=Get...

However using the same formula for the BAG-WFS, wasn’t directly successful. As it turned out “geom.”  - from the URL above - refers to the property name of the geometry-field (and should do so). Since the geometry-field of the BAG-WFS is “geometrie” , “geom” should be replaced here for “geometrie”. Having made this substitution renders the following successful request for the BAG-WFS.

http://geodata.nationaalgeoregister.nl/bag/wfs?REQUEST=GetFeature&SERVICE=WFS&VERSION=2.0.0&TYPENAME...,107240,507000,109000,509000,%27EPSG:28992%27)and(status=%27Bouwvergunning verleend%27))

0 Kudos