Statistics
| Revision:

root / trunk / libraries / libRaster / src-test / org / gvsig / raster / dataset / TestDataByPixelEcw.java @ 11074

History | View | Annotate | Download (4.13 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
import org.gvsig.raster.dataset.FileNotOpenException;
31
import org.gvsig.raster.dataset.InvalidSetViewException;
32
import org.gvsig.raster.dataset.NotSupportedExtensionException;
33
import org.gvsig.raster.dataset.RasterDataset;
34
import org.gvsig.raster.dataset.RasterDriverException;
35

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

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

    
118
}