*/
protected static GridCoverage2D createTestCoverage(final int width, final int height,
final double envX0, final double envY0,
final double envWidth, final double envHeight) {
final GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
WritableRaster raster =
RasterFactory.createBandedRaster(DataBuffer.TYPE_FLOAT, width, height, 1, null);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if( x<50 && y<50 ) { // upper left square: vertical lines
if(x % 5 == 0)
raster.setSample(x, y, 0, 0);
else
raster.setSample(x, y, 0, width);
}
else if(x < 50 && y > height-50) { // lower left square: horizontal lines
if(y % 5 == 0)
raster.setSample(x, y, 0, 0);
else
raster.setSample(x, y, 0, width);
}
else if(x > width- 50 && y < 50) { // upper right square: descending diagonal lines
if( (x-y) % 5 == 0)
raster.setSample(x, y, 0, 0);
else
raster.setSample(x, y, 0, width);
}
else if(x > width- 50 && y > height-50) { // lower right square: ascending diagonal lines
if( (x+y) % 5 == 0)
raster.setSample(x, y, 0, 0);
else
raster.setSample(x, y, 0, width);
}
else if(x % 50 == 0 || y % 50 == 0 || (x - y) % 100 == 0)
raster.setSample(x, y, 0, 0); // bigger lines
else
raster.setSample(x, y, 0, x+y); // normal background
}
}
final Color[] colors = new Color[]{
Color.BLUE, Color.CYAN, Color.WHITE, Color.YELLOW, Color.RED
};
return factory.create("Float coverage", raster,
new Envelope2D(DefaultGeographicCRS.WGS84, envX0, envY0, envWidth, envHeight),
null, null,
null, new Color[][]{colors}, null);
}