private Map<BandType, Integer> mapBandsToConstraints( BandType[] dataBands, Map<BandType, AxisSubset> requestedBands ) { Map<BandType, Integer> bandsWithConstraints = new HashMap<BandType, Integer>( dataBands.length ); for ( int b = 0; b < dataBands.length; ++b ) { AxisSubset axisSubset = requestedBands.get( dataBands[b] ); if ( axisSubset != null ) { if ( axisSubset.hasAxisConstraints() ) { bandsWithConstraints.put( dataBands[b], b ); } } } return bandsWithConstraints; }
@Override public AbstractRaster apply( RangeSet sourceRangeSet, RangeSet targetRangeset ) { AbstractRaster result = raster(); if ( rangeSetsAreApplicable( sourceRangeSet, targetRangeset ) ) { List<AxisSubset> requestedAxis = targetRangeset.getAxisDescriptions(); if ( requestedAxis != null && !requestedAxis.isEmpty() ) { // create a copy so that the original rangeset will not be modified. List<AxisSubset> copyRA = new ArrayList<AxisSubset>( requestedAxis ); Map<BandType, AxisSubset> referencedBands = getReferencedBands( copyRA ); BandType[] bands = null; if ( referencedBands != null ) { bands = referencedBands.keySet().toArray( new BandType[referencedBands.keySet().size()] ); // filter the bands. result = raster().getSubRaster( raster().getEnvelope(), bands ); boolean applyData = false; for ( AxisSubset ass : referencedBands.values() ) { applyData = ass.hasAxisConstraints(); if ( applyData ) { break; } } if ( applyData ) { result = applyDataFilter( result, requestedAxis, referencedBands ); } } } } return result; }