Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / GeoRasterFile.java @ 6038

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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