public GridCoverage next() {
final ByteArrayId insertionId = insertionIds.next();
if (insertionId == null) {
return null;
}
final MultiDimensionalNumericData rangePerDimension = pyramidLevel.getIndexStrategy().getRangeForId(
insertionId);
final NumericDimensionDefinition[] dimensions = pyramidLevel.getIndexStrategy().getOrderedDimensionDefinitions();
int longitudeIndex = 0, latitudeIndex = 1;
final double[] minDP = new double[2];
final double[] maxDP = new double[2];
for (int d = 0; d < dimensions.length; d++) {
if (dimensions[d] instanceof LatitudeDefinition) {
latitudeIndex = d;
minDP[1] = originalBounds.getMinValuesPerDimension()[d];
maxDP[1] = originalBounds.getMaxValuesPerDimension()[d];
}
else if (dimensions[d] instanceof LongitudeDefinition) {
longitudeIndex = d;
minDP[0] = originalBounds.getMinValuesPerDimension()[d];
maxDP[0] = originalBounds.getMaxValuesPerDimension()[d];
}
}
final Envelope originalEnvelope = new GeneralEnvelope(
minDP,
maxDP);
final double[] minsPerDimension = rangePerDimension.getMinValuesPerDimension();
final double[] maxesPerDimension = rangePerDimension.getMaxValuesPerDimension();
final ReferencedEnvelope mapExtent = new ReferencedEnvelope(
minsPerDimension[longitudeIndex],
maxesPerDimension[longitudeIndex],
minsPerDimension[latitudeIndex],
maxesPerDimension[latitudeIndex],