Revision 11076 trunk/libraries/libRaster/src-test/org/gvsig/raster/grid/TGReadingFullDatasourceSelectingBands.java
TGReadingFullDatasourceSelectingBands.java | ||
---|---|---|
21 | 21 |
import junit.framework.TestCase; |
22 | 22 |
|
23 | 23 |
import org.gvsig.raster.RasterLibrary; |
24 |
import org.gvsig.raster.dataaccess.DataSource;
|
|
25 |
import org.gvsig.raster.dataaccess.buffer.RasterBufferInvalidAccessException;
|
|
26 |
import org.gvsig.raster.dataaccess.buffer.RasterBufferInvalidException;
|
|
24 |
import org.gvsig.raster.buffer.BufferFactory;
|
|
25 |
import org.gvsig.raster.buffer.RasterBufferInvalidAccessException; |
|
26 |
import org.gvsig.raster.buffer.RasterBufferInvalidException; |
|
27 | 27 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
28 | 28 |
import org.gvsig.raster.dataset.RasterDataset; |
29 | 29 |
import org.gvsig.raster.dataset.RasterDriverException; |
... | ... | |
54 | 54 |
private String path2 = baseDir + "miniRaster25x24.tif"; |
55 | 55 |
private RasterDataset f1 = null; |
56 | 56 |
private RasterDataset f2 = null; |
57 |
private DataSource ds1 = null;
|
|
58 |
private DataSource ds2 = null;
|
|
57 |
private BufferFactory ds1 = null;
|
|
58 |
private BufferFactory ds2 = null;
|
|
59 | 59 |
|
60 |
static{ |
|
60 |
static {
|
|
61 | 61 |
RasterLibrary.wakeUp(); |
62 | 62 |
} |
63 | 63 |
|
64 |
public void start(){ |
|
64 |
public void start() {
|
|
65 | 65 |
this.setUp(); |
66 | 66 |
this.testStack(); |
67 | 67 |
} |
... | ... | |
69 | 69 |
public void setUp() { |
70 | 70 |
System.err.println("TGReadingFullDatasourceSelectingBands running..."); |
71 | 71 |
try { |
72 |
f1 = RasterDataset.openFile(null, path1);
|
|
73 |
f2 = RasterDataset.openFile(null, path2);
|
|
72 |
f1 = RasterDataset.open(null, path1); |
|
73 |
f2 = RasterDataset.open(null, path2); |
|
74 | 74 |
} catch (NotSupportedExtensionException e) { |
75 | 75 |
e.printStackTrace(); |
76 | 76 |
} catch (RasterDriverException e) { |
77 | 77 |
e.printStackTrace(); |
78 | 78 |
} |
79 |
ds1 = new DataSource(f1);
|
|
80 |
ds2 = new DataSource(f2);
|
|
79 |
ds1 = new BufferFactory(f1);
|
|
80 |
ds2 = new BufferFactory(f2);
|
|
81 | 81 |
} |
82 | 82 |
|
83 |
public void testStack(){ |
|
83 |
public void testStack() {
|
|
84 | 84 |
int[] drawableBands = {0, 1, 2}; |
85 | 85 |
try { |
86 | 86 |
Grid g = new Grid(ds1, drawableBands); |
... | ... | |
138 | 138 |
* @param g |
139 | 139 |
* @throws RasterBufferInvalidAccessException |
140 | 140 |
*/ |
141 |
private void testCellBufferFloat(Grid g, int band) throws RasterBufferInvalidAccessException{ |
|
141 |
private void testCellBufferFloat(Grid g, int band) throws RasterBufferInvalidAccessException {
|
|
142 | 142 |
int nCols = f1.getWidth(); |
143 | 143 |
int nRows = f1.getHeight(); |
144 |
for(int i = 0; i < nRows; i ++){ |
|
144 |
for(int i = 0; i < nRows; i ++) {
|
|
145 | 145 |
for(int j = 0; j < nCols; j ++) |
146 | 146 |
assertEquals((int)g.getCellValueAsFloat(j, i), (int)ds1.getRasterBuf().getElemFloat(i, j, band)); |
147 | 147 |
} |
... | ... | |
153 | 153 |
* @param g |
154 | 154 |
* @throws RasterBufferInvalidAccessException |
155 | 155 |
*/ |
156 |
private void testCellBufferByte(Grid g, int band) throws RasterBufferInvalidAccessException{ |
|
156 |
private void testCellBufferByte(Grid g, int band) throws RasterBufferInvalidAccessException {
|
|
157 | 157 |
int nCols = f2.getWidth(); |
158 | 158 |
int nRows = f2.getHeight(); |
159 |
for(int i = 0; i < nRows; i ++){ |
|
159 |
for(int i = 0; i < nRows; i ++) {
|
|
160 | 160 |
for(int j = 0; j < nCols; j ++) |
161 | 161 |
assertEquals((int)g.getCellValueAsByte(j, i), (int)ds2.getRasterBuf().getElemByte(i, j, band)); |
162 | 162 |
} |
Also available in: Unified diff