How To: CQL_FILTER in WMS (same as in cache)?

Hi All,

The enforcement/validation of a CQL_FILTER in WMTS requests as well as being able to set a default is excellent. We use it alot…

However, I can’t see any comparable configuration options in WMS.

Is is possible to:
a) Validate a CQL_FILTER parameter on all WMS requests
b) If no CQL_FILTER is supplied in the WMS request, configure a default.

The reason I ask is that I am trying to prevent SQL query execution that would put an extreme load on the database.

Thanks in advanve,
Andrew

Welcome @ahhughes thanks for joining us here.

I had to look up the CQL_FILTER in WMTS to learn what you are talking about, and I am still not sure what you mean by validate a CQL_FILTER.

WMS supports both:

  • FILTER the official OGC parameter using CQL which does “property operation expression” filters
  • CQL_FILTER - our extension ECQL which allows for “expression operation expression” filters

I expect you mean WMS vendor parameter ENV.

&env=distance:10

This allows defaults and is intend to be used to adjust the style easily.

<ogc:Function name="env">
   <ogc:Literal>distance</ogc:Literal>
   <ogc:Literal>6</ogc:Literal>
</ogc:Function>

All of these things change the style a lot, so configuration is needed in WMTS in order to allow it to create a separate tile cache for different values of distance above.

That can be used to record a tileset for different values of the CQL_FILTER parameter; however there is nothing special going on, it is only if the value matches a tile will be recorded. Any CQL_FILTER can be provided to WMS.

To better restrict WMS use env function above, or if you really like use env to supply a value with a default, and then recode to choose a longer expression based on the value provided.

Hi Andrew,
parameter filters are a GWC native functionality designed to avoid the explosion of parallel caches for a give cached layer. If that wasn’t there (of if you set up CQL_FILTER matching to be “.*”) then potentially infinite tile caches may exist for a given layer.

As said above, the functionality is native to GWC and it’s exposed in GeoServer for configuration purposes only. No equivalent exists for WMS.

I guess something like that would make for an interesting new community module, allowing to match and limit KVP parameters. What would make it tricky though, is that one can make also POST requests for most protocols, with a variety of XML encodings depending on the version.

You might be wondering… does WMS support XML post too? Yes, it does.
Thankfully it does not seem to support a variety of vendor parameters, including CQL_FILTER. It would also mean you cannot set a default for it, thought.

Cheers
Andrea

Hi Andrea,

Fantastic explanation thank you.

We use the CQL_FILTER heavily for this exact reason you’ve just explained.

The regex matcher also acts as a validator and enforces it as a mandatory URL parameter when a client is requesting tiles.

This also means if the following…

SELECT * FROM my_huge_dataset

…was an abusive query in the database. We could enforce a CQL_FILTER so that it only ever executed queries with a limiting WHERE clause like…

SELECT * FROM my_huge_dataset WHERE category=‘brewery’

But (possibly due to my lack of knowledge) I can’t seem to achieve this in WMS and prevent SELECT * FROM my_huge_dataset from being executed.

I have much to learn but any advice would be appreciated.

Many thanks,
Andrew

On Sat, 26 Oct 2024, 1:27 am Andrea Aime via OSGeo Discourse, <noreply@discourse.osgeo.org> wrote:

aaime-geosolutions
October 25

Hi Andrew,
parameter filters are a GWC native functionality designed to avoid the explosion of parallel caches for a give cached layer. If that wasn’t there (of if you set up CQL_FILTER matching to be “.*”) then potentially infinite tile caches may exist for a given layer.

As said above, the functionality is native to GWC and it’s exposed in GeoServer for configuration purposes only. No equivalent exists for WMS.

I guess something like that would make for an interesting new community module, allowing to match and limit KVP parameters. What would make it tricky though, is that one can make also POST requests for most protocols, with a variety of XML encodings depending on the version.

You might be wondering… does WMS support XML post too? Yes, it does.
Thankfully it does not seem to support a variety of vendor parameters, including CQL_FILTER. It would also mean you cannot set a default for it, thought.

Cheers
Andrea


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

Hi Jody,

Thanks for an excellent reply.

I’ll go have a look at the ENV parameter and try and get it to provide a default if none is supplied.

I take it that configuring…

<ogc:Function name=“env”> ogc:Literaldistance</ogc:Literal> ogc:Literal6</ogc:Literal> </ogc:Function>

into the layer style will mean that a WHERE clause such as…

SELECT … WHERE distance = 6 ;

is always going to be present in the query (unless) &env=distance:10 is supplied in the request then…

SELECT … WHERE distance = 10 ;

…will be executed. If so that is great.

But I don’t understand if/how it would work alongside the CQL_FILTER && WMTS… sorry, I think this is my lack of knowledge.

Huge thanks!
Andrew

On Wed, 23 Oct 2024 at 20:29, Jody Garnett via OSGeo Discourse <noreply@discourse.osgeo.org> wrote:

jive Leader
October 23

Welcome @ahhughes thanks for joining us here.

I had to look up the CQL_FILTER in WMTS to learn what you are talking about, and I am still not sure what you mean by validate a CQL_FILTER.

WMS supports both:

  • FILTER the official OGC parameter using CQL which does “property operation expression” filters
  • CQL_FILTER - our extension ECQL which allows for “expression operation expression” filters

I expect you mean WMS vendor parameter ENV.

&env=distance:10

This allows defaults and is intend to be used to adjust the style easily.

<ogc:Function name="env">
   <ogc:Literal>distance</ogc:Literal>
   <ogc:Literal>6</ogc:Literal>
</ogc:Function>

All of these things change the style a lot, so configuration is needed in WMTS in order to allow it to create a separate tile cache for different values of distance above.

That can be used to record a tileset for different values of the CQL_FILTER parameter; however there is nothing special going on, it is only if the value matches a tile will be recorded. Any CQL_FILTER can be provided to WMS.

To better restrict WMS use env function above, or if you really like use env to supply a value with a default, and then recode to choose a longer expression based on the value provided.


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.