// }
// }
// }
// }
Band band = metadata.getBand(0);
Set<TemporalGeometricPrimitive> temporalExtent;
// Set<NumberRange<Double>> verticalExtent;
Map<String, HDF4ProductFieldType> fields;
// //
//
// Firstly, group coverages having the same bounding Box.
// Some datasources may contain data coming from acquisitions
// on different areas. We divide them in different groups.
//
// //
// if (!verticalCRSMap.containsKey(referenceID)) {
if (!coverages2DMap.containsKey(boundingBox)) {
// //
//
// This is the first occurrence. Setting coverageName,
// as well as the extents.
//
// //
coverageName = new NameImpl(mainCoverageName.getLocalPart() + "_" + Integer.toString(numCoverages++));
coverageNames.add(coverageName);
// verticalCRSMap.put(referenceID, coverageName);
coverages2DMap.put(boundingBox, coverageName);
temporalExtent = new LinkedHashSet<TemporalGeometricPrimitive>();
// verticalExtent = new LinkedHashSet<NumberRange<Double>>();
fields = new LinkedHashMap<String, HDF4ProductFieldType>();
temporalExtentMap.put(coverageName, temporalExtent);
// verticalExtentMap.put(coverageName, verticalExtent);
fieldsMap.put(coverageName, fields);
} else {
// coverageName = verticalCRSMap.get(referenceID);
coverageName = coverages2DMap.get(boundingBox);
}
if (!envelopesMap.containsKey(coverageName)) {
// //
//
// In case this coverage's properties haven't been
// initialized yet, init them.
//
// //
initOriginalEnvelopeAndCRS(coverageName, sd);
final GridGeometry2D gridGeometry2D = buildGridGeometry2D(coverageName, metadata);
gridGeometry2DMap.put(coverageName, gridGeometry2D);
} else {
GeneralEnvelope envelope = envelopesMap.get(coverageName);
envelope.add(sd.getGeneralEnvelope());
envelopesMap.put(coverageName, envelope);
}
// //
//
// Update the temporal, vertical extent for this coverage
//
// //
temporalExtent = (LinkedHashSet<TemporalGeometricPrimitive>) temporalExtentMap.get(coverageName);
// verticalExtent = (LinkedHashSet<NumberRange<Double>>) verticalExtentMap.get(coverageName);
// if (ve != null) {
// NumberRange<Double> verticalEnvelope = NumberRange.create(ve.getMinimumValue().doubleValue(), ve.getMaximumValue().doubleValue());
// if (!verticalExtent.contains(verticalEnvelope))
// verticalExtent.add(verticalEnvelope);
// }
if (time != null) {
if (!temporalExtent.contains(time))
temporalExtent.add(time);
}
// //
//
// Update the fields for this coverage
//
// //
fields = (LinkedHashMap<String, HDF4ProductFieldType>) fieldsMap.get(coverageName);
String elementName = band.getName();
if (!fields.containsKey(elementName)) {
Product product = HDF4ProductFieldType.getProduct(elementName);
Unit unit = Unit.ONE;
if (product != null) {
unit = product.getUoM();
} else {
String uOm = band.getUoM();
if(uOm == null)
unit = Unit.ONE.alternate(uOm);
else
try {
unit = Unit.valueOf(uOm);