root / trunk / libraries / libRaster / src / org / gvsig / raster / buffer / cache / RasterReadOnlyHugeBuffer.java @ 11351
History | View | Annotate | Download (11.3 KB)
1 |
package org.gvsig.raster.buffer.cache; |
---|---|
2 |
|
3 |
import java.io.FileNotFoundException; |
4 |
|
5 |
import org.gvsig.raster.buffer.IBand; |
6 |
import org.gvsig.raster.buffer.RasterBuffer; |
7 |
import org.gvsig.raster.dataset.IBuffer; |
8 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
9 |
import org.gvsig.raster.dataset.RasterDriverException; |
10 |
|
11 |
/**
|
12 |
*
|
13 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
14 |
*
|
15 |
*/
|
16 |
public class RasterReadOnlyHugeBuffer extends RasterBuffer { |
17 |
private Cache cache = null; |
18 |
private LRUAlgorithm lru = null; |
19 |
|
20 |
/**
|
21 |
* Constructor. Asigna las variables de inicializaci?n y crea la estructura de
|
22 |
* la cach? con los datos pasados.
|
23 |
* @param dataType Tipo de dato
|
24 |
* @param width Ancho
|
25 |
* @param height Alto
|
26 |
* @param bandNr Banda
|
27 |
* @param orig
|
28 |
* @throws RasterDriverException
|
29 |
* @throws NotSupportedExtensionException
|
30 |
* @throws FileNotFoundException
|
31 |
*/
|
32 |
public RasterReadOnlyHugeBuffer(int dataType, int width, int height, int nBand, String fileName) |
33 |
throws FileNotFoundException, NotSupportedExtensionException, RasterDriverException{ |
34 |
cache = new Cache(nBand, dataType, width, height, fileName);
|
35 |
lru = new LRUAlgorithm(cache);
|
36 |
|
37 |
this.dataType = dataType;
|
38 |
this.width = width;
|
39 |
this.height = height;
|
40 |
this.nBands = nBand;
|
41 |
} |
42 |
|
43 |
public void malloc(int dataType, int width, int height, int bandNr) { |
44 |
} |
45 |
|
46 |
/*
|
47 |
* (non-Javadoc)
|
48 |
* @see org.gvsig.raster.driver.IBuffer#isBandSwitchable()
|
49 |
*/
|
50 |
public boolean isBandSwitchable(){ |
51 |
return false; |
52 |
} |
53 |
|
54 |
/**
|
55 |
* Obtiene la cach?
|
56 |
* @return
|
57 |
*/
|
58 |
public Cache getCache() {
|
59 |
return cache;
|
60 |
} |
61 |
//*********************************************************
|
62 |
|
63 |
public byte[][] getLineByte(int line) { |
64 |
try {
|
65 |
lru.cacheAccess(line, true);
|
66 |
} catch (InvalidPageNumberException e) {return null;} |
67 |
return cache.getAccessPage().getLineByte((line & cache.getOffset()));
|
68 |
} |
69 |
|
70 |
public short[][] getLineShort(int line) { |
71 |
try {
|
72 |
lru.cacheAccess(line, true);
|
73 |
} catch (InvalidPageNumberException e) {return null;} |
74 |
return cache.getAccessPage().getLineShort((line & cache.getOffset()));
|
75 |
} |
76 |
|
77 |
public int[][] getLineInt(int line) { |
78 |
try {
|
79 |
lru.cacheAccess(line, true);
|
80 |
} catch (InvalidPageNumberException e) {return null;} |
81 |
return cache.getAccessPage().getLineInt((line & cache.getOffset()));
|
82 |
} |
83 |
|
84 |
public float[][] getLineFloat(int line) { |
85 |
try {
|
86 |
lru.cacheAccess(line, true);
|
87 |
} catch (InvalidPageNumberException e) {return null;} |
88 |
return cache.getAccessPage().getLineFloat((line & cache.getOffset()));
|
89 |
} |
90 |
|
91 |
public double[][] getLineDouble(int line) { |
92 |
try {
|
93 |
lru.cacheAccess(line, true);
|
94 |
} catch (InvalidPageNumberException e) {return null;} |
95 |
return cache.getAccessPage().getLineDouble((line & cache.getOffset()));
|
96 |
} |
97 |
|
98 |
//*********************************************************
|
99 |
|
100 |
public void setLineByte(byte[][] data, int line) {} |
101 |
|
102 |
public void setLineShort(short[][] data, int line) {} |
103 |
|
104 |
public void setLineInt(int[][] data, int line) {} |
105 |
|
106 |
public void setLineFloat(float[][] data, int line) {} |
107 |
|
108 |
public void setLineDouble(double[][] data, int line) {} |
109 |
|
110 |
//*********************************************************
|
111 |
|
112 |
public byte[] getLineFromBandByte(int line, int band) { |
113 |
try {
|
114 |
lru.cacheAccess(line, true);
|
115 |
} catch (InvalidPageNumberException e) {return null;} |
116 |
return cache.getAccessPage().getLineFromBandByte((line & cache.getOffset()), band);
|
117 |
} |
118 |
|
119 |
public short[] getLineFromBandShort(int line, int band) { |
120 |
try {
|
121 |
lru.cacheAccess(line, true);
|
122 |
} catch (InvalidPageNumberException e) {return null;} |
123 |
return cache.getAccessPage().getLineFromBandShort((line & cache.getOffset()), band);
|
124 |
} |
125 |
|
126 |
public int[] getLineFromBandInt(int line, int band) { |
127 |
try {
|
128 |
lru.cacheAccess(line, true);
|
129 |
} catch (InvalidPageNumberException e) {return null;} |
130 |
return cache.getAccessPage().getLineFromBandInt((line & cache.getOffset()), band);
|
131 |
} |
132 |
|
133 |
public float[] getLineFromBandFloat(int line, int band) { |
134 |
try {
|
135 |
lru.cacheAccess(line, true);
|
136 |
} catch (InvalidPageNumberException e) {return null;} |
137 |
return cache.getAccessPage().getLineFromBandFloat((line & cache.getOffset()), band);
|
138 |
} |
139 |
|
140 |
public double[] getLineFromBandDouble(int line, int band) { |
141 |
try {
|
142 |
lru.cacheAccess(line, true);
|
143 |
} catch (InvalidPageNumberException e) {return null;} |
144 |
return cache.getAccessPage().getLineFromBandDouble((line & cache.getOffset()), band);
|
145 |
} |
146 |
|
147 |
//*********************************************************
|
148 |
|
149 |
public void setLineInBandByte(byte[] data, int line, int band) {} |
150 |
|
151 |
public void setLineInBandShort(short[] data, int line, int band) {} |
152 |
|
153 |
public void setLineInBandInt(int[] data, int line, int band) {} |
154 |
|
155 |
public void setLineInBandFloat(float[] data, int line, int band) {} |
156 |
|
157 |
public void setLineInBandDouble(double[] data, int line, int band) {} |
158 |
|
159 |
//*********************************************************
|
160 |
|
161 |
public byte getElemByte(int line, int col, int band) { |
162 |
try {
|
163 |
lru.cacheAccess(line, true);
|
164 |
} catch (InvalidPageNumberException e) {
|
165 |
return (byte)getNoDataValue(); //No leemos el dato |
166 |
} |
167 |
return cache.getAccessPage().getElemByte((line & cache.getOffset()), col, band);
|
168 |
} |
169 |
|
170 |
public short getElemShort(int line, int col, int band) { |
171 |
try {
|
172 |
lru.cacheAccess(line, true);
|
173 |
} catch (InvalidPageNumberException e) {
|
174 |
return (short)getNoDataValue(); //No leemos el dato |
175 |
} |
176 |
return cache.getAccessPage().getElemShort((line & cache.getOffset()), col, band);
|
177 |
} |
178 |
|
179 |
public int getElemInt(int line, int col, int band) { |
180 |
try {
|
181 |
lru.cacheAccess(line, true);
|
182 |
} catch (InvalidPageNumberException e) {
|
183 |
return (int)getNoDataValue(); //No leemos el dato |
184 |
} |
185 |
return cache.getAccessPage().getElemInt((line & cache.getOffset()), col, band);
|
186 |
} |
187 |
|
188 |
public float getElemFloat(int line, int col, int band) { |
189 |
try {
|
190 |
lru.cacheAccess(line, true);
|
191 |
} catch (InvalidPageNumberException e) {
|
192 |
return (float)getNoDataValue(); //No leemos el dato |
193 |
} |
194 |
return cache.getAccessPage().getElemFloat((line & cache.getOffset()), col, band);
|
195 |
} |
196 |
|
197 |
public double getElemDouble(int line, int col, int band) { |
198 |
try {
|
199 |
lru.cacheAccess(line, true);
|
200 |
} catch (InvalidPageNumberException e) {
|
201 |
return (double)getNoDataValue(); //No leemos el dato |
202 |
} |
203 |
return cache.getAccessPage().getElemDouble((line & cache.getOffset()), col, band);
|
204 |
} |
205 |
|
206 |
//*********************************************************
|
207 |
|
208 |
public void setElem(int line, int col, int band, byte data) {} |
209 |
|
210 |
public void setElem(int line, int col, int band, short data) {} |
211 |
|
212 |
public void setElem(int line, int col, int band, int data) {} |
213 |
|
214 |
public void setElem(int line, int col, int band, float data) {} |
215 |
|
216 |
public void setElem(int line, int col, int band, double data) {} |
217 |
|
218 |
//*********************************************************
|
219 |
|
220 |
public void getElemByte(int line, int col, byte[] data) { |
221 |
try {
|
222 |
lru.cacheAccess(line, true);
|
223 |
} catch (InvalidPageNumberException e) {
|
224 |
for (int iBand = 0; iBand < data.length; iBand++) |
225 |
data[iBand] = (byte)getNoDataValue();
|
226 |
} |
227 |
cache.getAccessPage().getElemByte((line & cache.getOffset()), col, data); |
228 |
} |
229 |
|
230 |
public void getElemShort(int line, int col, short[] data) { |
231 |
try {
|
232 |
lru.cacheAccess(line, true);
|
233 |
} catch (InvalidPageNumberException e) {
|
234 |
for (int iBand = 0; iBand < data.length; iBand++) |
235 |
data[iBand] = (short)getNoDataValue();
|
236 |
} |
237 |
cache.getAccessPage().getElemShort((line & cache.getOffset()), col, data); |
238 |
} |
239 |
|
240 |
public void getElemInt(int line, int col, int[] data) { |
241 |
try {
|
242 |
lru.cacheAccess(line, true);
|
243 |
} catch (InvalidPageNumberException e) {
|
244 |
for (int iBand = 0; iBand < data.length; iBand++) |
245 |
data[iBand] = (int)getNoDataValue();
|
246 |
} |
247 |
cache.getAccessPage().getElemInt((line & cache.getOffset()), col, data); |
248 |
} |
249 |
|
250 |
public void getElemFloat(int line, int col, float[] data) { |
251 |
try {
|
252 |
lru.cacheAccess(line, true);
|
253 |
} catch (InvalidPageNumberException e) {
|
254 |
for (int iBand = 0; iBand < data.length; iBand++) |
255 |
data[iBand] = (float)getNoDataValue();
|
256 |
} |
257 |
cache.getAccessPage().getElemFloat((line & cache.getOffset()), col, data); |
258 |
} |
259 |
|
260 |
public void getElemDouble(int line, int col, double[] data) { |
261 |
try {
|
262 |
lru.cacheAccess(line, true);
|
263 |
} catch (InvalidPageNumberException e) {
|
264 |
for (int iBand = 0; iBand < data.length; iBand++) |
265 |
data[iBand] = (double)getNoDataValue();
|
266 |
} |
267 |
cache.getAccessPage().getElemDouble((line & cache.getOffset()), col, data); |
268 |
} |
269 |
|
270 |
//*********************************************************
|
271 |
|
272 |
public void setElemByte(int line, int col, byte[] data) {} |
273 |
|
274 |
public void setElemShort(int line, int col, short[] data) {} |
275 |
|
276 |
public void setElemInt(int line, int col, int[] data) {} |
277 |
|
278 |
public void setElemFloat(int line, int col, float[] data) {} |
279 |
|
280 |
public void setElemDouble(int line, int col, double[] data) {} |
281 |
|
282 |
//***********************************************
|
283 |
//Obtiene una banda entera
|
284 |
|
285 |
public IBand getBand(int band){ |
286 |
return null; |
287 |
} |
288 |
|
289 |
/*
|
290 |
* (non-Javadoc)
|
291 |
* @see org.gvsig.fmap.driver.IBuffer#getBandBuffer(int)
|
292 |
*/
|
293 |
public IBuffer getBandBuffer(int iBand){ |
294 |
return null; |
295 |
} |
296 |
|
297 |
public void replicateBand(int orig, int dest) { |
298 |
} |
299 |
|
300 |
/*
|
301 |
* (non-Javadoc)
|
302 |
* @see org.gvsig.fmap.dataaccess.buffer.RasterBuffer#switchBands(int[])
|
303 |
*/
|
304 |
public void switchBands(int[] bandPosition){ |
305 |
|
306 |
} |
307 |
|
308 |
//*********************************************************
|
309 |
|
310 |
public RasterBuffer adjustRasterNearestNeighbourInterpolation(int w, int h, int[] bands) { |
311 |
return null; |
312 |
} |
313 |
|
314 |
public RasterBuffer adjustRasterBilinearInterpolation(int w, int h, int[] bands) { |
315 |
return null; |
316 |
} |
317 |
|
318 |
public RasterBuffer adjustRasterInverseDistanceInterpolation(int w, int h, int[] bands) { |
319 |
return null; |
320 |
} |
321 |
|
322 |
public RasterBuffer adjustRasterBicubicSplineInterpolation(int w, int h, int[] bands) { |
323 |
return null; |
324 |
} |
325 |
|
326 |
public RasterBuffer adjustRasterBSplineInterpolation(int w, int h, int[] bands) { |
327 |
return null; |
328 |
} |
329 |
|
330 |
//*********************************************************
|
331 |
|
332 |
public void assign(int band, byte value) {} |
333 |
|
334 |
public void assign(int band, short value) {} |
335 |
|
336 |
public void assign(int band, int value) {} |
337 |
|
338 |
public void assign(int band, float value) {} |
339 |
|
340 |
public void assign(int band, double value) {} |
341 |
|
342 |
|
343 |
/*
|
344 |
* (non-Javadoc)
|
345 |
* @see org.gvsig.fmap.driver.IBuffer#cloneBuffer()
|
346 |
*/
|
347 |
public IBuffer cloneBuffer(){
|
348 |
return null; |
349 |
} |
350 |
|
351 |
/*
|
352 |
* (non-Javadoc)
|
353 |
* @see org.gvsig.fmap.driver.IBuffer#interchangeBands(int, int)
|
354 |
*/
|
355 |
public void interchangeBands(int band1, int band2) { |
356 |
} |
357 |
|
358 |
/*
|
359 |
* (non-Javadoc)
|
360 |
* @see org.gvsig.fmap.driver.IBuffer#interchangeBands(int[])
|
361 |
*/
|
362 |
public void interchangeBands(int[] bands){ |
363 |
|
364 |
} |
365 |
|
366 |
/*
|
367 |
* (non-Javadoc)
|
368 |
* @see org.gvsig.fmap.driver.IBuffer#mallocOneBand(int, int, int, int)
|
369 |
*/
|
370 |
public void mallocOneBand(int dataType, int width, int height, int band) { |
371 |
|
372 |
} |
373 |
|
374 |
/*
|
375 |
* (non-Javadoc)
|
376 |
* @see org.gvsig.fmap.driver.IBuffer#copyBand(int, org.gvsig.fmap.dataaccess.buffer.IBand)
|
377 |
*/
|
378 |
public void copyBand(int nBand, IBand band) { |
379 |
|
380 |
} |
381 |
|
382 |
/*
|
383 |
* (non-Javadoc)
|
384 |
* @see org.gvsig.fmap.driver.IBuffer#assignBand(int, org.gvsig.fmap.dataaccess.buffer.IBand)
|
385 |
*/
|
386 |
public void assignBand(int nBand, IBand band) { |
387 |
|
388 |
} |
389 |
|
390 |
/*
|
391 |
* (non-Javadoc)
|
392 |
* @see org.gvsig.fmap.driver.IBuffer#createBand(byte)
|
393 |
*/
|
394 |
public IBand createBand(byte defaultValue) { |
395 |
|
396 |
return null; |
397 |
} |
398 |
|
399 |
/*
|
400 |
* (non-Javadoc)
|
401 |
* @see org.gvsig.fmap.driver.IBuffer#assignBandToNotValid(int)
|
402 |
*/
|
403 |
public void assignBandToNotValid(int iBand) { |
404 |
|
405 |
} |
406 |
|
407 |
} |