use of org.opengis.coverage.grid.GridCoverage in project geowave by locationtech.
the class GeoWaveBasicCustomCRSRasterIT method queryNoDataMergeStrategy.
private void queryNoDataMergeStrategy(final String coverageName, final int tileSize) throws IOException {
final DataStore dataStore = dataStoreOptions.createDataStore();
try (CloseableIterator<?> it = dataStore.query(QueryBuilder.newBuilder().addTypeName(coverageName).build())) {
// the expected outcome is:
// band 1,2,3,4,5,6 has every value set correctly, band 0 has every
// even row set correctly and every odd row should be NaN, and band
// 7 has the upper quadrant as NaN and the rest set
final GridCoverage coverage = (GridCoverage) it.next();
final Raster raster = coverage.getRenderedImage().getData();
Assert.assertEquals(tileSize, raster.getWidth(), DELTA);
Assert.assertEquals(tileSize, raster.getHeight(), DELTA);
for (int x = 0; x < tileSize; x++) {
for (int y = 0; y < tileSize; y++) {
for (int b = 1; b < 7; b++) {
Assert.assertEquals("x=" + x + ",y=" + y + ",b=" + b, TestUtils.getTileValue(x, y, b, tileSize), raster.getSampleDouble(x, y, b), DELTA);
}
if ((y % 2) == 0) {
Assert.assertEquals("x=" + x + ",y=" + y + ",b=0", TestUtils.getTileValue(x, y, 0, tileSize), raster.getSampleDouble(x, y, 0), DELTA);
} else {
Assert.assertEquals("x=" + x + ",y=" + y + ",b=0", Double.NaN, raster.getSampleDouble(x, y, 0), DELTA);
}
if ((x > ((tileSize * 3) / 4)) && (y > ((tileSize * 3) / 4))) {
Assert.assertEquals("x=" + x + ",y=" + y + ",b=7", Double.NaN, raster.getSampleDouble(x, y, 7), DELTA);
} else {
Assert.assertEquals("x=" + x + ",y=" + y + ",b=7", TestUtils.getTileValue(x, y, 7, tileSize), raster.getSampleDouble(x, y, 7), DELTA);
}
}
}
// there should be exactly one
Assert.assertFalse(it.hasNext());
}
}
use of org.opengis.coverage.grid.GridCoverage in project georchestra by georchestra.
the class CoverageTransformation method perform.
/**
* Entry point for performing a transformation
*
* @param in the file to read the coverage from
* @param transform the transformation to apply
*
* @return result from the transform object
*/
public static <T> T perform(File in, CoverageTransformation<T> transform) throws IOException {
GeneralParameterValue[] params = new GeneralParameterValue[0];
AbstractGridFormat gridFormat = lookupFormat(in);
GridCoverage coverage = gridFormat.getReader(in).read(params);
try {
return transform.transform(coverage);
} catch (FactoryException e) {
throw new ExtractorException(e);
}
}
Aggregations