Hi GT-developers,

Even this piece of code locks the GeoTIFF file (as soon as the coverage is
created by some InputStreams):

BufferedImage bufferedImage = ImageIO.read(geotiff);
PlanarImage planarImage = PlanarImage.wrapRenderedImage(bufferedImage);
reader = new GeoTiffReader(null);
cov = reader.createCoverage(planarImage, null);
cov.dispose(true);

Well, I don't have a clue how to dispose a coverage for sure and relatively
fast, so that the underlying GeoTIFF file can be further processed
(moved/renamed/deleted etc.)!



In my case (just for reading the BoundingBox of a GeoTIFF file) following
code did not lock the underlying GeoTIFF file when reading from it, so this
solves my problem in the meantime:

AbstractGridFormat format = GridFormatFinder.findFormat(geotiff);
AbstractGridCoverage2DReader gridReader = format.getReader(geotiff);
Rectangle2D rect = gridReader.getOriginalEnvelope().toRectangle2D();

// doing something ... (like reading envelope etc.)
System.out.println("left: " + Double.toString(rect.getMinX()));
System.out.println("bottom: " + Double.toString(rect.getMinY()));
System.out.println("right: " + Double.toString(rect.getMaxX()));
System.out.println("top: " + Double.toString(rect.getMaxY()));


I would nevertheless appreciate if someone can give me a hint how to dispose
a coverage.
Thanks

João



--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/GeoTiffReader-unable-to-dispose-file-still-locked-tp5004582p5004944.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to