NASAWorldWind / WorldWindJava

The NASA WorldWind Java SDK (WWJ) is for building cross-platform 3D geospatial desktop applications in Java.
714 stars 324 forks source link

Unable to Delete Image File Opened As SurfaceImage #100

Open robmilton opened 7 years ago

robmilton commented 7 years ago

I'm using WorldWind Java version 2.1.0, and when I open an image file to use as a SurfaceImage I am unable to delete/modify that image file until the WorldWind application is closed. I can replicate this behavior with the SurfaceImageViewer example application.

Because we cache these images and allow the user to create and modify images I need to be able to delete/modify an image after it has been opened as a SurfaceImage.

It seems there is a possibility that one or more of the classes that work with the GDAL library (particularly the GDALDataRaster class) may not be closing/releasing the image resources. But the code is very involved, and I'm not 100% sure that this is the case.

There is a post on the WorldWind Java forum that goes into greater detail... https://forum.worldwindcentral.com/forum/world-wind-java-forums/development-help/156976-need-help-deleting-image-file-opened-as-surfaceimage

Please let me know if you need anything else from me.

Thanks, Rob

robmilton commented 8 months ago

UPDATE

Discovered the issue can be resolved by calling SurfaceImageLayer.addImage and passing a 'name', buffered image, and sector.  Not sure what code was holding onto the image file.  But changing to this method resolved the issue.