Hi all. We are trying to render huge (21000x21000px) GeoTiff which is internally tiled and contain overviews. It is created from image and worldfile by GDAL. When it is not rotated ("rotation term" field for row and column in worldfile) everything works fine, memory consumption is small. But in case it is rotated, rendering takes big amount of memory. I debugged it and the problem is in "GridCoverageRenderer" in method "paint":
Because image is rotated this condition will pass
– if(!isScaleTranslate(gridCoverage.getGridGeometry().getGridToCRS())) {
then because we render in one CRS this condition will not pass
– if (doReprojection) {
then is called
– graphics.drawRenderedImage(finalImage, clonedFinalWorldToGrid);
which will fail on "Java heap space OutOfMemory Error". Because (Java documentation):
– Renders a RenderedImage, applying a transform from image space into user space before drawing.
So one possible solution is to use gdalwarp utility to remove rotation from image. That is how we work now.
Second possibility is to improve geotools way of rendering tiled rotated coverages. The improvement could be to render each tile inside rendering bbox separately. It will be probably quite slow but better than exception.
If you want I think I am able to implement this feature. Though some hints about classes/methods I should use could be helpful.