Revision 21615 trunk/libraries/libRaster/src-test/org/gvsig/raster/buffer/cache/TestRasterCache.java
TestRasterCache.java | ||
---|---|---|
9 | 9 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
10 | 10 |
import org.gvsig.raster.dataset.RasterDataset; |
11 | 11 |
import org.gvsig.raster.dataset.io.RasterDriverException; |
12 |
|
|
13 |
|
|
14 | 12 |
/** |
15 | 13 |
* Test de comparativa de datos cacheados con datos sin cachear. |
16 | 14 |
* Leemos un raster 1..n veces cacheandolo por p?ginas. Una vez cacheado recorreremos |
... | ... | |
20 | 18 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
21 | 19 |
*/ |
22 | 20 |
public class TestRasterCache extends TestCase{ |
23 |
private String baseDir = "./test-images/"; |
|
24 |
private String path = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg"; |
|
25 |
private RasterDataset f = null; |
|
26 |
private BufferFactory ds = null; |
|
27 |
|
|
28 |
static{ |
|
21 |
private String baseDir = "./test-images/"; |
|
22 |
private String path = baseDir + "03AUG23153350-M2AS-000000122423_01_P001-BROWSE.jpg"; |
|
23 |
private RasterDataset f = null; |
|
24 |
|
|
25 |
static { |
|
29 | 26 |
RasterLibrary.wakeUp(); |
30 | 27 |
} |
31 |
|
|
32 |
public void start(){ |
|
28 |
|
|
29 |
public void start() {
|
|
33 | 30 |
this.setUp(); |
34 | 31 |
this.testStack(); |
35 | 32 |
} |
36 |
|
|
33 |
|
|
37 | 34 |
public void setUp() { |
38 | 35 |
System.err.println("TestRasterCache running..."); |
39 | 36 |
try { |
... | ... | |
46 | 43 |
} |
47 | 44 |
|
48 | 45 |
public void testStack() { |
49 |
int[] drawableBands = {0, 1, 2};
|
|
46 |
int[] drawableBands = { 0, 1, 2 };
|
|
50 | 47 |
//N?mero de veces que cacheamos la imagen. Esto hace que el n?mero de l?neas totales se multiplique por este n?mero |
51 | 48 |
int nTimes = 1; |
52 |
|
|
53 |
ds = new BufferFactory(f); |
|
49 |
BufferFactory ds = new BufferFactory(f); |
|
54 | 50 |
ds.setDrawableBands(drawableBands); |
55 | 51 |
try { |
56 | 52 |
ds.setAreaOfInterest(0, 0, f.getWidth(), f.getHeight()); |
... | ... | |
61 | 57 |
} catch (RasterDriverException e) { |
62 | 58 |
e.printStackTrace(); |
63 | 59 |
} |
64 |
|
|
65 |
//Salvamos los PageBuffer |
|
60 |
|
|
61 |
// Salvamos los PageBuffer
|
|
66 | 62 |
IBuffer buf = ds.getRasterBuf(); |
67 | 63 |
|
68 | 64 |
//Reducimos el tama?o de la cach? para poder trabajar con un volumen de datos reducido |
65 |
long cacheSize = RasterLibrary.cacheSize; |
|
66 |
double pageSize = RasterLibrary.pageSize; |
|
69 | 67 |
RasterLibrary.cacheSize = 1; |
70 | 68 |
RasterLibrary.pageSize = 0.2; |
71 |
|
|
69 |
|
|
72 | 70 |
RasterCache rc = new RasterCache(f.getDataType()[0], f.getWidth(), f.getHeight() * nTimes, 3); |
73 |
//rc.getCache().getCacheStruct().show();
|
|
74 |
|
|
75 |
//Cargamos la cach? |
|
71 |
// rc.getCache().getCacheStruct().show();
|
|
72 |
|
|
73 |
// Cargamos la cach?
|
|
76 | 74 |
byte[] data = new byte[3]; |
77 |
for(int i = 0; i < nTimes; i++){
|
|
78 |
for(int line = 0; line < f.getHeight(); line ++){
|
|
75 |
for (int i = 0; i < nTimes; i++) {
|
|
76 |
for (int line = 0; line < f.getHeight(); line++) {
|
|
79 | 77 |
for (int col = 0; col < f.getWidth(); col++) { |
80 | 78 |
buf.getElemByte(line, col, data); |
81 | 79 |
rc.setElemByte(line + (f.getHeight() * i), col, data); |
82 | 80 |
} |
83 | 81 |
} |
84 | 82 |
} |
85 |
|
|
86 |
//Obtenemos los datos y comparamos |
|
83 |
|
|
84 |
// Obtenemos los datos y comparamos
|
|
87 | 85 |
byte[] dataA = new byte[3]; |
88 | 86 |
byte[] dataB = new byte[3]; |
89 |
for(int i = 0; i < nTimes; i++){
|
|
90 |
for(int line = 0; line < f.getHeight(); line ++){
|
|
87 |
for (int i = 0; i < nTimes; i++) {
|
|
88 |
for (int line = 0; line < f.getHeight(); line++) {
|
|
91 | 89 |
for (int col = 0; col < f.getWidth(); col++) { |
92 | 90 |
buf.getElemByte(line, col, dataA); |
93 | 91 |
rc.getElemByte(line + (f.getHeight() * i), col, dataB); |
... | ... | |
97 | 95 |
} |
98 | 96 |
} |
99 | 97 |
} |
100 |
|
|
101 |
|
|
98 |
RasterLibrary.cacheSize = cacheSize; |
|
99 |
RasterLibrary.pageSize = pageSize; |
|
102 | 100 |
} |
103 | 101 |
} |
Also available in: Unified diff