[Geoserver-users] How to apply cql filter just to one layer, when also a baseman is loaded

This question is about loading several layers, and applying a cql filter only to one of these layers.

I have some of my data and want to show it as a heatmap with a basemap of the world.
This works using a layer group : one layer for my data and one for the baseman.
But I want to be able to add a cql filters on several fields, and then regenerate the heatmap on the fly, and still have the basemap too, through changing the url (so different urls, and the values for the filters will change).
WORKS
1)only data in MYLAYER and a cql filter on this
http://myserver:8080/geoserver/cite/wms?service=WMS&version=1.1.0&request=GetMap
&layers=cite%3AMYLAYER
&CQL_FILTER=somefield>290;somefield<400;someotherfield=3
&styles=heatmap
&bbox=-180.0%2C-90.0%2C180.0%2C90.0&width=768&height=384&srs=EPSG%3A4326&format=application/openlayers
--> I can regenerate the url with different values and see the map immediately.

2)only world map
http://myserver:8080/geoserver/cite/wms?service=WMS&version=1.1.0&request=GetMap
&layers=cite%3AWORLDMAP
&bbox=-179.99999999999997%2C-89.99999999998201%2C179.99999999996405%2C90.0&width=768&height=384&srs=EPSG%3A4326&format=application/openlayers

DOES NOT WORK
(Combination of 1+2 and CQL Filter for MYLAYER):
http://myserver:8080/geoserver/cite/wms?service=WMS&version=1.1.0&request=GetMap
&layers=cite%3AMYLAYER,cite%3AWORLDMAP
&CQL_FILTER=somefield>290;somefield<400;someotherfield=3
&styles=heatmap
&bbox=-180.0%2C-90.0%2C180.0%2C90.0&width=768&height=384&srs=EPSG%3A4326&format=application/openlayers

Anyone has an example for this?
I had expected to be able to specify in the CQL filter something like
&CQL_FILTER=MYLAYER.somefield>290
to apply the filter only to one of the layers.

Thanks for input!

You need to have a matching filter for each layer, or the only filter you specify will be applied to all of them.
For a layers list like:

&layers=cite%3AMYLAYER,cite%3AWORLDMAP

you’ll likely want:

&cql_filter=somefield>290;INCLUDE

The “;” separates the filters, now we have one for the first layer, and one for the layer group,
which is really just a placeholder, INCLUDE means “accept everything”

Hope this helps

Best regards
Andrea

···

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

Dear Andrea,
Many thanks for your suggestion!

This works when I load several layers that have regular datapoints (loaded as style = point) ,but I failed to have it work when I also want to load a " base layer of the world”.
( I am using this one https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/raster/NE1_50M_SR_W.zip as described in the article https://medium.com/@dale.bingham_30375/setup-geoserver-for-a-local-gis-application-like-cesiumjs-14322f1178d5 ).
This layer is added as style=raster - I wonder if this style is the problem as you can not apply a CQL filter-not even with INCLUDE on this?

So maybe my question comes down to: are there better suggestions to easily add a base layer of the world (with names of some cities and distinction water/land would be nice), that I will be able to add as a layer on which the INCLUDE will work when applying a CQL filter?
And what style would those be then?

Many thanks for input!

Joris

···

== GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

I believe the CQL filter should still be allowed for a raster layer. In your case INCLUDE is really all that makes sense for it though.

The other question about baselayers, we usually see a group layer that contains multiple layers of different types (like OSM for example). And then you’ll make that a tiled layer and cache it. Then your overlays are rendered as entirely separate layers in the client.

···

Jason Newmoyer
Newmoyer Geospatial Solutions
843.606.0424
jason@anonymised.com