gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / buffer / RasterBuffer.java @ 1029
History | View | Annotate | Download (20.1 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.impl.buffer; |
23 |
|
24 |
import java.awt.geom.Rectangle2D; |
25 |
|
26 |
import org.gvsig.fmap.dal.DataStore; |
27 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
28 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
29 |
import org.gvsig.fmap.dal.coverage.exception.HistogramException; |
30 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
31 |
import org.gvsig.fmap.dal.coverage.process.IncrementableTask; |
32 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
33 |
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer; |
34 |
import org.gvsig.raster.impl.process.RasterTask; |
35 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
36 |
import org.gvsig.tools.exception.BaseException; |
37 |
import org.gvsig.tools.visitor.Visitor; |
38 |
|
39 |
/**
|
40 |
* Rectangulo de pixeles. Para cada tipo de datos java hay un buffer distinto donde cada elemento es
|
41 |
* accedido de la siguiente forma: [banda][fila][columna]
|
42 |
* m[1][2][0] = cte;-> Sustituye el elemento de la fila 2 de la banda 1 columna 0
|
43 |
* m[1][0] = array; -> Sustituye la fila 0 de la banda 1
|
44 |
* m[0] = matriz cuadrada; -> Sustituye la banda entera.
|
45 |
*
|
46 |
*/
|
47 |
public abstract class RasterBuffer implements Buffer { |
48 |
public static final int INTERPOLATION_PROCESS = 0; |
49 |
|
50 |
protected boolean[] cancel = new boolean[1]; |
51 |
public NoData noDataValue = null; |
52 |
protected int progressInterpolation = 0; |
53 |
protected boolean canceled = false; |
54 |
|
55 |
protected int width; |
56 |
protected int height; |
57 |
protected int nBands; |
58 |
protected int dataType; |
59 |
private Rectangle2D dataExtent = null; |
60 |
/**
|
61 |
* Reference to the parent RasterDataStore
|
62 |
*/
|
63 |
private RasterDataStore store = null; |
64 |
|
65 |
/**
|
66 |
* Variable est?tica que si est? a false desactiva el uso de cach?. Puede ser usada por un cliente
|
67 |
* para cargar siempre los datos en memoria. independientemente de su tama?o.
|
68 |
*/
|
69 |
public static boolean cacheOn = true; |
70 |
/**
|
71 |
* Fuerza la carga de los datos en cach? independientemente de su tama?o. Su
|
72 |
* uso suele ser util solo para depuraci?n. Su valor por defecto y recomendado
|
73 |
* es siempre false.
|
74 |
*/
|
75 |
public static boolean forceToLoadInCache = false; |
76 |
/**
|
77 |
* Fuerza la carga de los datos en cach? de solo lectura independientemente de su tama?o. Su
|
78 |
* uso suele ser util solo para depuraci?n. Su valor por defecto y recomendado
|
79 |
* es siempre false.
|
80 |
*/
|
81 |
public static boolean forceToLoadInReadOnlyCache = false; |
82 |
/**
|
83 |
* Valor con el que se rellena una banda no valida del buffer. Una banda no valida es la que
|
84 |
* no tiene datos asignados y tampoco puede ser null. Todas las bandas no validas de un buffer
|
85 |
* apuntan por referencia a la misma banda.
|
86 |
*/
|
87 |
protected double notValidValue = 0D; |
88 |
|
89 |
private BufferInterpolation interp = null; |
90 |
|
91 |
/**
|
92 |
* Proceso del cual se devuelve el porcentaje cuando este es solicitado
|
93 |
*/
|
94 |
private int process = INTERPOLATION_PROCESS; |
95 |
private HistogramComputer histogramComputer = null; |
96 |
|
97 |
/*
|
98 |
* (non-Javadoc)
|
99 |
* @see org.gvsig.fmap.dal.coverage.dataset.Buffer#getStore()
|
100 |
*/
|
101 |
public RasterDataStore getStore() {
|
102 |
return store;
|
103 |
} |
104 |
|
105 |
/*
|
106 |
* (non-Javadoc)
|
107 |
* @see org.gvsig.fmap.dal.coverage.dataset.Buffer#setStore(org.gvsig.fmap.dal.coverage.store.RasterDataStore)
|
108 |
*/
|
109 |
public void setStore(RasterDataStore store) { |
110 |
this.store = store;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* Reserva de memoria para el rasterbuf
|
115 |
* @param dataType Tipo de dato
|
116 |
* @param width Ancho
|
117 |
* @param height Alto
|
118 |
* @param bandNr Numero de bandas
|
119 |
* @param orig
|
120 |
*/
|
121 |
public abstract void malloc(int dataType, int width, int height, int bandNr); |
122 |
|
123 |
/*
|
124 |
* (non-Javadoc)
|
125 |
* @see org.gvsig.fmap.driver.Buffer#getWidth()
|
126 |
*/
|
127 |
public int getWidth() { |
128 |
return width;
|
129 |
} |
130 |
|
131 |
/**
|
132 |
* Gets a bouding box of this buffer
|
133 |
* @return
|
134 |
*/
|
135 |
public Rectangle2D getDataExtent() { |
136 |
return dataExtent;
|
137 |
} |
138 |
|
139 |
/**
|
140 |
* Sets a bounding box of this buffer
|
141 |
* @param r
|
142 |
*/
|
143 |
public void setDataExtent(Rectangle2D r) { |
144 |
this.dataExtent = r;
|
145 |
} |
146 |
|
147 |
/*
|
148 |
* (non-Javadoc)
|
149 |
* @see org.gvsig.fmap.driver.Buffer#getHeight()
|
150 |
*/
|
151 |
public int getHeight() { |
152 |
return height;
|
153 |
} |
154 |
|
155 |
/*
|
156 |
* (non-Javadoc)
|
157 |
* @see org.gvsig.fmap.driver.Buffer#getBandCount()
|
158 |
*/
|
159 |
public int getBandCount() { |
160 |
return nBands;
|
161 |
} |
162 |
|
163 |
/**
|
164 |
* Obtiene el tipo de dato. Los tipos de dato posibles est?n definidos en IRaster.
|
165 |
* @return tipo de datos
|
166 |
*/
|
167 |
public int getDataType() { |
168 |
return dataType;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* Asigna el tipo de dato. Los tipos de dato posibles est?n definidos en IRaster.
|
173 |
* @param dataType Tipo de dato del buffer
|
174 |
*/
|
175 |
public void setDataType(int dataType) { |
176 |
this.dataType = dataType;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* Obtiene el tama?o del tipo de dato en bytes
|
181 |
* @return Tipo de dato
|
182 |
*/
|
183 |
public int getDataSize() { |
184 |
if (dataType == TYPE_BYTE) {
|
185 |
return 1; |
186 |
} else if ((dataType == TYPE_SHORT) | (dataType == TYPE_USHORT)) { |
187 |
return 2; |
188 |
} else if (dataType == TYPE_INT) { |
189 |
return 4; |
190 |
}else if (dataType == TYPE_FLOAT) { |
191 |
return 8; |
192 |
}else if (dataType == TYPE_DOUBLE) { |
193 |
return 16; |
194 |
} |
195 |
|
196 |
return 0; |
197 |
} |
198 |
|
199 |
/**
|
200 |
* Obtiene el tama?o del buffer
|
201 |
* @return tama?o del buffer
|
202 |
*/
|
203 |
public long sizeof() { |
204 |
return getDataSize() * width * height * nBands;
|
205 |
} |
206 |
|
207 |
/**
|
208 |
* Replica la banda de una posici?n sobre otra. Si la banda de destino no existe
|
209 |
* se crea nueva. Si la posici?n de la banda de destino est? intercalada entre bandas
|
210 |
* que ya existen las otras se desplazan hacia abajo, NO se machacan los datos de ninguna.
|
211 |
* Los datos se replican por referencia por lo que al modificar la banda original las
|
212 |
* del resto quedar?n afectadas.
|
213 |
* @param orig. Posici?n de la banda de origen.
|
214 |
* @param dest. Posici?n de la banda destino
|
215 |
*/
|
216 |
public abstract void replicateBand(int orig, int dest); |
217 |
|
218 |
/**
|
219 |
* Cambia bandas de posici?n. Las posiciones deben existir como bandas del raster.
|
220 |
* Cada elemento del array representa una banda existente en el buffer (de longitud
|
221 |
* rasterBuf.length) y el valor contenido dentro la banda que le corresponde. Por ejemplo
|
222 |
* si pasamos un array {1, 0, 3, 2} significa que el buffer tiene cuatro bandas y que
|
223 |
* cambiamos la 0 por la 1 y la 2 por la 3. Un array {0, 1, 2, 3} en el mismo
|
224 |
* caso no producir?a nig?n cambio.
|
225 |
*
|
226 |
* Si quisieramos asignar en un buffer monobanda su banda a la segunda posici?n habria
|
227 |
* que insertar una vacia, por ejemplo con addBandFloat(0, null) se insertaria una
|
228 |
* banda nula en la posici?n 0 y la banda que estaba en la 0 pasar?a a la segunda.
|
229 |
*
|
230 |
*/
|
231 |
public abstract void switchBands(int[] bandPosition); |
232 |
|
233 |
/**
|
234 |
* Convierte un tipo de dato a cadena
|
235 |
* @param type Tipo de dato
|
236 |
* @return cadena que representa el tipo de dato
|
237 |
*/
|
238 |
public static String typesToString(int type) { |
239 |
switch (type) {
|
240 |
case RasterBuffer.TYPE_IMAGE:
|
241 |
return new String("Image"); |
242 |
|
243 |
case RasterBuffer.TYPE_BYTE:
|
244 |
return new String("Byte"); |
245 |
|
246 |
case RasterBuffer.TYPE_DOUBLE:
|
247 |
return new String("Double"); |
248 |
|
249 |
case RasterBuffer.TYPE_FLOAT:
|
250 |
return new String("Float"); |
251 |
|
252 |
case RasterBuffer.TYPE_INT:
|
253 |
return new String("Integer"); |
254 |
|
255 |
case RasterBuffer.TYPE_USHORT:
|
256 |
case RasterBuffer.TYPE_SHORT:
|
257 |
return new String("Short"); |
258 |
} |
259 |
|
260 |
return null; |
261 |
} |
262 |
|
263 |
/*
|
264 |
* (non-Javadoc)
|
265 |
* @see org.gvsig.raster.dataset.Buffer#isInside(int, int)
|
266 |
*/
|
267 |
public boolean isInside(int x, int y) { |
268 |
if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight()) |
269 |
return false; |
270 |
return true; |
271 |
} |
272 |
|
273 |
/*
|
274 |
* (non-Javadoc)
|
275 |
* @see org.gvsig.fmap.dal.coverage.dataset.Buffer#getNoDataValue()
|
276 |
*/
|
277 |
public NoData getNoDataValue() {
|
278 |
return noDataValue;
|
279 |
} |
280 |
|
281 |
/*
|
282 |
* (non-Javadoc)
|
283 |
* @see org.gvsig.fmap.dal.coverage.dataset.Buffer#setNoDataValue(org.gvsig.fmap.dal.coverage.datastruct.NoData)
|
284 |
*/
|
285 |
public void setNoDataValue(NoData nd){ |
286 |
noDataValue = nd; |
287 |
} |
288 |
|
289 |
/*
|
290 |
* (non-Javadoc)
|
291 |
* @see org.gvsig.fmap.driver.Buffer#getNotValidValue()
|
292 |
*/
|
293 |
public double getNotValidValue(){ |
294 |
return notValidValue;
|
295 |
} |
296 |
|
297 |
/*
|
298 |
* (non-Javadoc)
|
299 |
* @see org.gvsig.fmap.driver.Buffer#setNotValidValue(java.lang.Object)
|
300 |
*/
|
301 |
public void setNotValidValue(double value){ |
302 |
this.notValidValue = value;
|
303 |
} |
304 |
|
305 |
/*
|
306 |
* (non-Javadoc)
|
307 |
* @see org.gvsig.fmap.driver.Buffer#cloneBuffer()
|
308 |
*/
|
309 |
public abstract Buffer cloneBuffer(); |
310 |
|
311 |
/**
|
312 |
* Ajusta el ?rea del grid a un ancho y un alto dado en pixeles. Este ajuste se har?
|
313 |
* en relaci?n a un m?todo de interpolaci?n definido en el par?metro.
|
314 |
* @param w Ancho de la nueva imagen.
|
315 |
* @param h Alto de la nueva imagen.
|
316 |
* @param interpolation M?todo de interpolaci?n que se usar? en el ajuste.
|
317 |
*/
|
318 |
public Buffer getAdjustedWindow(int w, int h, int interpolationMethod) throws ProcessInterruptedException { |
319 |
if (interp == null) |
320 |
interp = new BufferInterpolation(this); |
321 |
|
322 |
if (w == getWidth() && h == getHeight())
|
323 |
return this; |
324 |
Buffer rasterBuf = null; |
325 |
switch (interpolationMethod) {
|
326 |
case Buffer.INTERPOLATION_NearestNeighbour: |
327 |
rasterBuf = interp.adjustRasterNearestNeighbourInterpolation(w, h); |
328 |
break;
|
329 |
case Buffer.INTERPOLATION_Bilinear: |
330 |
rasterBuf = interp.adjustRasterBilinearInterpolation(w, h); |
331 |
break;
|
332 |
case Buffer.INTERPOLATION_InverseDistance: |
333 |
rasterBuf = interp.adjustRasterInverseDistanceInterpolation(w, h); |
334 |
break;
|
335 |
case Buffer.INTERPOLATION_BicubicSpline: |
336 |
rasterBuf = interp.adjustRasterBicubicSplineInterpolation(w, h); |
337 |
break;
|
338 |
case Buffer.INTERPOLATION_BSpline: |
339 |
rasterBuf = interp.adjustRasterBSplineInterpolation(w, h); |
340 |
break;
|
341 |
} |
342 |
if (rasterBuf != null) |
343 |
return rasterBuf;
|
344 |
else
|
345 |
return this; |
346 |
} |
347 |
|
348 |
/*
|
349 |
* (non-Javadoc)
|
350 |
* @see org.gvsig.fmap.dal.coverage.dataset.Buffer#getIncrementableTask()
|
351 |
*/
|
352 |
public IncrementableTask getIncrementableTask() {
|
353 |
return interp;
|
354 |
} |
355 |
|
356 |
public BufferInterpolation getLastInterpolation() {
|
357 |
return interp;
|
358 |
} |
359 |
|
360 |
/*
|
361 |
* (non-Javadoc)
|
362 |
* @see org.gvsig.fmap.dal.coverage.store.props.Histogramable#getHistogramComputer()
|
363 |
*/
|
364 |
public HistogramComputer getHistogramComputer()
|
365 |
throws HistogramException, InterruptedException { |
366 |
if(histogramComputer == null) |
367 |
histogramComputer = new BufferHistogramComputer(this); |
368 |
return histogramComputer;
|
369 |
} |
370 |
|
371 |
/*
|
372 |
* (non-Javadoc)
|
373 |
* @see org.gvsig.raster.dataset.Buffer#getLimits()
|
374 |
*/
|
375 |
public double[] getLimits() throws ProcessInterruptedException { |
376 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().toString());
|
377 |
double max = Double.NEGATIVE_INFINITY; |
378 |
double secondMax = max;
|
379 |
double min = Double.MAX_VALUE; |
380 |
double secondMin = min;
|
381 |
double value = 0; |
382 |
|
383 |
switch (getDataType()) {
|
384 |
case Buffer.TYPE_BYTE: |
385 |
for (int i = 0; i < getBandCount(); i++) |
386 |
for (int r = 0; r < getHeight(); r++) { |
387 |
for (int c = 0; c < getWidth(); c++) { |
388 |
value = (double) ((getElemByte(r, c, i)));
|
389 |
if (value > max) {
|
390 |
if (max != value) secondMax = max;
|
391 |
max = value; |
392 |
} |
393 |
if (value < min) {
|
394 |
if (min != value) secondMin = min;
|
395 |
min = value; |
396 |
} |
397 |
} |
398 |
if (task.getEvent() != null) |
399 |
task.manageEvent(task.getEvent()); |
400 |
} |
401 |
break;
|
402 |
case Buffer.TYPE_SHORT: |
403 |
for (int i = 0; i < getBandCount(); i++) |
404 |
for (int r = 0; r < getHeight(); r++) { |
405 |
for (int c = 0; c < getWidth(); c++) { |
406 |
value = (double) getElemShort(r, c, i);
|
407 |
if (value > max) {
|
408 |
if (max != value) secondMax = max;
|
409 |
max = value; |
410 |
} |
411 |
if (value < min) {
|
412 |
if (min != value) secondMin = min;
|
413 |
min = value; |
414 |
} |
415 |
} |
416 |
if (task.getEvent() != null) |
417 |
task.manageEvent(task.getEvent()); |
418 |
} |
419 |
break;
|
420 |
case Buffer.TYPE_INT: |
421 |
for (int i = 0; i < getBandCount(); i++) |
422 |
for (int r = 0; r < getHeight(); r++) { |
423 |
for (int c = 0; c < getWidth(); c++) { |
424 |
value = (double) getElemInt(r, c, i);
|
425 |
if (value > max) {
|
426 |
if (max != value) secondMax = max;
|
427 |
max = value; |
428 |
} |
429 |
if (value < min) {
|
430 |
if (min != value) secondMin = min;
|
431 |
min = value; |
432 |
} |
433 |
} |
434 |
if (task.getEvent() != null) |
435 |
task.manageEvent(task.getEvent()); |
436 |
} |
437 |
break;
|
438 |
case Buffer.TYPE_FLOAT: |
439 |
for (int i = 0; i < getBandCount(); i++) |
440 |
for (int r = 0; r < getHeight(); r++) { |
441 |
for (int c = 0; c < getWidth(); c++) { |
442 |
value = (double) getElemFloat(r, c, i);
|
443 |
if (value > max) {
|
444 |
if (max != value) secondMax = max;
|
445 |
max = value; |
446 |
} |
447 |
if (value < min) {
|
448 |
if (min != value) secondMin = min;
|
449 |
min = value; |
450 |
} |
451 |
} |
452 |
if (task.getEvent() != null) |
453 |
task.manageEvent(task.getEvent()); |
454 |
} |
455 |
break;
|
456 |
case Buffer.TYPE_DOUBLE: |
457 |
for (int i = 0; i < getBandCount(); i++) |
458 |
for (int r = 0; r < getHeight(); r++) { |
459 |
for (int c = 0; c < getWidth(); c++) { |
460 |
value = getElemDouble(r, c, i); |
461 |
if (value > max) {
|
462 |
if (max != value) secondMax = max;
|
463 |
max = value; |
464 |
} |
465 |
if (value < min) {
|
466 |
if (min != value) secondMin = min;
|
467 |
min = value; |
468 |
} |
469 |
} |
470 |
if (task.getEvent() != null) |
471 |
task.manageEvent(task.getEvent()); |
472 |
} |
473 |
break;
|
474 |
} |
475 |
// Si no existe un secondMax lo igualo al maximo existente
|
476 |
if (secondMax == Double.NEGATIVE_INFINITY) |
477 |
secondMax = max; |
478 |
// Si no existe un secondMin lo igualo al minimo existente
|
479 |
if (secondMin == Double.MAX_VALUE) |
480 |
secondMin = min; |
481 |
|
482 |
double[] values = new double[4]; |
483 |
values[0] = min;
|
484 |
values[1] = max;
|
485 |
values[2] = secondMin;
|
486 |
values[3] = secondMax;
|
487 |
return values;
|
488 |
} |
489 |
|
490 |
/*
|
491 |
* (non-Javadoc)
|
492 |
* @see org.gvsig.raster.dataset.Buffer#getLimits()
|
493 |
*/
|
494 |
public double[][] getAllBandsLimits() throws ProcessInterruptedException { |
495 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().toString());
|
496 |
double max[] = new double[getBandCount()]; |
497 |
double min[] = new double[getBandCount()]; |
498 |
double value = 0; |
499 |
|
500 |
for (int i = 0; i < getBandCount(); i++) { |
501 |
max[i] = Double.NEGATIVE_INFINITY;
|
502 |
min[i] = Double.MAX_VALUE;
|
503 |
} |
504 |
|
505 |
switch (getDataType()) {
|
506 |
case Buffer.TYPE_BYTE: |
507 |
for (int i = 0; i < getBandCount(); i++) { |
508 |
for (int r = 0; r < getHeight(); r++) { |
509 |
for (int c = 0; c < getWidth(); c++) { |
510 |
value = (double) ((getElemByte(r, c, i)));
|
511 |
if (value > max[i])
|
512 |
max[i] = value; |
513 |
if (value < min[i])
|
514 |
min[i] = value; |
515 |
} |
516 |
if (task.getEvent() != null) |
517 |
task.manageEvent(task.getEvent()); |
518 |
} |
519 |
} |
520 |
break;
|
521 |
case Buffer.TYPE_SHORT: |
522 |
for (int i = 0; i < getBandCount(); i++) { |
523 |
for (int r = 0; r < getHeight(); r++) { |
524 |
for (int c = 0; c < getWidth(); c++) { |
525 |
value = (double) getElemShort(r, c, i);
|
526 |
if (value > max[i])
|
527 |
max[i] = value; |
528 |
if (value < min[i])
|
529 |
min[i] = value; |
530 |
} |
531 |
if (task.getEvent() != null) |
532 |
task.manageEvent(task.getEvent()); |
533 |
} |
534 |
} |
535 |
break;
|
536 |
case Buffer.TYPE_INT: |
537 |
for (int i = 0; i < getBandCount(); i++) { |
538 |
for (int r = 0; r < getHeight(); r++) { |
539 |
for (int c = 0; c < getWidth(); c++) { |
540 |
value = (double) getElemInt(r, c, i);
|
541 |
if (value > max[i])
|
542 |
max[i] = value; |
543 |
if (value < min[i])
|
544 |
min[i] = value; |
545 |
} |
546 |
if (task.getEvent() != null) |
547 |
task.manageEvent(task.getEvent()); |
548 |
} |
549 |
} |
550 |
break;
|
551 |
case Buffer.TYPE_FLOAT: |
552 |
for (int i = 0; i < getBandCount(); i++) { |
553 |
for (int r = 0; r < getHeight(); r++) { |
554 |
for (int c = 0; c < getWidth(); c++) { |
555 |
value = (double) getElemFloat(r, c, i);
|
556 |
if (value > max[i])
|
557 |
max[i] = value; |
558 |
if (value < min[i])
|
559 |
min[i] = value; |
560 |
} |
561 |
if (task.getEvent() != null) |
562 |
task.manageEvent(task.getEvent()); |
563 |
} |
564 |
} |
565 |
break;
|
566 |
case Buffer.TYPE_DOUBLE: |
567 |
for (int i = 0; i < getBandCount(); i++) { |
568 |
for (int r = 0; r < getHeight(); r++) { |
569 |
for (int c = 0; c < getWidth(); c++) { |
570 |
value = getElemDouble(r, c, i); |
571 |
if (value > max[i])
|
572 |
max[i] = value; |
573 |
if (value < min[i])
|
574 |
min[i] = value; |
575 |
} |
576 |
if (task.getEvent() != null) |
577 |
task.manageEvent(task.getEvent()); |
578 |
} |
579 |
} |
580 |
break;
|
581 |
} |
582 |
double[][] values = new double[2][getBandCount()]; |
583 |
|
584 |
for (int i = 0; i < getBandCount(); i++) { |
585 |
values[0][i] = min[i];
|
586 |
values[1][i] = max[i];
|
587 |
} |
588 |
return values;
|
589 |
} |
590 |
|
591 |
/*
|
592 |
* (non-Javadoc)
|
593 |
* @see org.gvsig.fmap.dal.coverage.dataset.Buffer#addDrawableBands(int[])
|
594 |
*/
|
595 |
public void addDrawableBands(int[] db) { |
596 |
|
597 |
} |
598 |
|
599 |
/*
|
600 |
* (non-Javadoc)
|
601 |
* @see org.gvsig.raster.util.IHistogramable#resetPercent()
|
602 |
*/
|
603 |
public void resetPercent() { |
604 |
switch(process) {
|
605 |
case INTERPOLATION_PROCESS: progressInterpolation = 0; |
606 |
} |
607 |
} |
608 |
|
609 |
/*
|
610 |
* (non-Javadoc)
|
611 |
* @see org.gvsig.raster.util.IHistogramable#getPercent()
|
612 |
*/
|
613 |
public int getPercent() { |
614 |
switch(process) {
|
615 |
case INTERPOLATION_PROCESS: return progressInterpolation; |
616 |
} |
617 |
return 0; |
618 |
} |
619 |
|
620 |
/**
|
621 |
* Asigna el proceso del cual se desea obtener informaci?n. Los procesos
|
622 |
* disponibles se definen como constantes en esta clase.
|
623 |
* @param process
|
624 |
*/
|
625 |
public void setProcess(int process) { |
626 |
this.process = process;
|
627 |
} |
628 |
|
629 |
/*
|
630 |
* (non-Javadoc)
|
631 |
* @see org.gvsig.fmap.dal.coverage.dataset.Buffer#isCached()
|
632 |
*/
|
633 |
public boolean isCached() { |
634 |
return false; |
635 |
} |
636 |
|
637 |
//****************************************************
|
638 |
//*********Implementing DataSet methods***************
|
639 |
//****************************************************
|
640 |
|
641 |
/*
|
642 |
* (non-Javadoc)
|
643 |
* @see org.gvsig.fmap.dal.DataSet#isFromStore(org.gvsig.fmap.dal.DataStore)
|
644 |
*/
|
645 |
public boolean isFromStore(DataStore store) { |
646 |
return store == this.store; |
647 |
} |
648 |
|
649 |
//****************************************************
|
650 |
//*********Implementing Visitable methods*************
|
651 |
//****************************************************
|
652 |
|
653 |
/*
|
654 |
* (non-Javadoc)
|
655 |
* @see org.gvsig.tools.visitor.Visitable#accept(org.gvsig.tools.visitor.Visitor)
|
656 |
*/
|
657 |
public void accept(Visitor visitor) throws BaseException { |
658 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().toString());
|
659 |
|
660 |
switch (getDataType()) {
|
661 |
case Buffer.TYPE_BYTE: |
662 |
for (int i = 0; i < getBandCount(); i++) { |
663 |
for (int r = 0; r < getHeight(); r++) { |
664 |
for (int c = 0; c < getWidth(); c++) |
665 |
visitor.visit(getElemByte(r, c, i)); |
666 |
if (task.getEvent() != null) |
667 |
task.manageEvent(task.getEvent()); |
668 |
} |
669 |
} |
670 |
break;
|
671 |
case Buffer.TYPE_SHORT: |
672 |
for (int i = 0; i < getBandCount(); i++) { |
673 |
for (int r = 0; r < getHeight(); r++) { |
674 |
for (int c = 0; c < getWidth(); c++) |
675 |
visitor.visit(getElemShort(r, c, i)); |
676 |
if (task.getEvent() != null) |
677 |
task.manageEvent(task.getEvent()); |
678 |
} |
679 |
} |
680 |
break;
|
681 |
case Buffer.TYPE_INT: |
682 |
for (int i = 0; i < getBandCount(); i++) { |
683 |
for (int r = 0; r < getHeight(); r++) { |
684 |
for (int c = 0; c < getWidth(); c++) |
685 |
visitor.visit(getElemInt(r, c, i)); |
686 |
if (task.getEvent() != null) |
687 |
task.manageEvent(task.getEvent()); |
688 |
} |
689 |
} |
690 |
break;
|
691 |
case Buffer.TYPE_FLOAT: |
692 |
for (int i = 0; i < getBandCount(); i++) { |
693 |
for (int r = 0; r < getHeight(); r++) { |
694 |
for (int c = 0; c < getWidth(); c++) |
695 |
visitor.visit(getElemFloat(r, c, i)); |
696 |
if (task.getEvent() != null) |
697 |
task.manageEvent(task.getEvent()); |
698 |
} |
699 |
} |
700 |
break;
|
701 |
case Buffer.TYPE_DOUBLE: |
702 |
for (int i = 0; i < getBandCount(); i++) { |
703 |
for (int r = 0; r < getHeight(); r++) { |
704 |
for (int c = 0; c < getWidth(); c++) |
705 |
visitor.visit(getElemDouble(r, c, i)); |
706 |
if (task.getEvent() != null) |
707 |
task.manageEvent(task.getEvent()); |
708 |
} |
709 |
} |
710 |
break;
|
711 |
} |
712 |
} |
713 |
|
714 |
} |