I am trying various ways to have a programatic way of combining various bands of a tiff file into the red, green, blue channels.
I tried the CQL way, eg see below
This is my SLD
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>custom_raster</Name>
<UserStyle>
<FeatureTypeStyle>
<Rule>
<Name>rule1</Name>
<Title>Opaque Raster</Title>
<Abstract>A raster with 100% opacity</Abstract>
<RasterSymbolizer>
<Opacity>1.0</Opacity>
<ChannelSelection>
<RedChannel>
<SourceChannelName>${env('red',0)}</SourceChannelName>
</RedChannel>
<GreenChannel>
<SourceChannelName>${env('green',1)}</SourceChannelName>
</GreenChannel>
<BlueChannel>
<SourceChannelName>${env('blue',2)}</SourceChannelName>
</BlueChannel>
</ChannelSelection>
</RasterSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
I call it using ENV=red:1;blue:3;green:5 but I am getting the following message
Caused by: java.lang.IllegalArgumentException: Band number -1 is not valid.
...
Caused by: java.lang.NumberFormatException: For input string: "${env('red',0)}"
...
It doesn't seem to allow CQL expressions where I am placing them... yet doesn't complain when I validate. Any idea?