I am trying to display a Grib file with more than 32 bands in Geoserver. Creating a coverage store works, however, creating a layer from it fails with a stacktrace which ends with this:
Caused by: ucar.ma2.InvalidRangeException: Illegal Range for dimension 1:
last requested 32 > max 0
... 137 more
This file can be used to demonstrate the problem:
If I subset the file to 32 bands, it works as expected.
Upon further inspection, I traced the problem to the index in getImageIndex
in GeoSpatialImageReader.java is returned unsorted, like this:
*[32 33 34 ... n 0 1 2 3 ... 31] *, where n is the number of bands
The granule list returned by slicesCatalog is not sorted for files with more than 32 bands.
Sorting the index prior to returing it resolves the issue: