Hi
We're running GeoServer 2.3.3. We encountered an error when making a WMS
call to a layer backed by a 4-band image. In this instance, we applied a
RasterSymbolizer to assign the bands to the appropriate channels (in this
case R-3, G-2, B-1).
Seems to work okay, but when we added the transparent=true the WMS request,
we got the following ClassCastException:
java.lang.ClassCastException: [[B cannot be cast to [[S
at
com.sun.media.jai.opimage.BandMergeOpImage.shortLoop(BandMergeOpImage.java:346)
at
com.sun.media.jai.opimage.BandMergeOpImage.computeRect(BandMergeOpImage.java:204)
at javax.media.jai.PointOpImage.computeTile(PointOpImage.java:914)
at
com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
at javax.media.jai.OpImage.getTile(OpImage.java:1129)
at javax.media.jai.PlanarImage.getData(PlanarImage.java:2085)
at
javax.media.jai.StatisticsOpImage.getProperty(StatisticsOpImage.java:292)
at
com.sun.media.jai.opimage.ExtremaOpImage.getProperty(ExtremaOpImage.java:100)
at javax.media.jai.RenderedOp$1.getProperty(RenderedOp.java:1808)
at
javax.media.jai.PropertyEnvironment.getProperty(PropertyEnvironment.java:197)
at
javax.media.jai.PropertySourceImpl.getProperty(PropertySourceImpl.java:277)
at
javax.media.jai.WritablePropertySourceImpl.getProperty(WritablePropertySourceImpl.java:130)
at javax.media.jai.RenderedOp.getProperty(RenderedOp.java:1982)
at
org.geotools.image.ImageWorker.getComputedProperty(ImageWorker.java:694)
at org.geotools.image.ImageWorker.getExtremas(ImageWorker.java:714)
at
org.geotools.image.ImageWorker.rescaleToBytes(ImageWorker.java:904)
at
org.geoserver.wms.map.RenderedImageMapResponse.applyPalette(RenderedImageMapResponse.java:171)
at
org.geoserver.wms.map.PNGMapResponse.formatImageOutputStream(PNGMapResponse.java:109)
at
org.geoserver.wms.map.RenderedImageMapResponse.write(RenderedImageMapResponse.java:122)
at org.geoserver.ows.Dispatcher.response(Dispatcher.java:919)
....
Following the stack trace, I found that when transparent is set to true, in
org.geoserver.wms.map.RenderedImageMapOutputFormat.directRasterRender, it
calls the addAlphaChannel() method. This adds an alpha channel as a byte
array. Later in the process, when calling the applyPalette method in
RenderedImageMapResponse, it tries to rescale the RenderedImage to bytes.
However, the source data are all shorts, which causes the issue we see deep
in JAI land.
My solution to this is to call the rescaletoBytes method prior to adding the
alpha channel. So now, in RenderedImageMapFormat.directRasterRender, that
particular section would look like this:
if (transparent) {
ImageWorker iw = new ImageWorker(image);
image = iw.rescaleToBytes().getRenderedImage();
image = addAlphaChannel(image);
...
This appears to fix the ClassCastException. The image renders now, but with
a couple of issues:
1. It appears that any kind of stretch is being applied on a per-tile
basis, instead of to the whole image. This results in the image on the map
appearing with light/dark tiles.
2. Perhaps related, I'm getting the following warning (along with a
lengthy exception):
WARNING: Can't load a service for category "Operation". Cause is
"ServiceConfigurationError: org.opengis.coverage.processing.Operation: Prov
ider org.geotools (...) processing.OperationNotFoundException: No such
"ZonalStats" operation for this processor.".
sun.misc.ServiceConfigurationError:
org.opengis.coverage.processing.Operation: Provider
org.geotools.coverage.processing.operation.ZonalStat
s could not be instantiated:
org.opengis.coverage.processing.OperationNotFoundException: No such
"ZonalStats" operation for this processor.
Questions:
1. Is the fix I put in okay? It's probably obvious, but I'm not
very familiar with the whole image processing chain. Hence,
1a. Am I causing myself more trouble due to the "fix"?
2. Is geoserver reallly getting statistics on a per-tile basis
instead of the whole image before splitting into tiles?
Thanks to anyone who can provide some insight into this!
Justin
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/SLD-Channel-Selection-transparent-true-error-with-possible-fix-tp5085629.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.