OutOfMemoryError exception throws when writing a USHORT geotiff
---------------------------------------------------------------

                 Key: GEOT-2331
                 URL: http://jira.codehaus.org/browse/GEOT-2331
             Project: GeoTools
          Issue Type: Bug
          Components: gc geotiff
    Affects Versions: 2.5.2, 2.4.5
            Reporter: Min Feng
            Priority: Minor


I tried to create a geotiff file with USHORT data type, but a OutOfMemoryError 
exception was throwed when saving the raster. I also tried other data types 
such as SHORT or INT. It turned out that the code works with those data types 
except USHORT.

JUnit tests pasted below:
----------------------------------------------------------------
import java.awt.image.DataBuffer;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.io.File;

import javax.media.jai.RasterFactory;

import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.coverage.grid.GridCoverageFactory;
import org.geotools.factory.FactoryFinder;
import org.geotools.factory.GeoTools;
import org.geotools.gce.geotiff.GeoTiffFormat;
import org.geotools.gce.geotiff.GeoTiffWriteParams;
import org.geotools.geometry.Envelope2D;
import org.geotools.referencing.CRS;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class AppTest extends TestCase {
        public void testApp() throws Exception {
                //It works when TYPE_USHORT changes to other data types, such 
as TYPE_SHORT, TYPE_INT, etc.
                WritableRaster _raster = 
RasterFactory.createBandedRaster(DataBuffer.TYPE_USHORT, 100, 50, 1, null);

                for(int _row = 0;_row<50;_row++){
                        for(int _col=0;_col < 100;_col++){
                                _raster.setSample(_col, _row, 0, _row * _col);
                        }
                }
                
                Envelope2D _env = new Envelope2D(CRS.decode("EPSG:4326", true), 
0, 0, 180, 90);

                GridCoverage2D _grid = new 
GridCoverageFactory().create("test1", _raster, _env);
                GeoTiffFormat _format = new GeoTiffFormat();
                
                GeoTiffWriteParams _wp = new GeoTiffWriteParams();
                _wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
                _wp.setCompressionType("LZW");
                _wp.setCompressionQuality(0.75F);
                
                //Exception throws here
                _format.getWriter(new File("c:\\test.tif")).write(_grid, null);
        }
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to