Hi Ruben:
I have a couple of suggestions; mostly around how JAI and its internal "image cache" is used.
I am really not keen on the "InMemoryCoverageLoader" code; as it represents us "fixing" a problem in the wrong manner. The trouble is we have not done the experiments to sort out what the correct manner is.
JAI makes use of a tile cache which it uses when working with raster data; and it does a pretty good job of not regenerating content it already has sorted out once. In uDig 1.1.x we did not actually use the tile cache at all; in uDig 1.2.0 I have tried storing a tile cache for each layer. While this is good in that we don't throw out our work each time we render it is bad as we do not use memory in a very wise fashion.
What we really should do is store a tile cache ...
- for each map (ie on the map blackboard?) this would allow a good balance between all the raster in use for the map; and we could "empty" the cache if the map was closed ...
- for each workbench window as Eclipse workbench service (like selection service) - which amounts to a blackboard for each eclipse window open. This would allow a larger bucket of memory to be devoted to raster use; and as we change between maps and so on JAI would be able to figure out what tiles were stale etc...
As for geotiff; there should be a fair bit that can be done. But 1st I need to ask how the image is slow?
!) is it slow when looking at the entire image zoomed out?
- If so an overlay would do wonders
- or ask JAI to create an overlay in memory when the image is 1st loaded? It would smoothly switch from the overlay to the real data when zooming in.
- or create an overlay as part of your geotiff file itself; it is the fastest way to help the performance (and no code changes)
2) is it slow when zoomed in?
- the JAI image tile cache things mentioned above should help; try different values (maybe make a preference page so users can try different values)
- go to an internal tile system in your geotiff (cannot remember what the option is called). It would prevent the disk head from running all over the place as it reads in a zoomed in "tile" of information.
- experiment with JAI title cache and geotiff internal timing (perhaps getting the two sizes to line up; or auto configuring the jai tile cache based on the tiles in your geotiff would do something?)
But yeah the number one advice here is to please chech that we are using the JAI tile cache; rather than something horrible like loading the image into memory ourself. If we have to set up the JAI tile cache and load the image into that it would be much better.