gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.lib.impl / deprecated / buffer / test / impl / rocache / TestCopyBand.java @ 1965
History | View | Annotate | Download (1.48 KB)
1 |
package org.gvsig.raster.cache.buffer.impl.rocache; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import junit.framework.TestCase; |
6 |
|
7 |
import org.gvsig.raster.cache.buffer.Band; |
8 |
import org.gvsig.raster.cache.buffer.Buffer; |
9 |
import org.gvsig.raster.cache.buffer.BufferDataSource; |
10 |
import org.gvsig.raster.cache.buffer.impl.io.BufferDataSourceImpl; |
11 |
|
12 |
/**
|
13 |
* Copy the band 0 from a buffer over the band 2 in the same buffer using the
|
14 |
* method getBandCopy.
|
15 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
16 |
*/
|
17 |
public class TestCopyBand extends TestCase { |
18 |
private String rasterIn = "./src/test/resources/image/001m09_1_0.tif"; |
19 |
|
20 |
public void start() { |
21 |
this.setUp();
|
22 |
this.testStack();
|
23 |
} |
24 |
|
25 |
public void setUp() { |
26 |
System.err.println("ROCache TestCopyBand running..."); |
27 |
} |
28 |
|
29 |
public void testStack() { |
30 |
long t1 = System.currentTimeMillis(); |
31 |
|
32 |
try {
|
33 |
BufferDataSource ds = null;
|
34 |
try {
|
35 |
ds = new BufferDataSourceImpl(rasterIn);
|
36 |
} catch (IOException e) { |
37 |
e.printStackTrace(); |
38 |
} |
39 |
Buffer buf = new RasterReadOnlyBuffer(ds); |
40 |
|
41 |
Band rb = buf.getBandCopy(0);
|
42 |
|
43 |
Band band1 = buf.getBand(0);
|
44 |
for (int i = 0; i < band1.getHeight(); i++) { |
45 |
for (int j = 0; j < band1.getWidth(); j++) { |
46 |
byte b1 = band1.getElemByte(i, j);
|
47 |
byte b2 = rb.getElemByte(i, j);
|
48 |
assertEquals(b1, b2); |
49 |
} |
50 |
} |
51 |
|
52 |
buf.free(); |
53 |
} catch (IOException e) { |
54 |
e.printStackTrace(); |
55 |
} |
56 |
long t2 = System.currentTimeMillis(); |
57 |
System.out.println("Tiempo ROCache TestCopyBand: " + (t2 - t1) + " milisegundos"); |
58 |
} |
59 |
|
60 |
} |