4

I believe GeoServer requires that filters passed in a WFS POST request are in the OGC XML based format.

If you make a GetFeature request to GeoServer using a GET request the filter can be CQL or ECQL and GeoServer will accept it.

Will GeoServer ever be able to accept CQL in a POST filter parameter or provide an endpoint which will convert it on the fly into the XML based filter?

Alternatively, do any of the other web servers handle this better?

Currently our layers are filtered using CQL for the WMS requests so it would be great if the WFS GetFeature requests were using the same filter format.

  • Is this a question about any WFS service or just ones provided by geoserver software? – nmtoken Dec 7 '16 at 9:20
  • Hi, we currently use GeoServer but if there is another option out there which solves this problem we would consider it as we are likely to need to re-deploy our servers soon anyway. So it short, I'm happy to hear about any WFS client providers. – Paul Wittle Dec 12 '16 at 7:56
2

The filter format is defined by the standard so I don't think you will find any WFS that accepts anything but OGC filters in the request.

I wrote a simple program a while ago to convert ECQL to OGC filters for you. So the functionality could be added to GeoServer fairly easily as a vendor extension - see the feature request guidelines for more details of how to do this.

  • Hi, this looks great, how do you deploy it? Do you add it as a plugin to GeoServer or GeoTools? Alternatively are you just deploying it standalone? Would you not submit that code to GeoServer yourself? I'd be happy to vote for it (if I can) but as you developed it surely it should be you offerring it to the community? – Paul Wittle Dec 12 '16 at 8:01
  • On the standards front, I'm aware that it is not in the standard but it seems odd to me to say when it is a GET request you can do an extra GeoServer specific function but when you do a POST it is just the standard. This is a function GeoServer is doing before the WFS standard is applied in the GET request so I don't see the problem in the POST request. That said, I'm developing in MVC at the moment so perhaps Java handles POST requests differently. – Paul Wittle Dec 12 '16 at 8:08
1

To add a definitive answer for the record the simple answer is that WFS does not allow CQL or ECQL as the filter.

It appears that some WFS providers such as GeoServer may permit you to pass a CQL filter in a GET request but GeoServer does not support this for the POST request.

Extensions do exist which may add this functionality by converting to OGC filter but that needs a separate installation.

1

@Paul Wittle , As the matter of fact there is WFS filter that support POST (I am not sure if it fully support CQL and/or ECQL ) but it does have support for some filters. have a look at examples here

https://openlayers.org/en/latest/examples/vector-wfs-getfeature.html?q=wfs+filter

so not only there is support in Geoserver for wfs POST filter, openlayers also have inbuilt functions to make the call easy as you have to create messy xml request for it.

0

You can do a WFS CQL post request on GeoServer service/layer using python like this:

import request
payload = {
    'version': '1.0.0',
    'service': 'wfs',
    'typeName': 'workspace:layerName',
    'request': 'GetFeature',
    'CQL_FILTER': query
    }

    url = "http://myServer.com:8080/geoserver/wfs/workspace"
    data = requests.post(url, payload)

Data returned should be in xml format which you may then parse.

  • Quoting Andrea from link "It may just be an issue with the way the query is made, CQL filters do work only in GET requests." My problem is not with knowing how to create a post request but my understanding is that GeoServer will ignore the CQL_FILTER parameter unless passed in the URL. – Paul Wittle Dec 6 '16 at 16:12

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.