Statistics
| Revision:

root / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / GeoRasterFile.java @ 8120

History | View | Annotate | Download (20.2 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 * 
22
 * cresques@gmail.com
23
 */
24
package org.cresques.io;
25

    
26
import java.awt.Component;
27
import java.awt.Dimension;
28
import java.awt.Image;
29
import java.awt.geom.Point2D;
30
import java.awt.image.DataBuffer;
31
import java.io.BufferedReader;
32
import java.io.File;
33
import java.io.FileInputStream;
34
import java.io.FileNotFoundException;
35
import java.io.FileReader;
36
import java.io.FileWriter;
37
import java.io.IOException;
38
import java.lang.reflect.Constructor;
39
import java.lang.reflect.InvocationTargetException;
40
import java.util.TreeMap;
41

    
42
import org.cresques.cts.ICoordTrans;
43
import org.cresques.cts.IProjection;
44
import org.cresques.filter.PixelFilter;
45
import org.cresques.filter.SimplePixelFilter;
46
import org.cresques.io.data.Metadata;
47
import org.cresques.io.data.RasterMetaFileTags;
48
import org.cresques.px.Extent;
49
import org.cresques.px.IObjList;
50
import org.cresques.px.PxContour;
51
import org.cresques.px.PxObjList;
52
import org.kxml2.io.KXmlParser;
53
import org.xmlpull.v1.XmlPullParserException;
54

    
55
/**
56
 * Manejador de ficheros raster georeferenciados.
57
 * 
58
 * Esta clase abstracta es el ancestro de todas las clases que proporcionan
59
 * soporte para ficheros raster georeferenciados.<br>
60
 * Actua tambien como una 'Fabrica', ocultando al cliente la manera en que
61
 * se ha implementado ese manejo. Una clase nueva que soportara un nuevo
62
 * tipo de raster tendr?a que registrar su extensi?n o extensiones usando
63
 * el m?todo @see registerExtension.<br> 
64
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>*
65
 */
66

    
67
public abstract class GeoRasterFile extends GeoFile {
68
        
69
        /**
70
         * Flag que representa a la banda del Rojo
71
         */
72
        public static final int         RED_BAND        = 0x01;
73
        
74
        /**
75
         * Flag que representa a la banda del Verde
76
         */
77
        public static final int         GREEN_BAND        = 0x02;
78
        
79
        /**
80
         * Flag que representa a la banda del Azul
81
         */
82
        public static final int         BLUE_BAND        = 0x04;
83
        private static TreeMap                 supportedExtensions = null;
84
        protected Component                 updatable = null;
85
        protected boolean                         doTransparency = false;
86
        private boolean                                verifySize = false;
87
        
88
        /**
89
         * Filtro para raster.
90
         * Permite eliminar la franja inutil alrededor de un raster girado o de
91
         * un mosaico de borde irregular.
92
         * 
93
         * Funciona bien solo con raster en tonos de gris, porque se basa que
94
         * el valor del pixel no supere un determinado valor 'umbral' que se
95
         * le pasa al constructor.
96
         * 
97
         * Desarrollado para 'limpiar' los bordes de los mosaicos del SIG
98
         * Oleicola. Para ese caso los par?metros del constructo son:
99
         * PixelFilter(0x10ffff00, 0xff000000, 0xf0f0f0);
100
         */
101
        protected PixelFilter                 tFilter = null;
102
        
103
        /**
104
         * Asignaci?n de banda del Rojo a una banda de la imagen
105
         */
106
        protected int                                 rBandNr = 1;
107
        
108
        /**
109
         * Asignaci?n de banda del Verde a una banda de la imagen
110
         */
111
        protected int                                 gBandNr = 1;
112
        
113
        /**
114
         * Asignaci?n de banda del Azul a una banda de la imagen
115
         */
116
        protected int                                 bBandNr = 1;
117
        
118
        /**
119
         * N?mero de bandas de la imagen
120
         */
121
        protected int                                 bandCount = 1;
122
        private int                                 dataType = DataBuffer.TYPE_BYTE;
123

    
124
        static {
125
                supportedExtensions = new TreeMap();
126
                supportedExtensions.put("ecw",  EcwFile.class);
127
                supportedExtensions.put("jp2",  EcwFile.class);
128
                
129
                supportedExtensions.put("sid",  MrSidFile.class);
130

    
131
                supportedExtensions.put("bmp", GdalFile.class);
132
                supportedExtensions.put("gif", GdalFile.class);
133
                supportedExtensions.put("img", GdalFile.class);
134
                supportedExtensions.put("tif", GdalFile.class);
135
                supportedExtensions.put("tiff", GdalFile.class);
136
                supportedExtensions.put("jpg", GdalFile.class);
137
                supportedExtensions.put("png", GdalFile.class);
138
                //supportedExtensions.put("jpg",  TifGeoRefFile.class);
139
                //supportedExtensions.put("png",  TifGeoRefFile.class);
140
                //supportedExtensions.put("dat",  GdalFile.class);
141
        }
142
        
143
        /**
144
         * Factoria para abrir distintos tipos de raster.
145
         * 
146
         * @param proj Proyecci?n en la que est? el raster.
147
         * @param fName Nombre del fichero.
148
         * @return GeoRasterFile, o null si hay problemas.
149
         */
150
        public static GeoRasterFile openFile(IProjection proj, String fName) {
151
                String ext = fName.toLowerCase().substring(fName.lastIndexOf('.')+1);
152
                GeoRasterFile grf = null;
153
                // TODO NotSupportedExtensionException
154
                if (!supportedExtensions.containsKey(ext)) return grf;
155
                /**/
156
                Class clase = (Class) supportedExtensions.get(ext);
157
                Class [] args = {IProjection.class, String.class};
158
                try {
159
                        Constructor hazNuevo = clase.getConstructor(args);
160
                        Object [] args2 = {proj, fName};
161
                        grf = (GeoRasterFile) hazNuevo.newInstance(args2);
162
                        grf.setFileSize(new File(fName).length());
163
                } catch (SecurityException e) {
164
                        // TODO Auto-generated catch block
165
                        e.printStackTrace();
166
                } catch (NoSuchMethodException e) {
167
                        // TODO Auto-generated catch block
168
                        e.printStackTrace();
169
                } catch (IllegalArgumentException e) {
170
                        // TODO Auto-generated catch block
171
                        e.printStackTrace();
172
                } catch (InstantiationException e) {
173
                        // TODO Auto-generated catch block
174
                        e.printStackTrace();
175
                } catch (IllegalAccessException e) {
176
                        // TODO Auto-generated catch block
177
                        e.printStackTrace();
178
                } catch (InvocationTargetException e) {
179
                        // TODO Auto-generated catch block
180
                        e.printStackTrace();
181
                }
182
                 
183
                return grf;
184
        }
185
        
186
        /**
187
         * Registra una clase que soporta una extensi?n raster.
188
         * @param ext extensi?n soportada.
189
         * @param clase clase que la soporta.
190
         */
191
        public static void registerExtension(String ext, Class clase) {
192
                ext = ext.toLowerCase();
193
                System.out.println("RASTER: extension '"+ext+"' supported.");
194
                supportedExtensions.put(ext, clase);
195
        }
196
        
197
        /**
198
         * Tipo de fichero soportado.
199
         * Devuelve true si el tipo de fichero (extension) est? soportado, si no
200
         * devuelve false.
201
         * 
202
         * @param fName Fichero raster
203
         * @return  true si est? soportado, si no false.
204
          */
205
        public static boolean fileIsSupported(String fName) {
206
                String ext = fName.toLowerCase().substring(fName.lastIndexOf('.')+1);
207
                return supportedExtensions.containsKey(ext);
208
        }
209
        
210
        /**
211
         * Constructor
212
         * @param proj        Proyecci?n
213
         * @param name        Nombre del fichero de imagen.
214
         */
215
        public GeoRasterFile(IProjection proj, String name) {
216
                super(proj, name);
217
        }
218
        
219
        /**
220
         * Carga un fichero raster. Puede usarse para calcular el extent e instanciar 
221
         * un objeto de este tipo.
222
         */
223
        abstract public GeoFile load();
224
        
225
        /**
226
         * Cierra el fichero y libera los recursos.
227
         */
228
        abstract public void close();
229
        
230
        /**
231
         * Obtiene la codificaci?n del fichero XML
232
         * @param file Nombre del fichero XML
233
         * @return Codificaci?n
234
         */
235
        private String readFileEncoding(String file){
236
                FileReader fr;
237
                String encoding = null;
238
                try
239
            {
240
                        fr = new FileReader(file);
241
                    BufferedReader br = new BufferedReader(fr);
242
                    char[] buffer = new char[100];
243
                    br.read(buffer);
244
                    StringBuffer st = new StringBuffer(new String(buffer));
245
                    String searchText = "encoding=\"";
246
                    int index = st.indexOf(searchText);
247
                    if (index>-1) {
248
                            st.delete(0, index+searchText.length());
249
                            encoding = st.substring(0, st.indexOf("\""));
250
                    }
251
                    fr.close();
252
            } catch(FileNotFoundException ex)        {
253
                    ex.printStackTrace();
254
            } catch (IOException e) {
255
                        e.printStackTrace();
256
                }
257
            return encoding;
258
        }
259
        
260
        private double[] parserExtent(KXmlParser parser) throws XmlPullParserException, IOException {                
261
                double originX = 0D, originY = 0D, w = 0D, h = 0D;
262
                double pixelSizeX = 0D, pixelSizeY = 0D;
263
                
264
                boolean end = false;
265
            int tag = parser.next();
266
            while (!end) {
267
                    switch(tag) {
268
                        case KXmlParser.START_TAG:
269
                                if(parser.getName() != null){        
270
                                                if (parser.getName().equals(RasterMetaFileTags.POSX)){
271
                                                        originX = Double.parseDouble(parser.nextText());
272
                                                }else if (parser.getName().equals(RasterMetaFileTags.POSY)){
273
                                                        originY = Double.parseDouble(parser.nextText());
274
                                                }else if (parser.getName().equals(RasterMetaFileTags.PX_SIZE_X)){
275
                                                        pixelSizeX = Double.parseDouble(parser.nextText());
276
                                                }else if (parser.getName().equals(RasterMetaFileTags.PX_SIZE_Y)){
277
                                                        pixelSizeY = Double.parseDouble(parser.nextText());
278
                                                }else if (parser.getName().equals(RasterMetaFileTags.WIDTH)){
279
                                                        w = Double.parseDouble(parser.nextText());
280
                                                }else if (parser.getName().equals(RasterMetaFileTags.HEIGHT)){
281
                                                        h = Double.parseDouble(parser.nextText());
282
                                                }
283
                                        }                    
284
                                        break;
285
                         case KXmlParser.END_TAG:
286
                                 if (parser.getName().equals(RasterMetaFileTags.BBOX))
287
                                         end = true;
288
                                break;
289
                        case KXmlParser.TEXT:
290
                                break;
291
                    }
292
                    tag = parser.next();
293
            }
294
                
295
            double[] values = {originX, originY, w, h, pixelSizeX, pixelSizeY};
296
                return values;
297
        }
298
        
299
        /**
300
         * Obtiene la informaci?n de georreferenciaci?n asociada a la imagen en un fichero .rmf. Esta 
301
         * georreferenciaci?n tiene la caracteristica de que tiene prioridad sobre la de la imagen.
302
         * Es almacenada en la clase GeoFile en la variable virtualExtent.
303
         * @param file Fichero de metadatos .rmf
304
         */
305
        protected void readGeoInfo(String file){
306
                String rmf = file.substring(0, file.lastIndexOf(".") + 1) + "rmf";
307
                File rmfFile = new File(rmf);
308
                if(!rmfFile.exists())
309
                        return;
310
                
311
                boolean georefOk = false;
312
                double originX = 0D, originY = 0D, w = 0D, h = 0D;
313
                double pixelSizeX = 0D, pixelSizeY = 0D;
314
                double imageWidth = 0D, imageHeight = 0D;
315
                
316
                FileReader fr = null;
317
                String v = null;
318
                try {
319
                        fr = new FileReader(rmf);
320
                        KXmlParser parser = new KXmlParser();
321
                        parser.setInput(new FileInputStream(rmf), readFileEncoding(rmf));
322
                        int tag = parser.nextTag();
323
                        if ( parser.getEventType() != KXmlParser.END_DOCUMENT ){                    
324
                                parser.require(KXmlParser.START_TAG, null, RasterMetaFileTags.MAIN_TAG);                            
325
                                while(tag != KXmlParser.END_DOCUMENT) {
326
                                        switch(tag) {
327
                                                case KXmlParser.START_TAG:
328
                                                        if (parser.getName().equals(RasterMetaFileTags.LAYER)) {
329
                                                                int layerListTag = parser.next();
330
                                                                boolean geoRefEnd = false;
331
                                                                while (!geoRefEnd){
332
                                                                        if(parser.getName() != null){
333
                                                                                if (parser.getName().equals(RasterMetaFileTags.PROJ)){
334
                                                                                        //System.out.println("PROJ:"+parser.nextText());
335
                                                                                } else if (parser.getName().equals(RasterMetaFileTags.BBOX)){
336
                                                                                        double[] values = parserExtent(parser);
337
                                                                                        originX = values[0];
338
                                                                                        originY = values[1];
339
                                                                                        w = values[2];
340
                                                                                        h = values[3];
341
                                                                                        pixelSizeX = values[4];
342
                                                                                        pixelSizeY = values[5];
343
                                                                                        georefOk = true;
344
                                                                                } else if (parser.getName().equals(RasterMetaFileTags.DIM)){
345
                                                                                        boolean DimEnd = false;
346
                                                                                        while (!DimEnd){
347
                                                                                                layerListTag = parser.next();
348
                                                                                                if(parser.getName() != null){        
349
                                                                                                        if (parser.getName().equals(RasterMetaFileTags.PX_WIDTH)){
350
                                                                                                                imageWidth = Double.parseDouble(parser.nextText());
351
                                                                                                        }else if (parser.getName().equals(RasterMetaFileTags.PX_HEIGHT)){
352
                                                                                                                imageHeight = Double.parseDouble(parser.nextText());
353
                                                                                                                DimEnd = true;
354
                                                                                                        }                                                                                                        
355
                                                                                                }
356
                                                                                        }
357
                                                                                        geoRefEnd = true;
358
                                                                                }
359
                                                                        }
360
                                                                        layerListTag = parser.next();
361
                                                                }
362
                                                        }
363
                                                        break;
364
                                                case KXmlParser.END_TAG:                                                        
365
                                                        break;
366
                                                case KXmlParser.TEXT:                                                        
367
                                                        break;
368
                                        }
369
                                        tag = parser.next();
370
                                }
371
                                parser.require(KXmlParser.END_DOCUMENT, null, null);
372
                        }
373
                        
374
                        if(georefOk){
375
                                rmfExists = true;
376
                                setExtentTransform(originX, originY, w, h, pixelSizeX, pixelSizeY);
377
                                extent = new Extent(originX, originY, originX + (pixelSizeX * imageWidth), originY + (pixelSizeY * imageHeight));
378
                        }
379
                        
380
                } catch (FileNotFoundException fnfEx) {
381
                } catch (XmlPullParserException xmlEx) {
382
                        xmlEx.printStackTrace();
383
                } catch (IOException e) {
384
                } 
385
                try{
386
                        if(fr != null)
387
                                fr.close();
388
                }catch(IOException ioEx){
389
                        //No est? abierto el fichero por lo que no hacemos nada
390
                }
391
        }
392

    
393
        /**
394
         * Calcula la transformaci?n que se produce sobre la vista cuando la imagen tiene un fichero .rmf
395
         * asociado. Esta transformaci?n tiene diferencias entre los distintos formatos por lo que debe calcularla
396
         * el driver correspondiente.
397
         * @param originX Origen de la imagen en la coordenada X
398
         * @param originY Origen de la imagen en la coordenada Y
399
         */
400
        abstract public void setExtentTransform(double originX, double originY, double w, double h, double psX, double psY);
401
        
402
        public static PxContour getContour(String fName, String name, IProjection proj) {
403
                PxContour contour = null;
404
                return contour;
405
        }
406
                
407
        /**
408
         * Obtiene el ancho de la imagen
409
         * @return Ancho de la imagen
410
         */
411
        abstract public int getWidth();
412
        
413
        /**
414
         * Obtiene el ancho de la imagen
415
         * @return Ancho de la imagen
416
         */
417
        abstract public int getHeight();
418

    
419
        /**
420
         * Reproyecci?n.
421
         * @param rp        Coordenadas de la transformaci?n
422
         */
423
        abstract public void reProject(ICoordTrans rp);
424

    
425
        /**
426
         * Asigna un nuevo Extent 
427
         * @param e        Extent
428
         */
429
        abstract public void setView(Extent e);
430
        
431
        /**
432
         * Obtiene el extent asignado
433
         * @return        Extent
434
         */
435
        abstract public Extent getView();
436
        
437
        public void setTransparency(boolean t) {
438
                doTransparency = t;
439
                tFilter = new PixelFilter(255);
440
        }
441
        
442
        /**
443
         * Asigna un valor de transparencia
444
         * @param t        Valor de transparencia
445
         */
446
        public void setTransparency(int t ) {
447
                doTransparency = true;
448
                tFilter = new SimplePixelFilter(255 - t);
449
        }
450
        
451
        public boolean getTransparency() { return doTransparency; }
452
        
453
        public void setAlpha(int alpha) {
454
                if (!doTransparency) setTransparency(255 - alpha);
455
                else tFilter.setAlpha(alpha);
456
        }
457
        public int getAlpha() {
458
                if (tFilter == null)
459
                        return 255;
460
                return tFilter.getAlpha();
461
        }
462
        
463
        public void setUpdatable(Component c) { updatable = c; }
464
        
465
        /**
466
         * Actualiza la imagen
467
         * @param width        ancho
468
         * @param height        alto
469
         * @param rp        Reproyecci?n
470
         * @return        img
471
         */
472
        abstract public Image updateImage(int width, int height, ICoordTrans rp);
473

    
474
        /**
475
         * Obtiene el valor del raster en la coordenada que se le pasa.
476
         * El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
477
         * raster.
478
         * @param x        coordenada X
479
         * @param y coordenada Y
480
         * @return
481
         */
482
        abstract public Object getData(int x, int y, int band);
483

    
484
        /**
485
         * Actualiza la/s banda/s especificadas en la imagen.
486
         * @param width                ancho
487
         * @param height        alto
488
         * @param rp                reproyecci?n
489
         * @param img                imagen
490
         * @param flags                que bandas [ RED_BAND | GREEN_BAND | BLUE_BAND ]
491
         * @return                img
492
         * @throws SupersamplingNotSupportedException
493
         */
494
        abstract public Image updateImage(int width, int height, ICoordTrans rp, Image img, int origBand, int destBand)throws SupersamplingNotSupportedException;
495

    
496
        public int getBandCount() { return bandCount; }
497
        
498
        /**
499
         * Asocia un colorBand al rojo, verde o azul.
500
         * @param flag cual (o cuales) de las bandas.
501
         * @param nBand        que colorBand
502
         */
503
        
504
        public void setBand(int flag, int bandNr) {
505
                if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) rBandNr = bandNr;
506
                if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) gBandNr = bandNr;
507
                if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) bBandNr = bandNr;
508
        }
509

    
510
        /**
511
         * Devuelve el colorBand activo en la banda especificada.
512
         * @param flag banda.
513
         */
514
        
515
        public int getBand(int flag) {
516
                if (flag == GeoRasterFile.RED_BAND) return rBandNr;
517
                if (flag == GeoRasterFile.GREEN_BAND) return gBandNr;
518
                if (flag == GeoRasterFile.BLUE_BAND) return bBandNr;
519
                return -1;
520
        }
521
        
522
        /**
523
         * @return Returns the dataType.
524
         */
525
        public int getDataType() {
526
                return dataType;
527
        }
528
        
529
        /**
530
         * @param dataType The dataType to set.
531
         */
532
        public void setDataType(int dataType) {
533
                this.dataType = dataType;
534
        }
535

    
536
        public IObjList getObjects() {
537
                // TODO hay que a?adir el raster a la lista de objetos
538
                IObjList oList = new PxObjList(proj);
539
                return oList;
540
        }
541
        
542
        /**
543
         * Calcula los par?metros de un worl file a partir de las esquinas del raster.
544
         *    1. X pixel size A
545
         *    2. X rotation term D
546
         *    3. Y rotation term B
547
         *    4. Y pixel size E
548
         *    5. X coordinate of upper left corner C
549
         *    6. Y coordinate of upper left corner F
550
         * where the real-world coordinates x',y' can be calculated from
551
         * the image coordinates x,y with the equations
552
         *  x' = Ax + By + C and y' = Dx + Ey + F.
553
         *  The signs of the first 4 parameters depend on the orientation
554
         *  of the image. In the usual case where north is more or less
555
         *  at the top of the image, the X pixel size will be positive
556
         *  and the Y pixel size will be negative. For a south-up image,
557
         *  these signs would be reversed.
558
         * 
559
         * You can calculate the World file parameters yourself based
560
         * on the corner coordinates. The X and Y pixel sizes can be
561
         *  determined simply by dividing the distance between two
562
         *  adjacent corners by the number of columns or rows in the image.
563
         *  The rotation terms are calculated with these equations:
564
         * 
565
         *  # B = (A * number_of_columns + C - lower_right_x') / number_of_rows * -1
566
         *  # D = (E * number_of_rows + F - lower_right_y') / number_of_columns * -1
567
         * 
568
         * @param corner (tl, tr, br, bl)
569
         * @return
570
         */
571
        public static double [] cornersToWorldFile(Point2D [] esq, Dimension size) {
572
                double a=0,b=0,c=0,d=0,e=0,f=0;
573
                double x1 = esq[0].getX(), y1 = esq[0].getY();
574
                double x2 = esq[1].getX(), y2 = esq[1].getY();
575
                double x3 = esq[2].getX(), y3 = esq[2].getY();
576
                double x4 = esq[3].getX(), y4 = esq[3].getY();
577
                // A: X-scale
578
                a = Math.abs( Math.sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
579
                      / size.getWidth());
580

    
581
                // E: negative Y-scale
582
                e =  - Math.abs(Math.sqrt((x1-x4)*(x1-x4)+
583
                      (y1-y4)*(y1-y4))/size.getHeight());
584

    
585
                // C, F: upper-left coordinates
586
                c = x1;
587
                f = y1;
588
                
589
                // B & D: rotation parameters
590
                b = (a * size.getWidth() + c - x3 ) / size.getHeight() * -1;
591
                d = (e * size.getHeight() + f - y3 ) / size.getWidth() * -1;
592

    
593
                double [] wf = {a,d,b,e,c,f}; 
594
                return wf;  
595
        }
596
    public static String printWF(String fName, Point2D [] esq, Dimension sz) {
597
            double [] wf = GeoRasterFile.cornersToWorldFile(esq, sz);
598
            System.out.println("wf para "+fName);
599
            System.out.println(esq+"\n"+sz);
600
            String wfData = "";
601
            for (int i=0; i<6; i++)
602
                    wfData += wf[i]+"\n";
603
                System.out.println(wfData);
604
                return wfData;
605
    }
606
    
607
    public static void saveWF(String fName, String data) throws IOException {
608
            FileWriter fw = new FileWriter(fName);
609
            fw.write(data);
610
            fw.flush();
611
            fw.close();
612
    }
613

    
614
        /**
615
         * Cosulta si hay que verificar la relaci?n de aspecto de la imagen, es decir comprueba que el ancho/alto
616
         * pasados a updateImage coinciden con el ancho/alto solicitado en setView a la imagen
617
         * @return true si est? verificando la relaci?n de aspecto. 
618
         */
619
        public boolean mustVerifySize() {
620
                return verifySize;
621
        }
622

    
623
        /**
624
         * Asigna el flag que dice si hay que verificar la relaci?n de aspecto de la imagen, es decir 
625
         * comprueba que el ancho/alto pasados a updateImage coinciden con el ancho/alto solicitado 
626
         * en setView a la imagen.
627
         * @return true si est? verificando la relaci?n de aspecto. 
628
         */
629
        public void setMustVerifySize(boolean verifySize) {
630
                this.verifySize = verifySize;
631
        }
632

    
633
        abstract public byte[] getWindow(int ulX, int ulY, int sizeX, int sizeY, int band);
634
        abstract public int getBlockSize();
635
        
636
        /**
637
         * Obtiene el objeto que contiene los metadatos. Este m?todo debe ser redefinido por los
638
         * drivers si necesitan devolver metadatos. 
639
         * @return
640
         */
641
        public Metadata getMetadata(){
642
                return null;
643
        }
644
        
645
        /**
646
         * Asigna un extent temporal que puede coincidir con el de la vista. Esto es 
647
         * util para cargar imagenes sin georreferenciar ya que podemos asignar el extent
648
         * que queramos para ajustarnos a una vista concreta
649
         * @param tempExtent The tempExtent to set.
650
         */
651
        public void setExtent(Extent ext) {
652
                this.extent = ext;
653
        }
654
        
655
        public boolean isGeoreferenced(){
656
                return true;
657
        }
658
}