I've created a page with OpenLayers 3 that adds a WMS Tile layer to the map served up by a local GeoServer (v2.6) instance. As it stands adding layer by layer things work just fine:
var dynamicMap = new ol.Map({
target: 'myMap',
layers: [
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
params: {
'LAYERS': 'ne:NE1_HR_LC_SR_W_DR'
}
})
}),
new ol.layer.Tile({
source: new ol.source.TileWMS(({
url: 'http://localgeoserver:8080/geoserver/wms',
params: {'CQL_FILTER':"[(USAGE IN ('H','B')]", 'TILED': true, 'layers':'WORKSPACENAME:LAYER1','WIDTH':'256','HEIGHT':'256' },
serverType: 'geoserver'
}))
}),
new ol.layer.Tile({
source: new ol.source.TileWMS(({
url: 'http://localgeoserver:8080/geoserver/wms',
params: {'CQL_FILTER':"[SYMBOL IN ('A','B','C')]", 'TILED': true, 'layers':'WORKSPACENAME:LAYER2','WIDTH':'256','HEIGHT':'256' },
serverType: 'geoserver'
}))
})
]
});
I plan to add several more layers to GeoServer, and rather than making WMS requests for each layer, I want to put them all in a Layergroup in GeoServer. I did that --
new ol.layer.Tile({
source: new ol.source.TileWMS(({
url: 'http://localgeoserver:8080/geoserver/wms',
params: {'TILED': true, 'layers':'WORKSPACENAME:LAYERGROUP1','WIDTH':'256','HEIGHT':'256' },
serverType: 'geoserver'
}))
})
and again all the layers return as I expect them to, with one exception - I'm not sure how to apply the necessary CQL_FILTER to my layergroup. When I added the first CQL_FILTER [(USAGE IN ('H','B')]
when adding the LAYERGROUP1 layergroup as a layer, it failed because USAGE was not found in the LAYER2 layer.
I tried examples I saw where people said that each CQL_FILTER needs to be delimited by a semicolon, but that didn't seem to work either.
Is my end goal even possible going this route?
Is there a way to apply CQL_FILTERS when creating my layers in GeoServer?
Each layer is simply referencing an Oracle table, so should I go so far as to just create each layer with SQL and just apply my filters in the WHERE clause there?