1

I need help with WFS filtering for GML. I want to filter only by one property (name of administrative unit) - that is all.

Lets say I would like to get the second member of this GML: http://services.cuzk.cz/wfs/inspire-au-wfs.asp?service=wfs&version=2.0.0&request=GetFeature&typeNames=au:AdministrativeUnit&count=2

The name of administrative unit is in this tag: <gn:text>Hlavní město Praha</gn:text> (path: au:name > gn:GeographicalName > gn:spelling > gn:SpellingOfName > gn:text)

Here are some of my tests which do not work:

http://services.cuzk.cz/wfs/inspire-au-wfs.asp?service=wfs&version=2.0.0&request=GetFeature&typeNames=au:AdministrativeUnit&FILTER=<Filter><PropertyIsEqualTo><ValueReference>gn:text</ValueReference><Literal>Hlavní město Praha</Literal></PropertyIsEqualTo></Filter>

When I use ogr2ogr to transform the GML to GeoJSON (the WFS returns only GML) then the name of the administrative unit is in "text" attribute.

http://services.cuzk.cz/wfs/inspire-au-wfs.asp?service=wfs&version=2.0.0&request=GetFeature&typeNames=au:AdministrativeUnit&FILTER=<Filter><PropertyIsEqualTo><PropertyName>text</PropertyName><Literal>Hlavní město Praha</Literal></PropertyIsEqualTo></Filter>

This one returns whole layer instead of the 1 feature/member:

http://services.cuzk.cz/wfs/inspire-au-wfs.asp?service=wfs&version=2.0.0&request=GetFeature&typeNames=au:AdministrativeUnit&CQL_FILTER=text='Hlavní město Praha'

Here is meta for the layer & service:

http://services.cuzk.cz/wfs/inspire-au-wfs.asp?service=wfs&version=2.0.0&request=DescribeFeatureType&typeNames=au:AdministrativeUnit

http://services.cuzk.cz/wfs/inspire-au-wfs.asp?service=wfs&version=2.0.0&request=GetCapabilities

Any idea how to filter the nested tags in GML?

0

In WFS 2.0 you can use a limited set of XPath to specify your property in the feature so in your case a query like this should work:

<?xml version="1.0"?>
<wfs:GetFeature xmlns:wfs="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:sf="http://www.openplans.org/spearfish" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="2.0.0" 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">
  <wfs:Query typeNames="au:AdministrativeUnit">
    <fes:Filter>
      <PropertyIsEqualTo>
        <ValueReference>name/GeographicalName/spelling/SpellingOfName/text</ValueReference>
        <Literal>Hlavní město Praha</Literal>
      </PropertyIsEqualTo>
    </fes:Filter>
  </wfs:Query>
</wfs:GetFeature>

But this server (despite claiming to support POST in the getCapabilities) doesn't seem to like POSTed queries so you need to URL encode the Filter which should give you a URL like:

"http://services.cuzk.cz/wfs/inspire-au-wfs.asp?service=wfs&version=2.0.0&request=GetFeature&typeNames=au:AdministrativeUnit&FILTER=%3Cfes%3AFilter%3E%0D%0A%20%20%20%20%20%20%3CPropertyIsEqualTo%3E%0D%0A%20%20%20%20%20%20%20%20%3CValueReference%3Ename%2FGeographicalName%2Fspelling%2FSpellingOfName%2Ftext%3C%2FValueReference%3E%0D%0A%20%20%20%20%20%20%20%20%3CLiteral%3EHlavn%C3%AD%20m%C4%9Bsto%20Praha%3C%2FLiteral%3E%0D%0A%20%20%20%20%20%20%3C%2FPropertyIsEqualTo%3E%0D%0A%20%20%20%20%3C%2Ffes%3AFilter%3E%0D%0A" 

But all I can get from that is an OperationProcessingFailed error, so something seems to be up with either my request or the server.

Since it seems to not be a GeoServer you almost certainly can't use CQL_FILTERs anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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