parameterDescriptors.addAll(dynamicParameters);
//
// TIME
//
ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
DimensionInfo timeDimension = meta.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class);
if(timeDimension != null && timeDimension.isEnabled() && dimensions.hasTime()) {
final List<Object> timeValues = new ArrayList<Object>();
if (temporalSubset != null && temporalSubset.getTimePosition() != null) {
// grab the time positions
final EList timePosition = temporalSubset.getTimePosition();
for (Iterator it = timePosition.iterator(); it.hasNext();) {
TimePositionType tp = (TimePositionType) it.next();
Date date = (Date) tp.getValue();
if(date == null) {
date = dimensions.getMaxTime();
}
timeValues.add(date);
}
// grab the time intervals
final EList timePeriods = temporalSubset.getTimePeriod();
for (Iterator it = timePeriods.iterator(); it.hasNext();) {
TimePeriodType tp = (TimePeriodType) it.next();
Date begin = (Date) tp.getBeginPosition().getValue();
Date end = (Date) tp.getEndPosition().getValue();
timeValues.add(new DateRange(begin, end));
}
}
if(timeValues.isEmpty()) {
Date date = dimensions.getMaxTime();
timeValues.add(date);
}
readParameters = CoverageUtils.mergeParameter(parameterDescriptors,
readParameters, timeValues, "TIME", "Time");
}
//
// ELEVATION SUPPORT VIA A SPECIFIC AXIS ELEVATION
//
DimensionInfo elevationDimension = meta.getMetadata().get(ResourceInfo.ELEVATION, DimensionInfo.class);
if(elevationDimension != null && elevationDimension.isEnabled() && dimensions.hasElevation()) {
List<Double> elevations = new ArrayList<Double>();
// extract elevation values
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