throw new IOException("Unable to access");
}
LOGGER.info("Connected to coverage: " + name.toString());
// TEMPORAL DOMAIN
final TemporalDomain temporalDomain = gridSource.getTemporalDomain();
if (temporalDomain == null) {
LOGGER.info("Temporal domain is null");
} else {
// temporal crs
LOGGER.info("TemporalCRS: " + temporalDomain.getCoordinateReferenceSystem());
// print the temporal domain elements
for (DateRange tg : temporalDomain.getTemporalElements(true, null)) {
LOGGER.info("Global Temporal Domain: " + tg.toString());
}
// print the temporal domain elements with overall = true
StringBuilder overallTemporal = new StringBuilder("Temporal domain element (overall = true):\n");
for (DateRange tg : temporalDomain.getTemporalElements(false, null)) {
overallTemporal.append(tg.toString()).append("\n");
}
LOGGER.info(overallTemporal.toString());
}
// VERTICAL DOMAIN
final VerticalDomain verticalDomain = gridSource.getVerticalDomain();
if (verticalDomain == null) {
LOGGER.info("Vertical domain is null");
} else {
// vertical crs
LOGGER.info("VerticalCRS: " + verticalDomain.getCoordinateReferenceSystem());
// print the Vertical domain elements
for (NumberRange<Double> vg : verticalDomain.getVerticalElements(true, null)) {
LOGGER.info("Vertical domain element: " + vg.toString());
}
// print the Vertical domain elements with overall = true
StringBuilder overallVertical = new StringBuilder("Vertical domain element (overall = true):\n");
for (NumberRange<Double> vg : verticalDomain.getVerticalElements(false, null)) {
overallVertical.append(vg.toString()).append("\n");
}
LOGGER.info(overallVertical.toString());
}
// HORIZONTAL DOMAIN
final SpatialDomain spatialDomain = gridSource.getSpatialDomain();
if (spatialDomain == null) {
LOGGER.info("Horizontal domain is null");
} else {
// print the horizontal domain elements
final CoordinateReferenceSystem crs2D = spatialDomain.getCoordinateReferenceSystem2D();
assert crs2D != null;
final MathTransform2D g2w = spatialDomain.getGridToWorldTransform(null);
assert g2w != null;
final Set<? extends BoundingBox> spatialElements = spatialDomain.getSpatialElements(true, null);
assert spatialElements != null && !spatialElements.isEmpty();
final StringBuilder buf = new StringBuilder();
buf.append("Horizontal domain is as follows:\n");
buf.append("G2W:").append("\t").append(g2w).append("\n");
buf.append("CRS2D:").append("\t").append(crs2D).append("\n");
for (BoundingBox bbox : spatialElements) {
buf.append("BBOX:").append("\t").append(bbox).append("\n");
}
LOGGER.info(buf.toString());
}
CoverageReadRequest readRequest = new CoverageReadRequest();
// //
//
// Setting up a limited range for the request.
//
// //
LinkedHashSet<NumberRange<Double>> requestedVerticalSubset = new LinkedHashSet<NumberRange<Double>>();
SortedSet<? extends NumberRange<Double>> verticalElements = verticalDomain
.getVerticalElements(false, null);
final int numLevels = verticalElements.size();
final Iterator<? extends NumberRange<Double>> iterator = verticalElements.iterator();
for (int i = 0; i < numLevels; i++) {
NumberRange<Double> level = iterator.next();
if (i % (numLevels / 5) == 1) {
requestedVerticalSubset.add(level);
}
}
readRequest.setVerticalSubset(requestedVerticalSubset);
SortedSet<DateRange> requestedTemporalSubset = new DateRangeTreeSet();
SortedSet<? extends DateRange> temporalElements = temporalDomain.getTemporalElements(false, null);
final int numTimes = temporalElements.size();
Iterator<? extends DateRange> iteratorT = temporalElements.iterator();
for (int i = 0; i < numTimes; i++) {
DateRange time = iteratorT.next();
if (i % (numTimes / 5) == 1) {