Statistics
| Revision:

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

History | View | Annotate | Download (3.86 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 org.gvsig.raster.dataset;
26

    
27
import junit.framework.TestCase;
28

    
29
import org.gvsig.raster.RasterLibrary;
30

    
31
/**
32
 * Este test que obtiene la informaci?n de un ?nico pixel. Repetira esta
33
 * operaci?n sobre varios pixels sobre una misma imagen comprobado que los resultados
34
 * sean correctos, es decir para la posici?n seleccionada existe ese pixel obtenido.
35
 * 
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 *
38
 */
39
public class TestDataByPixelEcw extends TestCase {
40

    
41
        private String baseDir = "./test-images/";
42
        private String path1 = baseDir + "miniraster30x30.jp2";
43
        
44
        private RasterDataset f1 = null;
45
        
46
        public void start() {
47
                this.setUp();
48
                this.testStack();
49
        }
50
        
51
        static {
52
                RasterLibrary.wakeUp();
53
        }
54
        
55
        public void setUp() {
56
                System.err.println("TestDataByPixelEcw running...");
57
                try {
58
                        f1 = RasterDataset.open(null, path1);
59
                } catch (NotSupportedExtensionException e1) {
60
                        e1.printStackTrace();
61
                } catch (RasterDriverException e1) {
62
                        e1.printStackTrace();
63
                }
64
                
65
        }
66
        
67
        public void testStack(){
68
                try {
69
                        testPixelsValues();
70
                } catch (InvalidSetViewException e) {
71
                        e.printStackTrace();
72
                } catch (FileNotOpenException e) {
73
                        e.printStackTrace();
74
                } catch (RasterDriverException e) {
75
                        e.printStackTrace();
76
                }
77
        }
78
        
79
        public void testPixelsValues()throws InvalidSetViewException, FileNotOpenException, RasterDriverException{
80
                assertEquals(((Integer)f1.getData(1, 1, 0)).intValue(), 73);
81
                assertEquals(((Integer)f1.getData(1, 1, 1)).intValue(), 87);
82
                assertEquals(((Integer)f1.getData(1, 1, 2)).intValue(), 72);
83
                
84
                assertEquals(((Integer)f1.getData(18, 16, 0)).intValue(), 61);
85
                assertEquals(((Integer)f1.getData(18, 16, 1)).intValue(), 74);
86
                assertEquals(((Integer)f1.getData(18, 16, 2)).intValue(), 57);
87
                
88
                assertEquals(((Integer)f1.getData(17, 23, 0)).intValue(), 172);
89
                assertEquals(((Integer)f1.getData(17, 23, 1)).intValue(), 154);
90
                assertEquals(((Integer)f1.getData(17, 23, 2)).intValue(), 140);
91
                
92
                assertEquals(((Integer)f1.getData(23, 3, 0)).intValue(), 188);
93
                assertEquals(((Integer)f1.getData(23, 3, 1)).intValue(), 186);
94
                assertEquals(((Integer)f1.getData(23, 3, 2)).intValue(), 189);
95
                
96
                assertEquals(((Integer)f1.getData(29, 29, 0)).intValue(), 126);
97
                assertEquals(((Integer)f1.getData(29, 29, 1)).intValue(), 134);
98
                assertEquals(((Integer)f1.getData(29, 29, 2)).intValue(), 111);
99
                
100
                assertEquals(((Integer)f1.getData(0, 29, 0)).intValue(), 175);
101
                assertEquals(((Integer)f1.getData(0, 29, 1)).intValue(), 175);
102
                assertEquals(((Integer)f1.getData(0, 29, 2)).intValue(), 147);
103
                
104
                assertEquals(((Integer)f1.getData(0, 0, 0)).intValue(), 43);
105
                assertEquals(((Integer)f1.getData(0, 0, 1)).intValue(), 53);
106
                assertEquals(((Integer)f1.getData(0, 0, 2)).intValue(), 26);
107
                
108
                assertEquals(((Integer)f1.getData(29, 0, 0)).intValue(), 255);
109
                assertEquals(((Integer)f1.getData(29, 0, 1)).intValue(), 252);
110
                assertEquals(((Integer)f1.getData(29, 0, 2)).intValue(), 246);
111
        }
112

    
113
}