1

I have a URL that I am passing into an API call to bring back a static image of a map. This URL currently works:

http://computername:8080/geoserver/Packt/wms?service=WMS&version=1.1.0&request=GetMap&layers=Packt:countries&styles=&bbox=-181.800003051758,-90.8669281005859,181.800003051758,84.4676055908203&width=768&height=370&srs=EPSG:4326&CQL_FILTER=continent%20%3D%20%27North+America%27&format=application/openlayers#

In the book I am reading it says the layers parameter can 'insert a comma-separated list of layers' but when I try to add another layer like so:

http://computername:8080/geoserver/Packt/wms?service=WMS&version=1.1.0&request=GetMap&layers=Packt:countries,Packt:ne_10m_railroads&styles=&bbox=-181.800003051758,-90.8669281005859,181.800003051758,84.4676055908203&width=768&height=370&srs=EPSG:4326&CQL_FILTER=continent%20%3D%20%27North+America%27&format=application/openlayers#

the browser does not accept it. My end goal is to call two layers and filter one of the layers with the CQL syntax.

I am running GeoServer 2.11.0 on Apache Tomcat 8.5 on Windows Server 2012.

1

See the answer and example at Applying multiple CQL_FILTER to single GeoServer LayerGroup?.

It seems that if you use CQL_FILTER with a list of layers you must also define some filter for each layer. Thus this does not work

http://localhost:8080/geoserver/wms?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&WIDTH=459&HEIGHT=346&LAYERS=topp:states,tiger:poi&TRANSPARENT=TRUE&FORMAT=image/png&BBOX=-74.01531543884973,40.7072072479969,-73.99804660283719,40.720224714795016&SRS=EPSG:4326&STYLES=&CQL_FILTER=STATE_NAME='New York'

Adding an empty second filter CQL_FILTER=STATE_NAME='New York'; does not seem to work. However, if you add a bogus second filter CQL_FILTER=STATE_NAME='New York';1=2 then the request does work

http://localhost:8080/geoserver/wms?REQUEST=GetMap&SERVICE=WMS&VERSION=1.1.1&WIDTH=459&HEIGHT=346&LAYERS=topp:states,tiger:poi&TRANSPARENT=TRUE&FORMAT=image/png&BBOX=-74.01531543884973,40.7072072479969,-73.99804660283719,40.720224714795016&SRS=EPSG:4326&STYLES=&CQL_FILTER=STATE_NAME='New York';1=2
  • 1
    There are 2 "bonus" filters INCLUDE & EXCLUDE you can use instead of 1=2 – Ian Turton Aug 25 '18 at 9:20
0

My first guess would be that you need to specify, which layer the cql filter belongs to:

See http://docs.geoserver.org/stable/en/user/services/wms/vendor.html#cql-filter

If more than one layer is specified in the layers parameter, then a separate filter can be specified for each layer, separated by semicolons. The syntax is:

cql_filter=filter1;filter2...

So your request would become:

http://computername:8080/geoserver/Packt/wms?service=WMS&version=1.1.0&request=GetMap&layers=Packt:countries,Packt:ne_10m_railroads&styles=&bbox=-181.800003051758,-90.8669281005859,181.800003051758,84.4676055908203&width=768&height=370&srs=EPSG:4326&CQL_FILTER=continent%20%3D%20%27North+America%27;&format=application/openlayers#

I haven't tested it though.

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.