Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libRaster / src-test / org / gvsig / raster / dataset / TestGetWindowRasterMrSID.java @ 12522

History | View | Annotate | Download (2.96 KB)

1
/*
2
 * Created on 9-ago-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 org.gvsig.raster.dataset;
26

    
27
import junit.framework.TestCase;
28

    
29
import org.gvsig.raster.RasterLibrary;
30
import org.gvsig.raster.buffer.BufferFactory;
31

    
32
/**
33
 * Test que compara los resultados de la llamada getWindowRaster en coordenadas pixel 
34
 * y coordenadas reales para comprobar que producen el mismo resultado para la misma extensi?n.
35
 * 
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 *
38
 */
39
public class TestGetWindowRasterMrSID extends TestCase {
40
        
41
        private String baseDir = "./test-images/";
42
        private String path1 = baseDir + "q101866.sid";
43
        private RasterDataset f1 = null;
44
        private RasterDataset f2 = null;
45
        
46
        static {
47
                RasterLibrary.wakeUp();
48
        }
49
        
50
        public void start() {
51
                this.setUp();
52
                this.testStack();
53
        }
54
        
55
        public void setUp() {
56
                System.err.println("TestGetWindowRasterMrSID running...");
57
                try {
58
                        f1 = RasterDataset.open(null, path1);
59
                        f2 = RasterDataset.open(null, path1);
60
                } catch (NotSupportedExtensionException e1) {
61
                        e1.printStackTrace();
62
                } catch (RasterDriverException e1) {
63
                        e1.printStackTrace();
64
                }
65
        }
66
        
67
        public void testStack(){
68
                BufferFactory bf1 = new BufferFactory(f1);
69
                bf1.setAllDrawableBands();
70
                bf1.setAreaOfInterest(f1.getExtent().getMin().getX(), f1.getExtent().getMax().getY(), f1.getExtent().width(), f1.getExtent().height());
71
                IBuffer buf1 = bf1.getRasterBuf();
72
                
73
                BufferFactory bf2 = new BufferFactory(f2);
74
                bf2.setAllDrawableBands();
75
                bf2.setAreaOfInterest(0, 0, f2.getWidth(), f2.getHeight());
76
                IBuffer buf2 = bf2.getRasterBuf();
77
                
78
                for (int band = 0; band < buf1.getBandCount(); band++) {
79
                        for (int row = 0; row < buf1.getHeight(); row++) {
80
                                for (int col = 0; col < buf1.getWidth(); col++) {
81
                                        //try {
82
                                        assertEquals(buf1.getElemByte(row, col, band), buf2.getElemByte(row, col, band));
83
                                        //System.out.println(buf1.getElemByte(row, col, band) + " " + buf2.getElemByte(row, col, band));
84
                                        /*} catch (AssertionFailedError e) {
85
                                                System.out.println(band + " " + line + " " + column);
86
                                                
87
                                        }*/
88
                                }
89
                        }
90
                }
91
        }
92

    
93
}