Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1010 / libraries / libCq_CMS_praster / src-test / org / cresques / io / data / TestGridMultiFile.java @ 12804

History | View | Annotate | Download (5.62 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.cresques.io.data;
26

    
27
import junit.framework.TestCase;
28

    
29
import org.cresques.io.GeoRasterFile;
30

    
31
/**
32
 * Este test prueba la gesti?n de multifichero de la clase GeoRasterMultiFile
33
 * y que incorpora un Grid, as? como la gesti?n de bandas que tiene BandList
34
 * y que incorpora GeoRasterMultiFile.
35
 * @author Nacho Brodin (brodin_ign@gva.es)
36
 *
37
 */
38
public class TestGridMultiFile extends TestCase{
39

    
40
        private String path1 = "/home/imagenes/p198r033_7t20010601_z31_nn10.tif";
41
        private String path2 = "/home/imagenes/p198r033_7t20010601_z31_nn20.tif";
42
        private String path3 = "/home/imagenes/p198r033_7t20010601_z31_nn30.tif";
43
        private String path4 = "/home/imagenes/043_269_mer_orto.img";
44
        
45
        private GeoRasterFile f1 = null;
46
        private GeoRasterFile f2 = null;
47
        private GeoRasterFile f3 = null;
48
        private GeoRasterFile f4 = null;
49
        
50
        private Grid grid = null;
51
        
52
        public void setUp() {
53
                System.out.println("TestGridMultiFile running...");
54
                f1 = GeoRasterFile.openFile(null, path1);
55
                f2 = GeoRasterFile.openFile(null, path2);
56
                f3 = GeoRasterFile.openFile(null, path3);
57
                f4 = GeoRasterFile.openFile(null, path4);
58
        }
59
        
60
        public void testStack(){
61
        
62
                //EL CONSTRUCTOR A?ADE FICHERO 1
63
                grid = new Grid(f1);
64
                //Comprobaci?n de n?mero y nombre de ficheros
65
                String[] fileList = grid.getGeoRasterMultiFile().getNameFileStringList();
66
                assertEquals(fileList.length, 1);
67
                assertEquals(fileList[0], path1);
68
                //Comprobaci?n de bandas
69
                String[] bandList = grid.getGeoRasterMultiFile().getBands().getBandStringList();
70
                assertEquals(bandList.length, 1);
71
                assertEquals(bandList[0], path1);
72
                
73
                //A?ADIMOS FICHERO 2
74
                grid.addFile(f2);
75
                fileList = grid.getGeoRasterMultiFile().getNameFileStringList();
76
                //Comprobaci?n de n?mero y nombre de ficheros
77
                assertEquals(fileList.length, 2);
78
                assertEquals(fileList[0], path1);
79
                assertEquals(fileList[1], path2);
80
                //Comprobaci?n de bandas
81
                bandList = grid.getGeoRasterMultiFile().getBands().getBandStringList();
82
                assertEquals(bandList.length, 2);
83
                assertEquals(bandList[0], path1);
84
                assertEquals(bandList[1], path2);
85
                
86
                //A?ADIMOS FICHERO 3
87
                grid.addFile(f3);
88
                fileList = grid.getGeoRasterMultiFile().getNameFileStringList();
89
                //Comprobaci?n de n?mero y nombre de ficheros
90
                assertEquals(fileList.length, 3);
91
                assertEquals(fileList[0], path1);
92
                assertEquals(fileList[1], path2);
93
                assertEquals(fileList[2], path3);
94
                //Comprobaci?n de bandas
95
                bandList = grid.getGeoRasterMultiFile().getBands().getBandStringList();
96
                assertEquals(bandList.length, 3);
97
                assertEquals(bandList[0], path1);
98
                assertEquals(bandList[1], path2);
99
                assertEquals(bandList[2], path3);
100
                //Posicion dentro del fichero
101
                int[] bandPos = grid.getGeoRasterMultiFile().getBands().getBandPositionList();
102
                for(int i = 0; i < bandPos.length; i++)
103
                        assertEquals(bandPos[i], 0);
104
                
105
                //ELIMINAMOS FICHERO 2
106
                grid.removeFile(f2);
107
                fileList = grid.getGeoRasterMultiFile().getNameFileStringList();
108
                //Comprobaci?n de n?mero y nombre de ficheros
109
                assertEquals(fileList.length, 2);
110
                assertEquals(fileList[0], path1);
111
                assertEquals(fileList[1], path3);
112
                //Comprobaci?n de bandas
113
                bandList = grid.getGeoRasterMultiFile().getBands().getBandStringList();
114
                assertEquals(bandList.length, 2);
115
                assertEquals(bandList[0], path1);
116
                assertEquals(bandList[1], path3);
117
                
118
                //ELIMINAMOS FICHERO 1
119
                grid.removeFile(f1);
120
                fileList = grid.getGeoRasterMultiFile().getNameFileStringList();
121
                //Comprobaci?n de n?mero y nombre de ficheros
122
                assertEquals(fileList.length, 1);
123
                assertEquals(fileList[0], path3);
124
                //Comprobaci?n de bandas
125
                bandList = grid.getGeoRasterMultiFile().getBands().getBandStringList();
126
                assertEquals(bandList.length, 1);
127
                assertEquals(bandList[0], path3);
128
                
129
                //ELIMINAMOS FICHERO 3
130
                grid.removeFile(f3);
131
                fileList = grid.getGeoRasterMultiFile().getNameFileStringList();
132
                //Comprobaci?n de n?mero y nombre de ficheros
133
                assertEquals(fileList.length, 0);
134
                //Comprobaci?n de bandas
135
                bandList = grid.getGeoRasterMultiFile().getBands().getBandStringList();
136
                assertEquals(bandList.length, 0);
137

    
138
                //A?ADIMOS FICHERO 4
139
                grid.addFile(f4);
140
                fileList = grid.getGeoRasterMultiFile().getNameFileStringList();
141
                //Comprobaci?n de n?mero y nombre de ficheros
142
                assertEquals(fileList.length, 1);
143
                assertEquals(fileList[0], path4);
144
                //Comprobaci?n de bandas
145
                bandList = grid.getGeoRasterMultiFile().getBands().getBandStringList();
146
                assertEquals(bandList.length, 4);
147
                assertEquals(bandList[0], path4);
148
                assertEquals(bandList[1], path4);
149
                assertEquals(bandList[2], path4);
150
                assertEquals(bandList[3], path4);
151
                //Posicion dentro del fichero
152
                bandPos = grid.getGeoRasterMultiFile().getBands().getBandPositionList();
153
                for(int i = 0; i < bandPos.length; i++)
154
                        assertEquals(bandPos[i], i);
155
        }
156

    
157
}