Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libRaster / src / org / gvsig / raster / buffer / BufferFactory.java @ 12749

History | View | Annotate | Download (23.2 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.Dimension;
23
import java.awt.geom.AffineTransform;
24
import java.awt.geom.Point2D;
25

    
26
import org.gvsig.raster.dataset.FileNotFoundInListException;
27
import org.gvsig.raster.dataset.IBuffer;
28
import org.gvsig.raster.dataset.InvalidSetViewException;
29
import org.gvsig.raster.dataset.MultiRasterDataset;
30
import org.gvsig.raster.dataset.NotSupportedExtensionException;
31
import org.gvsig.raster.dataset.RasterDataset;
32
import org.gvsig.raster.dataset.RasterDriverException;
33
import org.gvsig.raster.datastruct.ColorTable;
34
import org.gvsig.raster.datastruct.Extent;
35
import org.gvsig.raster.hierarchy.ICancellable;
36
import org.gvsig.raster.util.RasterUtilities;
37

    
38
/**
39
 * <P>
40
 * Clase que representa a una rejilla de datos que tiene como fuente
41
 * un RasterMultifile. Tiene m?todos para a?adir nuevos ficheros fuente a la
42
 * rejilla que podr?n ser consultados como bandas de uno solo. Estos deber?an tener
43
 * la misma extensi?n que el primero introducido.
44
 * </P>
45
 * <P>
46
 * Para la carga del buffer de datos habr? que asigna las bandas que queremos cargar
47
 * de todas las disponibles con addDrawableBands. Despu?s se seleccionar? el ?rea
48
 * que queremos cargar con setAreaOfInterest. Este ?rea se define con coordenadas
49
 * pixel o reales. Finalmente podemos recuperar el buffer con los datos usando la
50
 * funci?n getRasterBuf.
51
 * </P>
52
 * @author Nacho Brodin (nachobrodin@gmail.com)
53
 *
54
 */
55
public class BufferFactory implements ICancellable {
56

    
57
        public static final int                        CANCEL_READ = 1;
58
        private boolean[]                                cancel = new boolean[1];
59

    
60
        private MultiRasterDataset                 mDataset = new MultiRasterDataset(null);
61
        private IBuffer                                        rasterBuf = null;
62
        private int                                                width = 0;
63
        private int                                                height = 0;
64
        private boolean                                        adjustToExtent = true;
65

    
66
        /**
67
         * Extensi?n de los datos del buffer
68
         */
69
        private Extent                                        dataExtent = null;
70
        /**
71
         * Lista de paletas asociadas a las bandas cargadas en el DataSource. Estas son calculadas
72
         * en las funciones que asignan las bandas a dibujar (addDrawableBands)
73
         */
74
        private ColorTable[]                        palette = null;
75
        /**
76
         * Activa o desactiva el supersampleo en la carga del buffer.
77
         */
78
        private boolean                                        supersamplingLoadingBuffer = true;
79

    
80
        /**
81
         * Ancho y alto en pixeles del ?ltimo buffer asignado
82
         */
83
        private double                                         nWidth = 0;
84
        private double                                         nHeight = 0;
85

    
86
        /**
87
         * Constructor
88
         */
89
        public BufferFactory() {}
90

    
91
        /**
92
         * Constructor
93
         * @param MultiRasterDataset
94
         */
95
        public BufferFactory(MultiRasterDataset rmd) {
96
                mDataset = rmd;
97
                width = (int)rmd.getWidth()[0];
98
                height = (int)rmd.getHeight()[0];
99
        }
100

    
101
        /**
102
         * Constructor
103
         * @param grf Lista de geoRasterFile
104
         */
105
        public BufferFactory(RasterDataset[] grf) {
106
                for(int i = 0; i< grf.length; i++)
107
                        addFile(grf[i]);
108
        }
109

    
110
        /**
111
         * Constructor
112
         * @param grf GeoRasterFile
113
         */
114
        public BufferFactory(RasterDataset grf) {
115
                addFile(grf);
116
        }
117

    
118
        /**
119
         * A?ade un GeoRasterFile al Grid
120
         * @param grf GeoRasterFile a a?adir
121
         */
122
        public void addFile(RasterDataset grf) {
123
                try{
124
                        mDataset.addDataset(grf);
125
                        width = grf.getWidth();
126
                        height = grf.getHeight();
127
                }catch(FileNotFoundInListException e) {
128
                        //El fichero est? en la lista por lo que no lo a?adimos
129
                }
130
        }
131

    
132
        /**
133
         * A?ade un GeoRasterFile al Grid
134
         * @param fileName Nombre del fichero a a?adir
135
         * @throws NotSupportedExtensionException
136
         * @throws RasterDriverException
137
         */
138
        public void addFile(String filename) throws NotSupportedExtensionException, RasterDriverException{
139
                try{
140
                        mDataset.addDataset(filename);
141
                        width = (int)mDataset.getWidth()[0];
142
                        height = (int)mDataset.getHeight()[0];
143
                }catch(FileNotFoundInListException e) {
144
                        //El fichero est? en la lista por lo que no lo a?adimos
145
                }
146
        }
147

    
148
        /**
149
         * Elimina un GeoRasterFile del Grid
150
         * @param grf GeoRasterFile a eliminar
151
         */
152
        public void removeFile(RasterDataset grf) {
153
                mDataset.removeDataset(grf);
154
        }
155

    
156
        /**
157
         * Elimina un GeoRasterFile del Grid
158
         * @param fileName Nombre del fichero a eliminar su GeoRasterFile
159
         */
160
        public void removeFile(String fileName) {
161
                mDataset.removeDataset(fileName);
162
        }
163

    
164
        /**
165
         * Obtiene el n?mero de ficheros del que est? compuesta la fuente de datos.
166
         * @return
167
         */
168
        public int getFileCount() {
169
                return  mDataset.getDatasetCount();
170
        }
171

    
172
        /**
173
         * Obtiene la estructura que contiene la lista de ficheros del Grid
174
         * @return GeoRasterMultiFile
175
         */
176
        public MultiRasterDataset getMultiRasterDataset() {
177
                return mDataset;
178
        }
179

    
180
        /**
181
         * Libera el buffer de memoria
182
         */
183
        public void free() {
184
                rasterBuf.free();
185
                rasterBuf = null;
186
                System.gc();
187
        }
188

    
189
        /**
190
         * Resetea la asignaci?n de dibujado de las bandas de la imagen
191
         * sobre el DataImage cuando se hace un update para esta banda.
192
         */
193
        public void clearDrawableBand() {
194
                for(int i = 0; i < mDataset.getDatasetCount(); i++)
195
                        mDataset.getBands().clearDrawableBands();
196
                palette = null;
197
        }
198

    
199
        /**
200
         * Para este GeoRasterFile asigna que bandas se pintaran
201
         * sobre el RasterBuf cuando se haga un update. Cada posici?n del vector es una banda
202
         * del rasterBuf y el contenido de esa posici?n es la banda de la imagen que se dibujar?
203
         * sobre ese RasterBuf.
204
         * @param drawableBands        Array con las bandas a dibujar.
205
         * @return array con tantos elementos como bandas a dibujar. El valor contenido es el fichero del
206
         * dataset multifichero al que corresponde la banda.
207
         */
208
        public int[] setDrawableBands(int[] drawableBands) {
209
                clearDrawableBand();
210
                mDataset.getBands().setDrawableBands(drawableBands);
211

    
212
                int[] files = new int[drawableBands.length];
213
                palette = new ColorTable[drawableBands.length];
214

    
215
                for(int i = 0; i< drawableBands.length; i++) {
216
                        if(drawableBands[i] < 0 || drawableBands[i] >= mDataset.getBandCount())
217
                                continue;
218
                        mDataset.getBands().addDrawableBand(i, drawableBands[i]);
219
                        String fileName = mDataset.getBands().getBand(drawableBands[i]).getFileName();
220
                        files[i] = mDataset.getBands().getFileNumber(fileName);
221
                        palette[i] = mDataset.getColorTable(fileName);
222
                }
223
                return files;
224
        }
225

    
226
        /**
227
         * Para este GeoRasterFile asigna que bandas se pintaran
228
         * sobre el RasterBuf cuando se haga un update. Cada posici?n del vector es una banda
229
         * del rasterBuf y el contenido de esa posici?n es la banda de la imagen que se dibujar?
230
         * sobre ese RasterBuf. Esta llamada asigna todas las bandas dibujables en su orden natural.
231
         * @return array con tantos elementos como bandas a dibujar. El valor contenido es el fichero del
232
         * dataset multifichero al que corresponde la banda.
233
         */
234
        public int[] setAllDrawableBands() {
235
                clearDrawableBand();
236
                int[] files = new int[mDataset.getBandCount()];
237
                palette = new ColorTable[mDataset.getBandCount()];
238

    
239
                for(int i = 0; i< mDataset.getBandCount(); i++) {
240
                        mDataset.getBands().addDrawableBand(i, i);
241
                        String fileName = mDataset.getBands().getBand(i).getFileName();
242
                        files[i] = mDataset.getBands().getFileNumber(fileName);
243
                        palette[i] = mDataset.getColorTable(fileName);
244
                }
245
                return files;
246
        }
247

    
248
        /**
249
         * Obtiene el array que contiene el orden de bandas. Cada posici?n del vector es una banda
250
         * del rasterBuf y el contenido de esa posici?n es la banda de la imagen que se dibujar?
251
         * sobre ese RasterBuf.
252
         * @return Array de enteros con el orden de las badas
253
         */
254
        public int[] getDrawableBands() {
255
                return mDataset.getBands().getDrawableBands();
256
        }
257

    
258
        /**
259
         * Asigna el ?rea de interes en coordenadas del mundo real. Si las coordenadas exceden del tama?o de la imagen
260
         * estas coordenadas son ajustadas el extent.
261
         * @param x Coordenada X, esquina superior izquierda
262
         * @param y Coordenada Y, esquina superior izquierda
263
         * @param w Ancho del ?rea
264
         * @param h Alto del ?rea
265
         * @throws ArrayIndexOutOfBoundsException
266
         */
267
        public void setAreaOfInterest(double x, double y, double w, double h)
268
                throws ArrayIndexOutOfBoundsException {
269
                dataExtent = new Extent(x, y, x + w, y - h);
270

    
271
                Extent adjustedDataExtent = RasterUtilities.calculateAdjustedView(dataExtent, mDataset.getAffineTransform(), new Dimension((int)mDataset.getWidth()[0], (int)mDataset.getHeight()[0]));
272
                
273
                try {
274
                        rasterBuf = mDataset.getWindowRaster(adjustedDataExtent.getMin().getX(), adjustedDataExtent.getMax().getY(), adjustedDataExtent.width(), adjustedDataExtent.height(), adjustToExtent);
275
                } catch (InvalidSetViewException e) {
276
                        //Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
277
                }
278

    
279
                if(adjustToExtent) {
280
                        //TODO: FUNCIONALIDAD: (3D) En caso de que no se quiera ajustado al extent hay que devolver con valores no data
281
                }
282
        }
283

    
284
        /**
285
         * Asigna el ?rea de interes en coordenadas del mundo real. Si las coordenadas exceden del tama?o de la imagen
286
         * estas coordenadas son ajustadas el extent.
287
         * @param x Coordenada X, esquina superior izquierda
288
         * @param y Coordenada Y, esquina superior izquierda
289
         * @param w Ancho del ?rea
290
         * @param h Alto del ?rea
291
         * @param bufWidth Ancho del buffer
292
         * @param bufHeight Alto del buffer
293
         * @return En caso de que el buffer sea mayor que el tama?o seleccionado de raster se produce supersampleo. La funci?n devuelve
294
         * un array de dos elementos que representan el desplazamiento en pixels de X e Y de la esquina superior izquierda.
295
         * @throws ArrayIndexOutOfBoundsException
296
         */
297
        public int[] setAreaOfInterest(double ulx, double uly, double lrx, double lry, int bufWidth, int bufHeight)
298
                throws ArrayIndexOutOfBoundsException {
299
                dataExtent = new Extent(ulx, uly, lrx, lry);
300
                Extent adjustedDataExtent = RasterUtilities.calculateAdjustedView(dataExtent, mDataset.getAffineTransform(), new Dimension((int)mDataset.getWidth()[0], (int)mDataset.getHeight()[0]));
301

    
302
                //Esta secci?n es para que no supersamplee el driver y pueda hacerse en el cliente
303
                if(!isSupersamplingLoadingBuffer()) {
304
                        //nWidth = ((adjustedDataExtent.width() * mDataset.getDataset(0).getWidth()) / mDataset.getExtentForRequest().width());
305
                        //nHeight = ((adjustedDataExtent.height() * mDataset.getDataset(0).getHeight()) / mDataset.getExtentForRequest().height());
306
                        Point2D p1 = mDataset.worldToRaster(new Point2D.Double(adjustedDataExtent.getULX(), adjustedDataExtent.getULY()));
307
                        Point2D p2 = mDataset.worldToRaster(new Point2D.Double(adjustedDataExtent.getLRX(), adjustedDataExtent.getLRY()));
308
                        nWidth = Math.abs(p1.getX() - p2.getX());
309
                        nHeight = Math.abs(p1.getY() - p2.getY());
310

    
311
                        if(bufWidth > Math.ceil(nWidth) && bufHeight > Math.ceil(nHeight)) {
312
                                try {
313
                                        rasterBuf = mDataset.getWindowRaster(adjustedDataExtent.getULX(), adjustedDataExtent.getULY(), adjustedDataExtent.getLRX(), adjustedDataExtent.getLRY());
314
                                } catch (InvalidSetViewException e) {
315
                                        //Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
316
                                }
317
                                int[] step = mDataset.calcSteps(adjustedDataExtent.getULX(), adjustedDataExtent.getULY(), adjustedDataExtent.getLRX(), adjustedDataExtent.getLRY(), nWidth, nHeight, bufWidth, bufHeight);
318
                                return step;
319
                        }
320
                }
321

    
322
                try {
323
                        rasterBuf = mDataset.getWindowRaster(adjustedDataExtent.getULX(), adjustedDataExtent.getULY(), adjustedDataExtent.getLRX(), adjustedDataExtent.getLRY(), bufWidth, bufHeight, adjustToExtent);
324
                } catch (InvalidSetViewException e) {
325
                        //Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
326
                }
327
                return null;
328
        }
329
        
330
        /**
331
         * Dado unas coordenadas reales, un tama?o de buffer y un tama?o de raster. 
332
         * Si el buffer es de mayor tama?o que el raster (supersampleo) quiere decir que 
333
         * por cada pixel de buffer se repiten varios del raster. Esta funci?n calcula el 
334
         * n?mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
335
         * buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
336
         * solicitada es real y puede no caer sobre un pixel completo. Este calculo es
337
         * util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
338
         * el driver autom?ticamente.
339
         * @param dWorldTLX Coordenada real X superior izquierda
340
         * @param dWorldTLY Coordenada real Y superior izquierda
341
         * @param dWorldBRX Coordenada real X inferior derecha
342
         * @param dWorldBRY Coordenada real Y inferior derecha
343
         * @param nWidth Ancho del raster
344
         * @param nHeight Alto del raster
345
         * @param bufWidth Ancho del buffer
346
         * @param bufHeight Alto del buffer
347
         * @return Array de dos elementos con el desplazamiento en X e Y. 
348
         */
349
        public int[] calcSteps(double ulx, double uly, double lrx, double lry, 
350
                        double nWidth, double nHeight, int bufWidth, int bufHeight) {
351
                Point2D p1 = mDataset.worldToRaster(new Point2D.Double(ulx, uly));
352
                Point2D p2 = mDataset.worldToRaster(new Point2D.Double(lrx, lry));
353
                int width = (int)Math.abs(Math.ceil(p2.getX()) - Math.floor(p1.getX())); 
354
                int height = (int)Math.abs(Math.floor(p1.getY()) - Math.ceil(p2.getY()));
355
                Point2D wc1 = mDataset.rasterToWorld(new Point2D.Double(Math.floor(p1.getX()), Math.floor(p1.getY())));
356
                Point2D wc2 = mDataset.rasterToWorld(new Point2D.Double(Math.ceil(p2.getX()), Math.ceil(p2.getY())));
357
                
358
                return mDataset.calcSteps(wc1.getX(), wc1.getY(), wc2.getX(), wc2.getY(), width, height, bufWidth, bufHeight);
359
        }
360

    
361
        /**
362
         * Asigna el ?rea de interes en coordenadas pixel. Si las coordenadas exceden del tama?o de la imagen
363
         * lanza una excepci?n.
364
         * @param x Coordenada X, esquina superior izquierda
365
         * @param y Coordenada Y, esquina superior izquierda
366
         * @param w Ancho del ?rea
367
         * @param h Alto del ?rea
368
         * @throws ArrayIndexOutOfBoundsException
369
         */
370
        public void setAreaOfInterest(int x, int y, int w, int h){
371
                x = (x < 0) ? 0 : x;
372
                y = (y < 0) ? 0 : y;
373
                w = (w > getWidth()) ? getWidth() : w;
374
                h = (w > getHeight()) ? getHeight() : h;
375

    
376
                dataExtent = new Extent(mDataset.rasterToWorld(new Point2D.Double(x, y)),
377
                                                                mDataset.rasterToWorld(new Point2D.Double(x + w, y + h)));
378
                try {
379
                        rasterBuf = mDataset.getWindowRaster(x, y, w, h);
380
                } catch (InvalidSetViewException e) {
381
                        //Esta excepci?n no debe darse ya que se hace un calculateAdjustedView antes de la llamada.
382
                }
383
        }
384

    
385
        /**
386
         * Asigna el ?rea de inter?s a toda la extensi?n del raster.
387
         */
388
        public void setAreaOfInterest() {
389
                dataExtent = mDataset.getExtent();
390
                try {
391
                        rasterBuf = mDataset.getWindowRaster(0, 0, (int)mDataset.getWidth()[0], (int)mDataset.getHeight()[0]);
392
                } catch (InvalidSetViewException e) {
393
                        //Esta excepci?n no deber?a darse ya que las coordenadas se asignan autom?ticamente por lo que no
394
                        //tiene sentido lanzarla hacia arriba
395
                        e.printStackTrace();
396
                }
397
        }
398

    
399
        /**
400
         * Asigna el ?rea de interes en coordenadas pixel. Esta operaci?n cargar? un RasterBuffer con los datos solicitados por
401
         * lo que, si al acabar hacemos getRasterBuf obtendremos la matriz de datos. Si las coordenadas exceden del tama?o
402
         * de la imagen lanza una excepci?n.
403
         * @param x Coordenada X, esquina superior izquierda
404
         * @param y Coordenada Y, esquina superior izquierda
405
         * @param w Ancho del ?rea
406
         * @param h Alto del ?rea
407
         * @param bufWidth Ancho del buffer
408
         * @param bufHeight Alto del buffer
409
         * @throws ArrayIndexOutOfBoundsException
410
         */
411
        public void setAreaOfInterest(int x, int y, int w, int h, int bufWidth, int bufHeight)
412
                throws InvalidSetViewException {
413
                //TODO: VALIDACI?N: Comprobaci?n de exceso de memoria reservada
414
                x = (x < 0) ? 0 : x;
415
                y = (y < 0) ? 0 : y;
416
                w = (w > getWidth()) ? getWidth() : w;
417
                h = (w > getHeight()) ? getHeight() : h;
418

    
419
                dataExtent = new Extent(mDataset.rasterToWorld(new Point2D.Double(x, y)),
420
                                                                mDataset.rasterToWorld(new Point2D.Double(x + w, y + h)));
421

    
422
                rasterBuf = mDataset.getWindowRaster(x, y, w, h, bufWidth, bufHeight);
423
        }
424

    
425
        /**
426
         * Obtiene el tipo de datos del grid.
427
         * @return entero que representa el tipo de dato de las celdas del grid.
428
         */
429
        public int getDataType() {
430
                return mDataset.getDataType()[0];
431
        }
432

    
433
        /**
434
         * Obtiene la altura del grid.
435
         * @return altura en celdas del grid.
436
         */
437
        public int getHeight() {
438
                return height;
439
        }
440

    
441
        /**
442
         * Obtiene la anchura del grid.
443
         * @return anchura en celdas del grid.
444
         */
445
        public int getWidth() {
446
                return width;
447
        }
448

    
449
        /**
450
         * Tama?o de celda en X
451
         * @return
452
         */
453
        public double getXCellSize() {
454

    
455
                Extent e = mDataset.getExtent();
456
                double dCellsize = (e.getMax().getX() - e.getMin().getX() ) / (double) width;
457

    
458
                return dCellsize;
459

    
460
        }
461

    
462
        /**
463
         * Tama?o de celda en Y
464
         * @return
465
         */
466
        public double getYCellSize() {
467

    
468
                return 0;
469
        }
470

    
471
        /**
472
         * Devuelve true si la celda contiene un valor de NODATA
473
         * @param x        coordenada X
474
         * @param y coordenada Y
475
         * @return
476
         */
477
        public boolean isNoData(int x, int y, int band) {
478

    
479
                return false;
480

    
481
        }
482

    
483
        public void setNoDataValue(double dNoDataValue) {
484
                if(rasterBuf instanceof RasterBuffer)
485
                        ((RasterBuffer)rasterBuf).setNoDataValue(dNoDataValue);
486
        }
487

    
488
        public double getNoDataValue() {
489
                if(rasterBuf instanceof RasterBuffer)
490
                        return ((RasterBuffer)rasterBuf).getNoDataValue();
491
                return 0D;
492
        }
493

    
494
        /**
495
         * Asigna tipo de datos del raster
496
         * @see java.awt.image.DataBuffer
497
         */
498
        public void setDataType(int dt) {
499

    
500
        }
501

    
502
        /**
503
         * Obtiene el n?mero de bandas
504
         * @return N?mero de bandas
505
         */
506
        public int getBandCount() {
507
                if(rasterBuf != null)
508
                        return rasterBuf.getBandCount();
509
                else
510
                        return this.getMultiRasterDataset().getBandCount();
511
        }
512

    
513
        /**
514
         * Obtiene el buffer de datos del grid
515
         * @return RasterBuf
516
         */
517
        public IBuffer getRasterBuf() {
518
                return rasterBuf;
519
        }
520

    
521
        /**
522
         * Evalua si una coordenada pixel cae dentro de la imagen.
523
         * @param x coordenada pixel X
524
         * @param y coordenada pixel Y
525
         */
526
        public boolean isPixelInGrid(int x, int y) {
527
                return (x >= 0 && y >= 0 && x <= getWidth() && y <= getHeight());
528
        }
529

    
530
        /**
531
         * Extent de todo el raster asociado a la fuente de datos.
532
         */
533
        public Extent getExtent() {
534
                return mDataset.getExtent();
535
        }
536

    
537
        /**
538
         * Obtiene un buffer desde la posici?n x,y en pixeles de ancho w y alto h
539
         * @param x Coordenada x de la esquina superior izquierda
540
         * @param y Coordenada y de la esquina superior izquierda
541
         * @param w Ancho del grid
542
         * @param h Alto del grid
543
         * @return Buffer de datos
544
         */
545
        public RasterBuffer getData(int x, int y, int w, int h) {
546
                return null;
547
        }
548

    
549
        /**
550
         * Obtiene las coordenadas del fichero worldFile (o cabecera del raster) asociado
551
         * o el RMF en caso de que existan. Si la imagen no est? georreferenciada tendr?
552
         * las coordenadas pixel de la misma
553
         * @return Array de seis valores:
554
         *         <TABLE BORDER="1">
555
         *         <TR><TD><B>0:</B></TD><TD>Valor X de la esquina superior izquierda.</TD></TR>
556
         *         <TR><TD><B>1:</B></TD><TD>Tama?o de pixel en X.</TD></TR>
557
         *         <TR><TD><B>2:</B></TD><TD>Shearing en X.</TD></TR>
558
         *         <TR><TD><B>3:</B></TD><TD>Valor Y de la esquina superior izquierda.</TD></TR>
559
         *         <TR><TD><B>4:</B></TD><TD>Shearing en Y.</TD></TR>
560
         *         <TR><TD><B>5:</B></TD><TD>Tama?o de pixel en Y.</TD></TR>
561
         *         </TABLE>
562
         */
563
        public AffineTransform getCoordsGeoTransformFile() {
564
                return mDataset.getCoordsGeoTransformFile();
565
        }
566

    
567
        /**
568
         * Obtiene el extent de la ?ltima selecci?n hecha con alguna de las llamadas
569
         * setAreaOfInterest. Este extent es devuelto en coordenadas reales con las transformaciones
570
         * que se hayan aplicado sobre el/los dataset.
571
         * @return Extent Coordenadas reales que representan el ?ltimo ?rea de datos
572
         * solicitada.
573
         */
574
        public Extent getLastSelectedView() {
575
                return mDataset.getLastSelectedView();
576
        }
577

    
578
        /**
579
         * Obtiene el extent correspondiente a los datos cargados en el buffer
580
         * @return Extent
581
         */
582
        public Extent getDataExtent() {
583
                return dataExtent;
584
        }
585

    
586
        /**
587
         * Obtiene la lista de paletas asociadas a las bandas cargadas en el DataSource
588
         * @return Lista con las paletas o null si no hay ninguna asocida. Un nulo en una
589
         * posici?n del array tambi?n indicar? que para esa banda no hay paletas asociadas.
590
         */
591
        public ColorTable[] getColorTables() {
592
                return palette;
593
        }
594

    
595
        /**
596
         * Obtiene el flag que dice si la imagen est? o no georreferenciada
597
         * @return true si est? georreferenciada y false si no lo est?.
598
         */
599
        public boolean isGeoreferenced() {
600
                return mDataset.isGeoreferenced();
601
        }
602

    
603
        /**
604
         * Consulta el flag de supersampleo en la carga del buffer.
605
         * <P>
606
         * Si este flag es false
607
         * y pasamos un buffer de tama?o mayor que el n?mero de pixels del ?rea requerida en la
608
         * llamada setAreaOfInterest entonces se ajustar? este buffer al n?mero de pixeles contenidos
609
         * en el ?rea.
610
         * </P>
611
         * <P>
612
         * Por ejemplo, si solicitamos un ?rea de 5x4 pixels de un raster y pedimos que nos los grabe
613
         * en un buffer de 500x400, si esta variable es false el buffer lo generar? de 5x4. Si esta
614
         * variable es true el buffer lo generar? de 500x400.
615
         * </P>
616
         *
617
         * @return true si el supersampleo en la carga del buffer est? activado y false si no lo est?.
618
         */
619
        public boolean isSupersamplingLoadingBuffer() {
620
                return supersamplingLoadingBuffer;
621
        }
622

    
623
        /**
624
         * Activa o desactiva el supersampling en la carga del buffer.
625
         * <P>
626
         * Si este flag es false
627
         * y pasamos un buffer de tama?o mayor que el n?mero de pixels del ?rea requerida en la
628
         * llamada setAreaOfInterest entonces se ajustar? este buffer al n?mero de pixeles contenidos
629
         * en el ?rea.
630
         * </P>
631
         * <P>
632
         * Por ejemplo, si solicitamos un ?rea de 5x4 pixels de un raster y pedimos que nos los grabe
633
         * en un buffer de 500x400, si esta variable es false el buffer lo generar? de 5x4. Si esta
634
         * variable es true el buffer lo generar? de 500x400.
635
         * </P>
636
         *
637
         * @param supersamplingLoadingBuffer true o false para activar o desactivar el supersampling en la
638
         * carga del buffer.
639
         */
640
        public void setSupersamplingLoadingBuffer(boolean supersamplingLoadingBuffer) {
641
                this.supersamplingLoadingBuffer = supersamplingLoadingBuffer;
642
        }
643

    
644
        public double getNHeight() {
645
                return nHeight;
646
        }
647

    
648
        public double getNWidth() {
649
                return nWidth;
650
        }
651

    
652
        /*
653
         * (non-Javadoc)
654
         * @see org.gvsig.raster.util.ICancellable#isCanceled(int)
655
         */
656
        public boolean isCanceled(int process) {
657
                if (process == CANCEL_READ)
658
                        return cancel[0];
659
                return false;
660
        }
661

    
662
        /*
663
         * (non-Javadoc)
664
         * @see org.gvsig.raster.util.ICancellable#setCanceled(boolean, int)
665
         */
666
        public void setCanceled(boolean value, int process) {
667
                if(process == CANCEL_READ || process == 0)
668
                        cancel[0] = value;
669
        }
670

    
671
        /**
672
         * Obtiene el flag que ajusta el extent de la petici?n al del raster. Si est? a
673
         * true en caso de que el extent de la petici?n sea mayor lo ajustar? a los limites
674
         * de este. Si est? a false no lo ajustar? rellenando los valores con NoData. Por defecto
675
         * estar? a true.
676
         * @return true si ajusta y false si no lo hace
677
         */
678
        public boolean isAdjustToExtent() {
679
                return adjustToExtent;
680
        }
681

    
682
        /**
683
         * Asigna el flag que ajusta el extent de la petici?n al del raster. Si est? a
684
         * true en caso de que el extent de la petici?n sea mayor lo ajustar? a los limites
685
         * de este. Si est? a false no lo ajustar? rellenando los valores con NoData
686
         * @param adjustToExtent true para ajustar y false si no queremos que lo haga. Por defecto
687
         * estar? a true.
688
         */
689
        public void setAdjustToExtent(boolean adjustToExtent) {
690
                this.adjustToExtent = adjustToExtent;
691
        }
692

    
693
}
694