List axisSubset = null;
if (request.getRangeSubset() != null) {
axisSubset = request.getRangeSubset().getAxisSubset();
if (axisSubset.size() > 0) {
for (int a = 0; a < axisSubset.size(); a++) {
AxisSubsetType axis = (AxisSubsetType) axisSubset.get(a);
String axisName = axis.getName();
if (axisName.equalsIgnoreCase(WCSUtils.ELEVATION)) {
if (axis.getSingleValue().size() > 0) {
for (int s = 0; s < axis.getSingleValue().size(); s++) {
elevations.add(Double.parseDouble(((TypedLiteralType) axis
.getSingleValue().get(s)).getValue()));
}
} else if (axis.getInterval().size() > 0) {
IntervalType interval = (IntervalType) axis.getInterval().get(0);
int min = Integer.parseInt(interval.getMin().getValue());
int max = Integer.parseInt(interval.getMax().getValue());
int res = (interval.getRes() != null ? Integer.parseInt(interval
.getRes().getValue()) : 1);
int count = (int) (Math.floor(max - min) / res + 1);
for (int b = 0; b < count; b++) {
elevations.add(new Double(min + b * res));
}
}
}
}
}
}
if(elevations.isEmpty()) {
elevations.add(dimensions.getMinElevation());
}
readParameters = CoverageUtils.mergeParameter(parameterDescriptors,
readParameters, elevations, "ELEVATION", "Elevation");
}
//
// CUSTOM DIMENSION SUPPORT
//
if (request.getRangeSubset() != null) {
EList<?> axisSubset = request.getRangeSubset().getAxisSubset();
final int asCount = axisSubset == null ? 0 : axisSubset.size();
for (int i = 0; i < asCount; i++) {
AxisSubsetType axis = (AxisSubsetType)axisSubset.get(i);
String axisName = axis.getName();
if (!axisName.equalsIgnoreCase(WCSUtils.ELEVATION)) {
Object dimInfo = meta.getMetadata().get(ResourceInfo.CUSTOM_DIMENSION_PREFIX + axisName);
axisName = axisName.toUpperCase(); // using uppercase with imagemosaic
if (dimInfo instanceof DimensionInfo && dimensions.hasDomain(axisName)) {
int valueCount = axis.getSingleValue().size();
if (valueCount > 0) {
List<String> dimValues = new ArrayList<String>(valueCount);
for (int s = 0; s < valueCount; s++) {
dimValues.add(((TypedLiteralType) axis
.getSingleValue().get(s)).getValue());
}
readParameters = CoverageUtils.mergeParameter(parameterDescriptors,
readParameters, dimValues, axisName);
}
}
}
}
}
//
// Check if we have a filter among the params
//
Filter filter = WCSUtils.getRequestFilter();
if(filter != null) {
readParameters = CoverageUtils.mergeParameter(parameterDescriptors,
readParameters, filter, "FILTER", "Filter");
}
// Check we're not going to read too much data
WCSUtils.checkInputLimits(wcs, meta, reader, requestedGridGeometry);
//
// Checking for supported Interpolation Methods
//
Interpolation interpolation = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
String interpolationType = null;
if(request.getInterpolationMethod()!=null){
interpolationType = request.getInterpolationMethod().getLiteral();
if (interpolationType != null) {
if (interpolationType.equalsIgnoreCase("bilinear")) {
interpolation = Interpolation.getInstance(Interpolation.INTERP_BILINEAR);
} else if (interpolationType.equalsIgnoreCase("bicubic")) {
interpolation = Interpolation.getInstance(Interpolation.INTERP_BICUBIC);
} else if (interpolationType.equalsIgnoreCase("nearest neighbor")) {
interpolation = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
}
readParameters = CoverageUtils.mergeParameter(parameterDescriptors,readParameters, interpolation, "interpolation");
if(meta.getStore().getFormat() instanceof ImageMosaicFormat){
GeneralParameterValue[] temp = new GeneralParameterValue[readParameters.length+1];
System.arraycopy(readParameters, 0, temp, 0, readParameters.length);
temp[temp.length-1]=ImageMosaicFormat.INTERPOLATION.createValue();
((ParameterValue)temp[temp.length-1]).setValue(interpolation);
readParameters=temp;
}
}
}
//
// make sure we work in streaming mode
//
// work in streaming fashion when JAI is involved
readParameters = WCSUtils.replaceParameter(readParameters, Boolean.FALSE,
AbstractGridFormat.USE_JAI_IMAGEREAD);
//
// perform read
//
coverage = (GridCoverage2D) reader.read(readParameters);
if ((coverage == null) || !(coverage instanceof GridCoverage2D)) {
throw new IOException("No raster data found in the request (it may be that " +
"the request bbox is outside of the coverage area, or that the filters used " +
"match no portions of it.");
}
// double check what we have loaded
WCSUtils.checkInputLimits(wcs, coverage);
//
// Band Select (works on just one field)
//
GridCoverage2D bandSelectedCoverage = coverage;
// ImageIOUtilities.visualize(coverage.getRenderedImage());
if (request.getRangeSubset() != null) {
// if (request.getRangeSubset().getAxisSubset().size() > 1) {
// throw new WcsException("Multi field coverages are not supported yet");
// }
// extract the band indexes
EList axisSubset = request.getRangeSubset().getAxisSubset();
if (axisSubset.size() > 0) {
for (int a = 0; a < axisSubset.size(); a++) {
AxisSubsetType axis = (AxisSubsetType) axisSubset.get(a);
try {
String axisName = axis.getName();
if (axisName.equalsIgnoreCase("Band")) {
int[] bands = null;
if (axis.getSingleValue().size() > 0) {
bands = new int[axis.getSingleValue().size()];
for (int s = 0; s < axis.getSingleValue().size(); s++) {
bands[s] = Integer.parseInt(((TypedLiteralType) axis
.getSingleValue().get(s)).getValue()) - 1;
}
} else if (axis.getInterval().size() > 0) {
IntervalType interval = (IntervalType) axis.getInterval()
.get(0);
int min = Integer.parseInt(interval.getMin().getValue());
int max = Integer.parseInt(interval.getMax().getValue());
int res = (interval.getRes() != null ? Integer
.parseInt(interval.getRes().getValue()) : 1);