Filter originalFilter = subsettingRequest.getFilter();
final int specifiedDimensionsSubset = dimensionsSubset != null ? dimensionsSubset.size() : 0;
// Casting to StructuredGridCoverage2DReader
final StructuredGridCoverage2DReader structuredReader = (StructuredGridCoverage2DReader) reader;
// Getting dimension descriptors
final List<DimensionDescriptor> dimensionDescriptors = structuredReader.getDimensionDescriptors(coverageName);
DimensionDescriptor timeDimension = null;
DimensionDescriptor elevationDimension = null;
final List<DimensionDescriptor> customDimensions = new ArrayList<DimensionDescriptor>();
int dimensions = 0;
// Collect dimension Descriptor info
for (DimensionDescriptor dimensionDescriptor: dimensionDescriptors) {
if (dimensionDescriptor.getName().equalsIgnoreCase(ResourceInfo.TIME)) {
timeDimension = dimensionDescriptor;
} else if (dimensionDescriptor.getName().equalsIgnoreCase(ResourceInfo.ELEVATION)) {
elevationDimension = dimensionDescriptor;
} else {
customDimensions.add(dimensionDescriptor);
dimensions++;
}
}
final boolean defaultTimeNeeded = temporalSubset == null && timeDimension != null;
final boolean defaultElevationNeeded = elevationSubset == null && elevationDimension != null;
final boolean defaultCustomDimensionsNeeded = dimensions != specifiedDimensionsSubset;
// Note that only Slicing is currently supported;
if (defaultTimeNeeded || defaultElevationNeeded || defaultCustomDimensionsNeeded) {
// Get granules source
GranuleSource source = structuredReader.getGranules(coverageName, true);
// Set filtering query matching the specified subsets.
Filter finalFilter = setFilters(originalFilter, temporalSubset, elevationSubset, envelopeSubset, dimensionsSubset, structuredReader, timeDimension, elevationDimension, customDimensions);
Query query = new Query();