Hi GT-developers, 

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

File geotiff = ...
BufferedImage bufferedImage = ImageIO.read(geotiff); 
PlanarImage planarImage = PlanarImage.wrapRenderedImage(bufferedImage); 
GeoTiffReader 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-tp5004582p5005157.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
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