Ciao Thomas,
where are you exactly trying to delete the original files in your
code? That would help me with tracing down the problem.


Simone.

On Fri, Mar 21, 2008 at 4:59 PM, Thomas Bonavia <[EMAIL PROTECTED]> wrote:
>
> I am currently trying to :
> - get many geotiffs files,
> - crop them to get only the area i need,
> - write the new geotiffs,
> - delete the old geotiffs from my directory.
>
> My problem is the next one :
> When I try to remove the old tiff files, It is impossible...
> This is my code :
>
> for(int i = 0; i < files.length; i++){
>             try{
>                 /* We read the coverage and crop it. */
>                 reader = new GeoTiffReader(files[i], hints);
>                 GridCoverage2D temp = (GridCoverage2D)reader.read(null);
>
>                 /* We crop this coverage and put it into a second coverage.
> */
>                 paramCrop.parameter("Source").setValue(temp);
>                 paramCrop.parameter("Envelope").setValue(crop);
>                 GridCoverage2D temp2 =
> (GridCoverage2D)processor.doOperation(paramCrop);
>
>                 /* We write out the new coverage into geotiff file. */
>                 File outFile = new
> File(MSS_ControlProject.getRastersPath()+File.separator+i+".TIF");
>                 GeoTiffWriter gtw =
> (GeoTiffWriter)format.getWriter(outFile);
>
> gtw.write(temp2,(GeneralParameterValue[])paramWrite.values().toArray(new
> GeneralParameterValue[1]));
>
>                 /* We read the new geotiff file. */
>                 GeoTiffReader readerNew = new GeoTiffReader(outFile);
>                 GridCoverage2D temp3 = (GridCoverage2D)readerNew.read(null);
>
>                 rasters.add(temp3);
>                 readers.add(readerNew);
>
>                 temp.dispose(true);
>                 reader.dispose();
>
>                 // TODO delete original files
>                 // TODO add the creation of overview
>             }catch(DataSourceException dse){
>             }catch(IOException ioe){
>             }catch(CannotCropException cce){
>                 cce.printStackTrace();
>             }
>
> I tried to simplify the code, just to test, like that :
>
> for(int i = 0; i < files.length; i++){
>             try{
>                 /* We read the coverage and crop it. */
>                 reader = new GeoTiffReader(files[i], hints);
>                 GridCoverage2D temp = (GridCoverage2D)reader.read(null);
>
>                 temp.dispose(true);
>                 reader.dispose();
>
>                 // TODO delete original files
>                 // TODO add the creation of overview
>             }catch(DataSourceException dse){
>             }catch(IOException ioe){
>             }catch(CannotCropException cce){
>                 cce.printStackTrace();
>             }
>
> But it does not work... Is there somebody who get an idea ?
> (I tried to start with reader.dispose(), to put false instead of true....)
>
> Thanks
> Thomas
>
>
> ________________________________
> Discutez gratuitement avec vos amis en vidéo ! Téléchargez Messenger, c'est
> gratuit !
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Geotools-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-devel
>
>



-- 
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax: +39 0584983027
mob: +39 333 8128928


http://www.geo-solutions.it

-------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to