root / trunk / libraries / libRaster / src-test / tmp / TestDataSourceWithNoData.java @ 11067
History | View | Annotate | Download (2.65 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.dataset.IBuffer; |
31 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
32 |
import org.gvsig.raster.dataset.RasterDataset; |
33 |
import org.gvsig.raster.dataset.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 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
40 |
*
|
41 |
*/
|
42 |
public class TestDataSourceWithNoData extends TestCase{ |
43 |
|
44 |
private String baseDir = "./test-images/"; |
45 |
private String path1 = baseDir + "miniRaster25x24.tif"; |
46 |
|
47 |
private RasterDataset f1 = null; |
48 |
|
49 |
private DataSource ds = null; |
50 |
|
51 |
public void setUp() { |
52 |
System.out.println("TestDataSourceWithNoData running..."); |
53 |
try {
|
54 |
f1 = RasterDataset.openFile(null, path1);
|
55 |
} catch (NotSupportedExtensionException e) {
|
56 |
e.printStackTrace(); |
57 |
} catch (RasterDriverException e) {
|
58 |
e.printStackTrace(); |
59 |
} |
60 |
|
61 |
} |
62 |
|
63 |
public void testStack(){ |
64 |
int[] drawableBands = {0, 1, 2}; |
65 |
ds = new DataSource(f1); |
66 |
ds.addDrawableBands(drawableBands); |
67 |
//El par?metro false indica que no se ajuste el extent al raster sino que se rellene con NoData los huecos
|
68 |
ds.setAreaOfInterest(645800.0, 4923870.0, 70, 70.0, false); |
69 |
|
70 |
IBuffer raster = ds.getRasterBuf(); |
71 |
for(int line = 0; line < raster.getHeight(); line++){ |
72 |
for(int col = 0; col < raster.getWidth(); col++) |
73 |
System.out.print("("+raster.getElemByte(line, col, 0)+" "+raster.getElemByte(line, col, 1)+" "+raster.getElemByte(line, col, 2)+")"); |
74 |
System.out.println();
|
75 |
} |
76 |
} |
77 |
|
78 |
} |