use of org.geotoolkit.coverage.io.ImageCoverageReader in project geotoolkit by Geomatys.
the class LandsatResource method getSampleDimensions.
/**
* {@inheritDoc }
*
* @param index 0, 1 or 2 for respectively ({@link LandsatConstants#REFLECTIVE_LABEL},
* {@link LandsatConstants#PANCHROMATIC_LABEL}, {@link LandsatConstants#THERMAL_LABEL}).
*/
@Override
public List<SampleDimension> getSampleDimensions() throws DataStoreException, CancellationException {
if (gsdLandsat != null) {
return gsdLandsat;
}
final int[] bandId = group.bands;
final List<SampleDimension> gList = new ArrayList<>();
for (int i : bandId) {
final String bandName = metadataParser.getValue(true, BAND_NAME_LABEL + i);
final Path resolve = parentDirectory.resolve(bandName);
final ImageCoverageReader imageCoverageReader = new ImageCoverageReader();
try {
final ImageReader tiffReader = TIFF_SPI.createReaderInstance();
tiffReader.setInput(resolve);
imageCoverageReader.setInput(tiffReader);
final List<SampleDimension> candidates = imageCoverageReader.getSampleDimensions();
if (candidates != null)
gList.addAll(candidates);
} catch (IOException ex) {
throw new DataStoreException(ex);
} finally {
imageCoverageReader.dispose();
}
}
gsdLandsat = gList;
return gsdLandsat;
}
Aggregations