root / trunk / libraries / libRaster / src / org / gvsig / raster / buffer / BufferFactory.java @ 11478
History | View | Annotate | Download (20.9 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.raster.buffer; |
20 |
|
21 |
|
22 |
import java.awt.geom.Point2D; |
23 |
|
24 |
import org.gvsig.raster.dataset.FileNotFoundInListException; |
25 |
import org.gvsig.raster.dataset.IBuffer; |
26 |
import org.gvsig.raster.dataset.InvalidSetViewException; |
27 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
28 |
import org.gvsig.raster.dataset.RasterDataset; |
29 |
import org.gvsig.raster.dataset.RasterDriverException; |
30 |
import org.gvsig.raster.dataset.MultiRasterDataset; |
31 |
import org.gvsig.raster.dataset.properties.DatasetPalette; |
32 |
import org.gvsig.raster.shared.Extent; |
33 |
import org.gvsig.raster.util.ICancellable; |
34 |
import org.gvsig.raster.util.RasterUtilities; |
35 |
|
36 |
/**
|
37 |
* <P>
|
38 |
* Clase que representa a una rejilla de datos que tiene como fuente
|
39 |
* un RasterMultifile. Tiene m?todos para a?adir nuevos ficheros fuente a la
|
40 |
* rejilla que podr?n ser consultados como bandas de uno solo. Estos deber?an tener
|
41 |
* la misma extensi?n que el primero introducido.
|
42 |
* </P>
|
43 |
* <P>
|
44 |
* Para la carga del buffer de datos habr? que asigna las bandas que queremos cargar
|
45 |
* de todas las disponibles con addDrawableBands. Despu?s se seleccionar? el ?rea
|
46 |
* que queremos cargar con setAreaOfInterest. Este ?rea se define con coordenadas
|
47 |
* pixel o reales. Finalmente podemos recuperar el buffer con los datos usando la
|
48 |
* funci?n getRasterBuf.
|
49 |
* </P>
|
50 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
51 |
*
|
52 |
*/
|
53 |
public class BufferFactory implements ICancellable { |
54 |
|
55 |
public static final int CANCEL_READ = 1; |
56 |
private boolean[] cancel = new boolean[1]; |
57 |
|
58 |
private MultiRasterDataset mDataset = new MultiRasterDataset(null); |
59 |
private IBuffer rasterBuf = null; |
60 |
private int width = 0; |
61 |
private int height = 0; |
62 |
private int[] drawableBands = null; |
63 |
/**
|
64 |
* Extensi?n de los datos del buffer
|
65 |
*/
|
66 |
private Extent dataExtent = null; |
67 |
/**
|
68 |
* Lista de paletas asociadas a las bandas cargadas en el DataSource. Estas son calculadas
|
69 |
* en las funciones que asignan las bandas a dibujar (addDrawableBands)
|
70 |
*/
|
71 |
private DatasetPalette[] palette = null; |
72 |
/**
|
73 |
* Activa o desactiva el supersampleo en la carga del buffer.
|
74 |
*/
|
75 |
private boolean supersamplingLoadingBuffer = true; |
76 |
|
77 |
/**
|
78 |
* Ancho y alto en pixeles del ?ltimo buffer asignado
|
79 |
*/
|
80 |
private double nWidth = 0; |
81 |
private double nHeight = 0; |
82 |
|
83 |
/**
|
84 |
* Constructor
|
85 |
*/
|
86 |
public BufferFactory() {}
|
87 |
|
88 |
/**
|
89 |
* Constructor
|
90 |
* @param MultiRasterDataset
|
91 |
*/
|
92 |
public BufferFactory(MultiRasterDataset rmd) {
|
93 |
mDataset = rmd; |
94 |
width = (int)rmd.getWidth()[0]; |
95 |
height = (int)rmd.getHeight()[0]; |
96 |
} |
97 |
|
98 |
/**
|
99 |
* Constructor
|
100 |
* @param grf Lista de geoRasterFile
|
101 |
*/
|
102 |
public BufferFactory(RasterDataset[] grf) { |
103 |
for(int i = 0; i< grf.length; i++) |
104 |
addFile(grf[i]); |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Constructor
|
109 |
* @param grf GeoRasterFile
|
110 |
*/
|
111 |
public BufferFactory(RasterDataset grf) {
|
112 |
addFile(grf); |
113 |
} |
114 |
|
115 |
/**
|
116 |
* A?ade un GeoRasterFile al Grid
|
117 |
* @param grf GeoRasterFile a a?adir
|
118 |
*/
|
119 |
public void addFile(RasterDataset grf) { |
120 |
try{
|
121 |
mDataset.addDataset(grf); |
122 |
width = grf.getWidth(); |
123 |
height = grf.getHeight(); |
124 |
}catch(FileNotFoundInListException e) {
|
125 |
//El fichero est? en la lista por lo que no lo a?adimos
|
126 |
} |
127 |
} |
128 |
|
129 |
/**
|
130 |
* A?ade un GeoRasterFile al Grid
|
131 |
* @param fileName Nombre del fichero a a?adir
|
132 |
* @throws NotSupportedExtensionException
|
133 |
* @throws RasterDriverException
|
134 |
*/
|
135 |
public void addFile(String filename) throws NotSupportedExtensionException, RasterDriverException{ |
136 |
try{
|
137 |
mDataset.addDataset(filename); |
138 |
width = (int)mDataset.getWidth()[0]; |
139 |
height = (int)mDataset.getHeight()[0]; |
140 |
}catch(FileNotFoundInListException e) {
|
141 |
//El fichero est? en la lista por lo que no lo a?adimos
|
142 |
} |
143 |
} |
144 |
|
145 |
/**
|
146 |
* Elimina un GeoRasterFile del Grid
|
147 |
* @param grf GeoRasterFile a eliminar
|
148 |
*/
|
149 |
public void removeFile(RasterDataset grf) { |
150 |
mDataset.removeDataset(grf); |
151 |
} |
152 |
|
153 |
/**
|
154 |
* Elimina un GeoRasterFile del Grid
|
155 |
* @param fileName Nombre del fichero a eliminar su GeoRasterFile
|
156 |
*/
|
157 |
public void removeFile(String fileName) { |
158 |
mDataset.removeDataset(fileName); |
159 |
} |
160 |
|
161 |
/**
|
162 |
* Obtiene el n?mero de ficheros del que est? compuesta la fuente de datos.
|
163 |
* @return
|
164 |
*/
|
165 |
public int getFileCount() { |
166 |
return mDataset.getDatasetCount();
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* Obtiene la estructura que contiene la lista de ficheros del Grid
|
171 |
* @return GeoRasterMultiFile
|
172 |
*/
|
173 |
public MultiRasterDataset getGeoRasterMultiFile() {
|
174 |
return mDataset;
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* Libera el buffer de memoria
|
179 |
*/
|
180 |
public void free() { |
181 |
rasterBuf = null;
|
182 |
System.gc();
|
183 |
} |
184 |
|
185 |
/**
|
186 |
* Resetea la asignaci?n de dibujado de las bandas de la imagen
|
187 |
* sobre el DataImage cuando se hace un update para esta banda.
|
188 |
*/
|
189 |
public void clearDrawableBand() { |
190 |
for(int i = 0; i < mDataset.getDatasetCount(); i++) |
191 |
mDataset.getBands().clearDrawableBand(); |
192 |
palette = null;
|
193 |
} |
194 |
|
195 |
/**
|
196 |
* Para este GeoRasterFile asigna que bandas se pintaran
|
197 |
* sobre el RasterBuf cuando se haga un update. Cada posici?n del vector es una banda
|
198 |
* del rasterBuf y el contenido de esa posici?n es la banda de la imagen que se dibujar?
|
199 |
* sobre ese RasterBuf.
|
200 |
* @param drawableBands Array con las bandas a dibujar.
|
201 |
* @return array con tantos elementos como bandas a dibujar. El valor contenido es el fichero del
|
202 |
* dataset multifichero al que corresponde la banda.
|
203 |
*/
|
204 |
public int[] addDrawableBands(int[] drawableBands) { |
205 |
this.drawableBands = drawableBands;
|
206 |
mDataset.getBands().setDrawableArray(drawableBands); |
207 |
|
208 |
int[] files = new int[drawableBands.length]; |
209 |
palette = new DatasetPalette[drawableBands.length];
|
210 |
|
211 |
for(int i = 0; i< drawableBands.length; i++) { |
212 |
if(drawableBands[i] < 0 || drawableBands[i] >= mDataset.getBandCount()) |
213 |
continue;
|
214 |
mDataset.getBands().addDrawableBand(i, drawableBands[i]); |
215 |
String fileName = mDataset.getBands().getBand(drawableBands[i]).getFileName();
|
216 |
files[i] = mDataset.getBands().getFileNumber(fileName); |
217 |
palette[i] = mDataset.getPalette(fileName); |
218 |
} |
219 |
return files;
|
220 |
} |
221 |
|
222 |
/**
|
223 |
* Para este GeoRasterFile asigna que bandas se pintaran
|
224 |
* sobre el RasterBuf cuando se haga un update. Cada posici?n del vector es una banda
|
225 |
* del rasterBuf y el contenido de esa posici?n es la banda de la imagen que se dibujar?
|
226 |
* sobre ese RasterBuf. Esta llamada asigna todas las bandas dibujables en su orden natural.
|
227 |
* @return array con tantos elementos como bandas a dibujar. El valor contenido es el fichero del
|
228 |
* dataset multifichero al que corresponde la banda.
|
229 |
*/
|
230 |
public int[] setAllDrawableBands() { |
231 |
clearDrawableBand(); |
232 |
drawableBands = new int[mDataset.getBandCount()]; |
233 |
int[] files = new int[drawableBands.length]; |
234 |
palette = new DatasetPalette[drawableBands.length];
|
235 |
|
236 |
for(int i = 0; i< mDataset.getBandCount(); i++) { |
237 |
mDataset.getBands().addDrawableBand(i, i); |
238 |
this.drawableBands[i] = i;
|
239 |
String fileName = mDataset.getBands().getBand(drawableBands[i]).getFileName();
|
240 |
files[i] = mDataset.getBands().getFileNumber(fileName); |
241 |
palette[i] = mDataset.getPalette(fileName); |
242 |
} |
243 |
return files;
|
244 |
} |
245 |
|
246 |
/**
|
247 |
* Obtiene el array que contiene el orden de bandas. Cada posici?n del vector es una banda
|
248 |
* del rasterBuf y el contenido de esa posici?n es la banda de la imagen que se dibujar?
|
249 |
* sobre ese RasterBuf.
|
250 |
* @return Array de enteros con el orden de las badas
|
251 |
*/
|
252 |
public int[] getDrawableBands() { |
253 |
return drawableBands;
|
254 |
} |
255 |
|
256 |
/**
|
257 |
* Asigna el ?rea de interes en coordenadas del mundo real. Si las coordenadas exceden del tama?o de la imagen
|
258 |
* estas coordenadas son ajustadas el extent.
|
259 |
* @param x Coordenada X, esquina superior izquierda
|
260 |
* @param y Coordenada Y, esquina superior izquierda
|
261 |
* @param w Ancho del ?rea
|
262 |
* @param h Alto del ?rea
|
263 |
* @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
|
264 |
* @throws ArrayIndexOutOfBoundsException
|
265 |
*/
|
266 |
public void setAreaOfInterest(double x, double y, double w, double h, boolean adjustToExtent) |
267 |
throws ArrayIndexOutOfBoundsException { |
268 |
dataExtent = new Extent(x, y, x + w, y - h);
|
269 |
if(adjustToExtent) {
|
270 |
Extent adjustedDataExtent = RasterUtilities.calculateAdjustedView(dataExtent, mDataset.getExtent()); |
271 |
double newW = w;
|
272 |
double newH = h;
|
273 |
if(!RasterUtilities.compareExtents(dataExtent, adjustedDataExtent)) {
|
274 |
//Si el extent ha sido ajustado entonces tenemos que variar tambi?n al ancho y el alto de la petici?n
|
275 |
newW = (adjustedDataExtent.width() * w) / dataExtent.width(); |
276 |
newH = (adjustedDataExtent.height() * h) / dataExtent.height(); |
277 |
} |
278 |
try {
|
279 |
rasterBuf = mDataset.getWindowRaster(adjustedDataExtent.getMin().getX(), adjustedDataExtent.getMax().getY(), newW, newH, adjustToExtent); |
280 |
} catch (InvalidSetViewException e) {
|
281 |
//Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
|
282 |
} |
283 |
} else {
|
284 |
try {
|
285 |
rasterBuf = mDataset.getWindowRaster(dataExtent.getMin().getX(), dataExtent.getMax().getY(), w, h, adjustToExtent); |
286 |
} catch (InvalidSetViewException e) {
|
287 |
//Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
|
288 |
} |
289 |
} |
290 |
} |
291 |
|
292 |
/**
|
293 |
* Asigna el ?rea de interes en coordenadas del mundo real. Si las coordenadas exceden del tama?o de la imagen
|
294 |
* estas coordenadas son ajustadas el extent.
|
295 |
* @param x Coordenada X, esquina superior izquierda
|
296 |
* @param y Coordenada Y, esquina superior izquierda
|
297 |
* @param w Ancho del ?rea
|
298 |
* @param h Alto del ?rea
|
299 |
* @param bufWidth Ancho del buffer
|
300 |
* @param bufHeight Alto del buffer
|
301 |
* @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
|
302 |
* @return En caso de que el buffer sea mayor que el tama?o seleccionado de raster se produce supersampleo. La funci?n devuelve
|
303 |
* un array de dos elementos que representan el desplazamiento en pixels de X e Y de la esquina superior izquierda.
|
304 |
* @throws ArrayIndexOutOfBoundsException
|
305 |
*/
|
306 |
public int[] setAreaOfInterest(double minX, double minY, double maxX, double maxY, int bufWidth, int bufHeight, boolean adjustToExtent) |
307 |
throws ArrayIndexOutOfBoundsException { |
308 |
//TODO: VALIDACI?N: Comprobaci?n de exceso de memoria reservada
|
309 |
dataExtent = new Extent(minX, minY, maxX, maxY);
|
310 |
Extent adjustedDataExtent = new Extent(dataExtent);
|
311 |
if(adjustToExtent)
|
312 |
adjustedDataExtent = RasterUtilities.calculateAdjustedView(dataExtent, mDataset.getExtent()); |
313 |
|
314 |
minX = adjustedDataExtent.getMin().getX(); |
315 |
minY = adjustedDataExtent.getMin().getY(); |
316 |
maxX = adjustedDataExtent.getMax().getX(); |
317 |
maxY = adjustedDataExtent.getMax().getY(); |
318 |
|
319 |
//Esta secci?n es para que no supersamplee el driver y pueda hacerse en el cliente
|
320 |
if(!isSupersamplingLoadingBuffer()) {
|
321 |
nWidth = ((adjustedDataExtent.width() * mDataset.getDataset(0).getWidth()) / mDataset.getDataset(0).getExtent().width()); |
322 |
nHeight = ((adjustedDataExtent.height() * mDataset.getDataset(0).getHeight()) / mDataset.getDataset(0).getExtent().height()); |
323 |
|
324 |
if(bufWidth > Math.ceil(nWidth) && bufHeight > Math.ceil(nHeight)) { |
325 |
try {
|
326 |
rasterBuf = mDataset.getWindowRaster(minX, maxY, Math.abs(maxX - minX), Math.abs(maxY - minY), adjustToExtent); |
327 |
} catch (InvalidSetViewException e) {
|
328 |
//Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
|
329 |
} |
330 |
int[] step = mDataset.calcSteps(minX, maxY, maxX, minY, nWidth, nHeight, bufWidth, bufHeight); |
331 |
return step;
|
332 |
} |
333 |
} |
334 |
|
335 |
try {
|
336 |
rasterBuf = mDataset.getWindowRaster(minX, minY, maxX, maxY, bufWidth, bufHeight, adjustToExtent); |
337 |
} catch (InvalidSetViewException e) {
|
338 |
//Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
|
339 |
} |
340 |
return null; |
341 |
} |
342 |
|
343 |
/**
|
344 |
* Asigna el ?rea de interes en coordenadas pixel. Si las coordenadas exceden del tama?o de la imagen
|
345 |
* lanza una excepci?n.
|
346 |
* @param x Coordenada X, esquina superior izquierda
|
347 |
* @param y Coordenada Y, esquina superior izquierda
|
348 |
* @param w Ancho del ?rea
|
349 |
* @param h Alto del ?rea
|
350 |
* @throws ArrayIndexOutOfBoundsException
|
351 |
*/
|
352 |
public void setAreaOfInterest(int x, int y, int w, int h){ |
353 |
x = (x < 0) ? 0 : x; |
354 |
y = (y < 0) ? 0 : y; |
355 |
w = (w > getWidth()) ? getWidth() : w; |
356 |
h = (w > getHeight()) ? getHeight() : h; |
357 |
|
358 |
dataExtent = new Extent(mDataset.rasterToWorld(new Point2D.Double(x, y)), |
359 |
mDataset.rasterToWorld(new Point2D.Double(x + w, y + h))); |
360 |
try {
|
361 |
rasterBuf = mDataset.getWindowRaster(x, y, w, h); |
362 |
} catch (InvalidSetViewException e) {
|
363 |
//Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
|
364 |
} |
365 |
} |
366 |
|
367 |
/**
|
368 |
* Asigna el ?rea de inter?s a toda la extensi?n del raster.
|
369 |
*/
|
370 |
public void setAreaOfInterest() throws InvalidSetViewException { |
371 |
dataExtent = mDataset.getExtent(); |
372 |
rasterBuf = mDataset.getWindowRaster(0, 0, (int)mDataset.getWidth()[0], (int)mDataset.getHeight()[0]); |
373 |
} |
374 |
|
375 |
/**
|
376 |
* Asigna el ?rea de interes en coordenadas pixel. Esta operaci?n cargar? un RasterBuffer con los datos solicitados por
|
377 |
* lo que, si al acabar hacemos getRasterBuf obtendremos la matriz de datos. Si las coordenadas exceden del tama?o
|
378 |
* de la imagen lanza una excepci?n.
|
379 |
* @param x Coordenada X, esquina superior izquierda
|
380 |
* @param y Coordenada Y, esquina superior izquierda
|
381 |
* @param w Ancho del ?rea
|
382 |
* @param h Alto del ?rea
|
383 |
* @param bufWidth Ancho del buffer
|
384 |
* @param bufHeight Alto del buffer
|
385 |
* @throws ArrayIndexOutOfBoundsException
|
386 |
*/
|
387 |
public void setAreaOfInterest(int x, int y, int w, int h, int bufWidth, int bufHeight) |
388 |
throws InvalidSetViewException {
|
389 |
//TODO: VALIDACI?N: Comprobaci?n de exceso de memoria reservada
|
390 |
x = (x < 0) ? 0 : x; |
391 |
y = (y < 0) ? 0 : y; |
392 |
w = (w > getWidth()) ? getWidth() : w; |
393 |
h = (w > getHeight()) ? getHeight() : h; |
394 |
|
395 |
dataExtent = new Extent(mDataset.rasterToWorld(new Point2D.Double(x, y)), |
396 |
mDataset.rasterToWorld(new Point2D.Double(x + w, y + h))); |
397 |
|
398 |
rasterBuf = mDataset.getWindowRaster(x, y, w, h, bufWidth, bufHeight); |
399 |
} |
400 |
|
401 |
/**
|
402 |
* Obtiene el tipo de datos del grid.
|
403 |
* @return entero que representa el tipo de dato de las celdas del grid.
|
404 |
*/
|
405 |
public int getDataType() { |
406 |
return mDataset.getDataType()[0]; |
407 |
} |
408 |
|
409 |
/**
|
410 |
* Obtiene la altura del grid.
|
411 |
* @return altura en celdas del grid.
|
412 |
*/
|
413 |
public int getHeight() { |
414 |
return height;
|
415 |
} |
416 |
|
417 |
/**
|
418 |
* Obtiene la anchura del grid.
|
419 |
* @return anchura en celdas del grid.
|
420 |
*/
|
421 |
public int getWidth() { |
422 |
return width;
|
423 |
} |
424 |
|
425 |
/**
|
426 |
* Tama?o de celda en X
|
427 |
* @return
|
428 |
*/
|
429 |
public double getXCellSize() { |
430 |
|
431 |
Extent e = mDataset.getExtent(); |
432 |
double dCellsize = (e.getMax().getX() - e.getMin().getX() ) / (double) width; |
433 |
|
434 |
return dCellsize;
|
435 |
|
436 |
} |
437 |
|
438 |
/**
|
439 |
* Tama?o de celda en Y
|
440 |
* @return
|
441 |
*/
|
442 |
public double getYCellSize() { |
443 |
|
444 |
return 0; |
445 |
} |
446 |
|
447 |
/**
|
448 |
* Devuelve true si la celda contiene un valor de NODATA
|
449 |
* @param x coordenada X
|
450 |
* @param y coordenada Y
|
451 |
* @return
|
452 |
*/
|
453 |
public boolean isNoData(int x, int y, int band) { |
454 |
|
455 |
return false; |
456 |
|
457 |
} |
458 |
|
459 |
public void setNoDataValue(double dNoDataValue) { |
460 |
if(rasterBuf instanceof RasterBuffer) |
461 |
((RasterBuffer)rasterBuf).setNoDataValue(dNoDataValue); |
462 |
} |
463 |
|
464 |
public double getNoDataValue() { |
465 |
if(rasterBuf instanceof RasterBuffer) |
466 |
return ((RasterBuffer)rasterBuf).getNoDataValue();
|
467 |
return 0D; |
468 |
} |
469 |
|
470 |
/**
|
471 |
* Asigna tipo de datos del raster
|
472 |
* @see java.awt.image.DataBuffer
|
473 |
*/
|
474 |
public void setDataType(int dt) { |
475 |
|
476 |
} |
477 |
|
478 |
/**
|
479 |
* Obtiene el n?mero de bandas
|
480 |
* @return N?mero de bandas
|
481 |
*/
|
482 |
public int getBandCount() { |
483 |
if(rasterBuf != null) |
484 |
return rasterBuf.getBandCount();
|
485 |
else
|
486 |
return this.getGeoRasterMultiFile().getBandCount(); |
487 |
} |
488 |
|
489 |
/**
|
490 |
* Obtiene el buffer de datos del grid
|
491 |
* @return RasterBuf
|
492 |
*/
|
493 |
public IBuffer getRasterBuf() {
|
494 |
return rasterBuf;
|
495 |
} |
496 |
|
497 |
/**
|
498 |
* Evalua si una coordenada pixel cae dentro de la imagen.
|
499 |
* @param x coordenada pixel X
|
500 |
* @param y coordenada pixel Y
|
501 |
*/
|
502 |
public boolean isPixelInGrid(int x, int y) { |
503 |
return (x >= 0 && y >= 0 && x <= getWidth() && y <= getHeight()); |
504 |
} |
505 |
|
506 |
/**
|
507 |
* Extent de todo el raster asociado a la fuente de datos.
|
508 |
*/
|
509 |
public Extent getExtent() {
|
510 |
return mDataset.getExtent();
|
511 |
} |
512 |
|
513 |
/**
|
514 |
* Obtiene un buffer desde la posici?n x,y en pixeles de ancho w y alto h
|
515 |
* @param x Coordenada x de la esquina superior izquierda
|
516 |
* @param y Coordenada y de la esquina superior izquierda
|
517 |
* @param w Ancho del grid
|
518 |
* @param h Alto del grid
|
519 |
* @return Buffer de datos
|
520 |
*/
|
521 |
public RasterBuffer getData(int x, int y, int w, int h) { |
522 |
return null; |
523 |
} |
524 |
|
525 |
/**
|
526 |
* Obtiene las coordenadas del fichero worldFile (o cabecera del raster) asociado
|
527 |
* o el RMF en caso de que existan. Si la imagen no est? georreferenciada tendr?
|
528 |
* las coordenadas pixel de la misma
|
529 |
* @return Array de seis valores:
|
530 |
* <TABLE BORDER="1">
|
531 |
* <TR><TD><B>0:</B></TD><TD>Valor X de la esquina superior izquierda.</TD></TR>
|
532 |
* <TR><TD><B>1:</B></TD><TD>Tama?o de pixel en X.</TD></TR>
|
533 |
* <TR><TD><B>2:</B></TD><TD>Shearing en X.</TD></TR>
|
534 |
* <TR><TD><B>3:</B></TD><TD>Valor Y de la esquina superior izquierda.</TD></TR>
|
535 |
* <TR><TD><B>4:</B></TD><TD>Shearing en Y.</TD></TR>
|
536 |
* <TR><TD><B>5:</B></TD><TD>Tama?o de pixel en Y.</TD></TR>
|
537 |
* </TABLE>
|
538 |
*/
|
539 |
public double[] getCoordsGeoTransformFile() { |
540 |
return mDataset.getCoordsGeoTransformFile();
|
541 |
} |
542 |
|
543 |
/**
|
544 |
* Obtiene el extent de la ?ltima selecci?n hecha con alguna de las llamadas
|
545 |
* setAreaOfInterest. Este extent es devuelto en coordenadas reales con las transformaciones
|
546 |
* que se hayan aplicado sobre el/los dataset.
|
547 |
* @return Extent Coordenadas reales que representan el ?ltimo ?rea de datos
|
548 |
* solicitada.
|
549 |
*/
|
550 |
public Extent getLastSelectedView() {
|
551 |
return mDataset.getLastSelectedView();
|
552 |
} |
553 |
|
554 |
/**
|
555 |
* Obtiene el extent correspondiente a los datos cargados en el buffer
|
556 |
* @return Extent
|
557 |
*/
|
558 |
public Extent getDataExtent() {
|
559 |
return dataExtent;
|
560 |
} |
561 |
|
562 |
/**
|
563 |
* Obtiene la lista de paletas asociadas a las bandas cargadas en el DataSource
|
564 |
* @return Lista con las paletas o null si no hay ninguna asocida. Un nulo en una
|
565 |
* posici?n del array tambi?n indicar? que para esa banda no hay paletas asociadas.
|
566 |
*/
|
567 |
public DatasetPalette[] getPalettes() { |
568 |
return palette;
|
569 |
} |
570 |
|
571 |
/**
|
572 |
* Obtiene el flag que dice si la imagen est? o no georreferenciada
|
573 |
* @return true si est? georreferenciada y false si no lo est?.
|
574 |
*/
|
575 |
public boolean isGeoreferenced() { |
576 |
return mDataset.isGeoreferenced();
|
577 |
} |
578 |
|
579 |
/**
|
580 |
* Consulta el flag de supersampleo en la carga del buffer.
|
581 |
* <P>
|
582 |
* Si este flag es false
|
583 |
* y pasamos un buffer de tama?o mayor que el n?mero de pixels del ?rea requerida en la
|
584 |
* llamada setAreaOfInterest entonces se ajustar? este buffer al n?mero de pixeles contenidos
|
585 |
* en el ?rea.
|
586 |
* </P>
|
587 |
* <P>
|
588 |
* Por ejemplo, si solicitamos un ?rea de 5x4 pixels de un raster y pedimos que nos los grabe
|
589 |
* en un buffer de 500x400, si esta variable es false el buffer lo generar? de 5x4. Si esta
|
590 |
* variable es true el buffer lo generar? de 500x400.
|
591 |
* </P>
|
592 |
*
|
593 |
* @return true si el supersampleo en la carga del buffer est? activado y false si no lo est?.
|
594 |
*/
|
595 |
public boolean isSupersamplingLoadingBuffer() { |
596 |
return supersamplingLoadingBuffer;
|
597 |
} |
598 |
|
599 |
/**
|
600 |
* Activa o desactiva el supersampling en la carga del buffer.
|
601 |
* <P>
|
602 |
* Si este flag es false
|
603 |
* y pasamos un buffer de tama?o mayor que el n?mero de pixels del ?rea requerida en la
|
604 |
* llamada setAreaOfInterest entonces se ajustar? este buffer al n?mero de pixeles contenidos
|
605 |
* en el ?rea.
|
606 |
* </P>
|
607 |
* <P>
|
608 |
* Por ejemplo, si solicitamos un ?rea de 5x4 pixels de un raster y pedimos que nos los grabe
|
609 |
* en un buffer de 500x400, si esta variable es false el buffer lo generar? de 5x4. Si esta
|
610 |
* variable es true el buffer lo generar? de 500x400.
|
611 |
* </P>
|
612 |
*
|
613 |
* @param supersamplingLoadingBuffer true o false para activar o desactivar el supersampling en la
|
614 |
* carga del buffer.
|
615 |
*/
|
616 |
public void setSupersamplingLoadingBuffer(boolean supersamplingLoadingBuffer) { |
617 |
this.supersamplingLoadingBuffer = supersamplingLoadingBuffer;
|
618 |
} |
619 |
|
620 |
public double getNHeight() { |
621 |
return nHeight;
|
622 |
} |
623 |
|
624 |
public double getNWidth() { |
625 |
return nWidth;
|
626 |
} |
627 |
|
628 |
/*
|
629 |
* (non-Javadoc)
|
630 |
* @see org.gvsig.raster.util.ICancellable#isCanceled(int)
|
631 |
*/
|
632 |
public boolean isCanceled(int process) { |
633 |
if(process == CANCEL_READ)
|
634 |
return cancel[0]; |
635 |
return false; |
636 |
} |
637 |
|
638 |
/*
|
639 |
* (non-Javadoc)
|
640 |
* @see org.gvsig.raster.util.ICancellable#setCanceled(boolean, int)
|
641 |
*/
|
642 |
public void setCanceled(boolean value, int process) { |
643 |
if(process == CANCEL_READ || process == 0) |
644 |
cancel[0] = value;
|
645 |
} |
646 |
|
647 |
} |
648 |
|