Skip to content

Commit

Permalink
[GEOS-8018] WMS cascading fails with NPE when advanced projection han…
Browse files Browse the repository at this point in the history
…dling gets disabled (NPE fixes)
  • Loading branch information
dromagnoli authored and aaime committed Mar 6, 2017
1 parent a487673 commit f28e846
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@
import org.geotools.styling.Style;
import org.geotools.util.logging.Logging;
import org.jaitools.imageutils.ROIGeometry;
import org.opengis.coverage.grid.Format;
import org.opengis.feature.Feature;
import org.opengis.feature.type.FeatureType;
import org.opengis.feature.type.Name;
import org.opengis.filter.expression.Expression;
import org.opengis.geometry.BoundingBox;
import org.opengis.parameter.GeneralParameterDescriptor;
import org.opengis.parameter.GeneralParameterValue;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.PixelInCell;
Expand Down Expand Up @@ -1051,13 +1055,20 @@ protected GridCoverage2D readCoverage(GridCoverage2DReader reader,
readGG.getGridRange2D(), interpolation, readerBgColor, bandIndices);

// If reader supports band selection, symbolizer channels should be reordered.
if (reader.getFormat().getReadParameters().getDescriptor().descriptors().
contains(AbstractGridFormat.BANDS) && params!=null){
// if bands are selected, alter the symbolizer to use bands in order 0,1,2,...
// since the channel order defined by it previously is taken care of the reader
if (bandIndices != null) {
symbolizer = GridCoverageRenderer.setupSymbolizerForBandsSelection(symbolizer);
}
if (params != null && reader != null) {
Format format = reader.getFormat();
ParameterValueGroup readParameters = null;
ParameterDescriptorGroup descriptorGroup = null;
List<GeneralParameterDescriptor> descriptors = null;
if (format != null && ((readParameters = format.getReadParameters()) != null)
&& ((descriptorGroup = readParameters.getDescriptor()) != null)
&& ((descriptors = descriptorGroup.descriptors()) != null)
&& (descriptors.contains(AbstractGridFormat.BANDS))
&& bandIndices != null){
// if bands are selected, alter the symbolizer to use bands in order 0,1,2,...
// since the channel order defined by it previously is taken care of the reader
symbolizer = GridCoverageRenderer.setupSymbolizerForBandsSelection(symbolizer);
}
}

}
Expand Down

0 comments on commit f28e846

Please sign in to comment.