Statistics
| Revision:

root / trunk / libraries / libRaster / src-test / tmp / TestDataSourceWithNoDataAndResizeBuffer.java @ 10740

History | View | Annotate | Download (3.66 KB)

1
/*
2
 * Created on 19-jul-2006
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 */
25
package tmp;
26

    
27
import junit.framework.TestCase;
28

    
29
import org.gvsig.raster.dataaccess.DataSource;
30
import org.gvsig.raster.driver.NotSupportedExtensionException;
31
import org.gvsig.raster.driver.RasterDataset;
32
import org.gvsig.raster.driver.IBuffer;
33
import org.gvsig.raster.driver.RasterDriverException;
34

    
35
/**
36
 * Este test prueba la gesti?n de multifichero de la clase GeoRasterMultiFile
37
 * y que incorpora un Grid, as? como la gesti?n de bandas que tiene BandList
38
 * y que incorpora GeoRasterMultiFile.
39
 * <P>
40
 * Raster de 25x24 pixels 
41
 * Extent ul=(645818.258, 4923850.700) lr=(645852.842, 4923817.500)
42
 * Petici?n ul=(645800.0, 4923870.0) lr=(645870.0, 4923800.0)  (Mayor que la extensi?n)
43
 * Casos posibles:
44
 * </P>
45
 * <PRE>
46
 * isSupersamplingLoadingBuffer() == true
47
 *     Buffer 25x24; adjustToExtent = true -> readRaster(0, 0, 25, 24, 25, 24); step(0, 0, 25, 24)
48
 *     Buffer 25x24; adjustToExtent = false -> readRaster(0, 0, 25, 24, 12, 11); step(6, 6, 18, 17)
49
 *     Buffer 51x50; adjustToExtent = true -> readRaster(0, 0, 25, 24, 51, 50); step(0, 0, 51, 50)
50
 *     Buffer 51x50; adjustToExtent = false -> readRaster(0, 0, 25, 24, 25, 24); step(13, 13, 38, 37)
51
 * isSupersamplingLoadingBuffer() == false
52
 *     Buffer 25x24; adjustToExtent = true -> readRaster(0, 0, 25, 24, 25, 24); step(0, 0, 25, 24)
53
 *     Buffer 25x24; adjustToExtent = false
54
 *     Buffer 51x50; adjustToExtent = true
55
 *     Buffer 51x50; adjustToExtent = false
56
 * </PRE>
57
 * @author Nacho Brodin (nachobrodin@gmail.com)
58
 *
59
 */
60
public class TestDataSourceWithNoDataAndResizeBuffer extends TestCase{
61

    
62
        private String baseDir = "./test-images/";
63
        private String path1 = baseDir + "miniRaster25x24.tif";
64
        
65
        private RasterDataset f1 = null;
66
                
67
        private DataSource ds = null;
68
        
69
        public void setUp() {
70
                System.out.println("TestDataSourceWithNoDataAndResizeBuffer running...");
71
                try {
72
                        f1 = RasterDataset.openFile(null, path1);
73
                } catch (NotSupportedExtensionException e) {
74
                        e.printStackTrace();
75
                } catch (RasterDriverException e) {
76
                        e.printStackTrace();
77
                }
78
        }
79
        
80
        public void testStack(){
81
                int[] drawableBands = {0, 1, 2};
82
                ds = new DataSource(f1);
83
                ds.addDrawableBands(drawableBands);
84
                //El par?metro false indica que no se ajuste el extent al raster sino que se rellene con NoData los huecos
85
                ds.setSupersamplingLoadingBuffer(false);
86
                ds.setAreaOfInterest(645800.0, 4923870.0, 645870.0, 4923800.0, 13, 12, true);
87
                
88
                IBuffer raster = ds.getRasterBuf();
89
                for(int line = 0; line < raster.getHeight(); line++){
90
                        for(int col = 0; col < raster.getWidth(); col++)
91
                                System.out.print("("+raster.getElemByte(line, col, 0)+" "+raster.getElemByte(line, col, 1)+" "+raster.getElemByte(line, col, 2)+")");
92
                        System.out.println();
93
                }
94
        }
95

    
96
}