Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / provider / DefaultRasterProvider.java @ 212

History | View | Annotate | Download (39.9 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.raster.impl.provider;
23

    
24
import java.awt.geom.AffineTransform;
25
import java.awt.geom.NoninvertibleTransformException;
26
import java.awt.geom.Point2D;
27
import java.io.File;
28
import java.lang.reflect.Constructor;
29
import java.lang.reflect.InvocationTargetException;
30
import java.util.Date;
31
import java.util.Iterator;
32

    
33
import org.cresques.cts.IProjection;
34
import org.gvsig.fmap.dal.DataParameters;
35
import org.gvsig.fmap.dal.DataServerExplorer;
36
import org.gvsig.fmap.dal.DataStoreParameters;
37
import org.gvsig.fmap.dal.coverage.RasterLibrary;
38
import org.gvsig.fmap.dal.coverage.RasterLocator;
39
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
40
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
41
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
42
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
43
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
44
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
45
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
46
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
47
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
48
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
49
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
50
import org.gvsig.fmap.dal.coverage.grid.render.TileListener;
51
import org.gvsig.fmap.dal.coverage.store.RasterFileStoreParameters;
52
import org.gvsig.fmap.dal.coverage.store.RasterStoreParameters;
53
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters;
54
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
55
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
56
import org.gvsig.fmap.dal.coverage.store.props.Histogram;
57
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
58
import org.gvsig.fmap.dal.coverage.util.FileUtils;
59
import org.gvsig.fmap.dal.coverage.util.RasterUtils;
60
import org.gvsig.fmap.dal.exception.OpenException;
61
import org.gvsig.fmap.dal.exception.ReadException;
62
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
63
import org.gvsig.fmap.dal.raster.spi.AbstractCoverageStoreProvider;
64
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
65
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
66
import org.gvsig.raster.impl.datastruct.DefaultNoData;
67
import org.gvsig.raster.impl.datastruct.ExtentImpl;
68
import org.gvsig.raster.impl.datastruct.serializer.ColorTableRmfSerializer;
69
import org.gvsig.raster.impl.datastruct.serializer.NoDataRmfSerializer;
70
import org.gvsig.raster.impl.store.AbstractRasterDataStore;
71
import org.gvsig.raster.impl.store.AbstractRasterStoreParameters;
72
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
73
import org.gvsig.raster.impl.store.properties.DataStoreHistogram;
74
import org.gvsig.raster.impl.store.properties.DataStoreMetadata;
75
import org.gvsig.raster.impl.store.properties.DataStoreStatistics;
76
import org.gvsig.raster.impl.store.rmf.ClassSerializer;
77
import org.gvsig.raster.impl.store.rmf.RmfBlocksManager;
78
import org.gvsig.raster.impl.store.serializer.ColorInterpretationRmfSerializer;
79
import org.gvsig.raster.impl.store.serializer.GeoInfoRmfSerializer;
80
import org.gvsig.raster.impl.store.serializer.ProjectionRmfSerializer;
81
import org.gvsig.raster.util.DefaultProviderServices;
82
import org.gvsig.tools.ToolsLocator;
83
import org.gvsig.tools.dynobject.DynObject;
84
import org.gvsig.tools.extensionpoint.ExtensionPoint;
85
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
86
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension;
87

    
88
/**
89
 * Manejador de ficheros raster georeferenciados.
90
 *
91
 * Esta clase abstracta es el ancestro de todas las clases que proporcionan
92
 * soporte para ficheros raster georeferenciados.<br>
93
 * Actua tambien como una 'Fabrica', ocultando al cliente la manera en que
94
 * se ha implementado ese manejo. Una clase nueva que soportara un nuevo
95
 * tipo de raster tendr?a que registrar su extensi?n o extensiones usando
96
 * el m?todo @see registerExtension.<br>
97
 * 
98
 * @author Nacho Brodin (nachobrodin@gmail.com)
99
 */
100
public abstract class DefaultRasterProvider extends AbstractCoverageStoreProvider implements RasterProvider {
101
        /**
102
         * Flags que representan a las bandas visualizables
103
         */
104
        public static final int                 RED_BAND               = 0x01;
105
        public static final int                 GREEN_BAND             = 0x02;
106
        public static final int                 BLUE_BAND              = 0x04;
107
        public static final int                 ALPHA_BAND             = 0x08;
108
        
109
        protected int                           bandCount              = 1;
110
        private int[]                           dataType               = null;
111
        protected double                        noData                 = 0;
112
        protected String                        wktProjection          = "";
113

    
114
        protected DataStoreStatistics           stats                  = new DataStoreStatistics(this);
115
        protected DataStoreHistogram            histogram              = null;
116
        protected DataStoreParameters           param                  = null;
117
        protected RmfBlocksManager              rmfBlocksManager       = null;
118
        protected ColorTable                    colorTable             = null;
119
        protected DataStoreColorInterpretation  colorInterpretation    = null;
120

    
121
        /**
122
         * Indica si el valor NoData esta activo
123
         */
124
        protected boolean                       noDataEnabled          = false;
125
        protected FileUtils                     fileUtil               = RasterLocator.getManager().getFileUtils();
126
        protected RasterUtils                   rasterUtil             = RasterLocator.getManager().getRasterUtils();
127
        
128
        protected IProjection                   proj                   = null;
129
        protected long                          fileSize               = 0;
130
        protected long                          bytesReaded            = 0;
131
        protected long                          lineCnt                = 0;
132
        protected String                        name;
133
        protected boolean                       mustTileRequest        = false;
134
        
135
        /**
136
         * Transformaci?n creada a partir de la informaci?n de georreferencia de la
137
         * propia imagen. Esta informaci?n est? en la cabecera o en ficheros
138
         * worldfile.
139
         */
140
        protected AffineTransform               ownTransformation      = null;
141
        /**
142
         * Transformaci?n asignada de forma externa, bien desde el fichero rmf o
143
         * asignada directamente por el usuario.
144
         */
145
        protected AffineTransform               externalTransformation = null;
146
        
147
        public DefaultRasterProvider(AbstractRasterStoreParameters params,
148
                        DataStoreProviderServices storeServices, DynObject metadata) {
149
                super(params, storeServices, metadata);
150
                if(params.getURI() != null) {
151
                        File f = new File(params.getURI());
152
                        if(f.exists())
153
                                setFileSize(f.length());
154
                }
155
                
156
                if(params.getURI() != null)
157
                        name = translateFileName(params.getURI());
158
                
159
                ownTransformation = new AffineTransform();
160
                externalTransformation = new AffineTransform();
161
        }
162
        
163
        public DefaultRasterProvider(DataStoreParameters params,
164
                        DataStoreProviderServices storeServices, DynObject metadata) {
165
                super(params, storeServices, metadata);
166
                if(((RemoteStoreParameters)params).getHost() != null) {
167
                        File f = new File(((RemoteStoreParameters)params).getHost());
168
                        if(f.exists())
169
                                setFileSize(f.length());
170
                }
171
                
172
                if(((RemoteStoreParameters)params).getHost() != null)
173
                        name = translateFileName(((RemoteStoreParameters)params).getHost());
174
                
175
                ownTransformation = new AffineTransform();
176
                externalTransformation = new AffineTransform();
177
        }
178
        
179
        public DefaultRasterProvider(String params) {
180
                super();
181
        }
182
        
183
        public DefaultRasterProvider() {
184
                super(null, null, null);
185
        }
186
        
187
        public String getFullName() {
188
                return getName();
189
        }
190
        
191
        public String getProviderName() {
192
                return getName();
193
        }
194
        
195
        /**
196
         * Acciones de inicilizaci?n comunes a todos los drivers.
197
         * Este m?todo debe ser llamado explicitamente por el constructor de cada driver.
198
         * Estas son acciones de inicializaci?n que se ejecutan despu?s del constructor de cada driver.
199
         * Las acciones que hayan de ser realizadas antes se definen en el constructor de RasterDataset.
200
         */
201
        protected void init() {
202
        }
203
        
204
        /*
205
         * (non-Javadoc)
206
         * @see org.gvsig.raster.impl.provider.RasterProvider#isTiled()
207
         */
208
        public boolean isTiled() {
209
                return mustTileRequest;
210
        }
211
        
212
        /*
213
         * (non-Javadoc)
214
         * @see java.lang.Object#clone()
215
         */
216
        public RasterProvider cloneProvider() {
217
                try {
218
                        DefaultRasterProvider provider = singleDatasetInstance(param);
219
                        // Estas van por referencia
220
                        provider.histogram = histogram;
221
                        provider.stats = stats;
222
                        return provider;
223
                } catch (NotSupportedExtensionException e) {
224
                        e.printStackTrace();
225
                } catch (RasterDriverException e) {
226
                        e.printStackTrace();
227
                }
228
                return null;
229
        }
230
        
231
        /**
232
         * Factoria para abrir distintos tipos de raster.
233
         * @param fName Nombre del fichero.
234
         *
235
         * @return SingleDataset, o null si hay problemas.
236
         */
237
        @SuppressWarnings("unchecked")
238
        public static DefaultRasterProvider singleDatasetInstance(DataStoreParameters param) throws NotSupportedExtensionException, RasterDriverException {
239
                String idFormat = null;
240
                Class clase = null;
241
                DefaultRasterProvider grf = null;
242
                
243
                //Remote services
244
                if(param instanceof RemoteStoreParameters) {
245
                        ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
246
                        ExtensionPoint point = extensionPoints.get("RasterReader");
247
                        Extension ext = point.get("wms");
248
                        if (ext != null)
249
                                clase = ext.getExtension();
250

    
251
                } else {
252
                        //Files
253
                        if (((RasterStoreParameters)param).getURI() != null)
254
                                idFormat = RasterLocator.getManager().getFileUtils().getExtensionFromFileName(((RasterStoreParameters)param).getURI());
255

    
256

    
257
                        ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
258

    
259
                        if (idFormat != null) {
260
                                ExtensionPoint point = extensionPoints.get("RasterReader");
261
                                Extension ext = point.get(idFormat);
262
                                if (ext != null)
263
                                        clase = ext.getExtension();
264
                        }
265

    
266
                        //Driver by default
267
                        if (clase == null) {
268
                                ExtensionPoint pointDefaultReader = extensionPoints.get("DefaultDriver");
269
                                Extension extReader = pointDefaultReader.get("reader");
270
                                clase = extReader.getExtension();
271
                        }
272

    
273
                }
274

    
275
                Class [] args = {param.getClass(), AbstractRasterDataStore.class};
276
                try {
277
                        Constructor hazNuevo = clase.getConstructor(args);
278
                        Object [] args2 = {param, null};
279
                        grf = (DefaultRasterProvider) hazNuevo.newInstance(args2);
280
                } catch (SecurityException e) {
281
                        throw new RasterDriverException("Error SecurityException in open", e);
282
                } catch (NoSuchMethodException e) {
283
                        throw new RasterDriverException("Error NoSuchMethodException in open", e);
284
                } catch (IllegalArgumentException e) {
285
                        throw new RasterDriverException("Error IllegalArgumentException in open", e);
286
                } catch (InstantiationException e) {
287
                        throw new RasterDriverException("Error InstantiationException in open", e);
288
                } catch (IllegalAccessException e) {
289
                        throw new RasterDriverException("Error IllegalAccessException in open", e);
290
                } catch (InvocationTargetException e) {
291
                        throw new NotSupportedExtensionException("Error opening this image with " + clase, e);
292
                }
293
                return grf;
294
        }
295
        
296
        /**
297
         * Factoria para abrir distintos tipos de raster.
298
         * @param fName Nombre del fichero.
299
         *
300
         * @return SingleDataset, o null si hay problemas.
301
         */
302
        @SuppressWarnings("unchecked")
303
        public static DefaultRasterProvider singleDatasetInstance(String param) throws NotSupportedExtensionException, RasterDriverException {
304
                String idFormat = null;
305

    
306
                if (param instanceof String)
307
                        idFormat = RasterLocator.getManager().getFileUtils().getExtensionFromFileName(((String) param));
308
                
309
                DefaultRasterProvider grf = null;
310

    
311
                Class clase = null;
312
                ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
313
                if (idFormat != null) {
314
                        ExtensionPoint point = extensionPoints.get("RasterReader");
315
                        Extension ext = point.get(idFormat);
316
                        if (ext != null)
317
                                clase = ext.getExtension();
318
                }
319

    
320
                if (clase == null) {
321
                        ExtensionPoint pointDefaultReader = extensionPoints.get("DefaultDriver");
322
                        Extension extReader = pointDefaultReader.get("reader");
323
                        clase = extReader.getExtension();
324
                }
325

    
326
                Class [] args = {String.class};
327
                try {
328
                        Constructor hazNuevo = clase.getConstructor(args);
329
                        Object [] args2 = {param};
330
                        grf = (DefaultRasterProvider) hazNuevo.newInstance(args2);
331
                } catch (SecurityException e) {
332
                        throw new RasterDriverException("Error SecurityException in open", e);
333
                } catch (NoSuchMethodException e) {
334
                        throw new RasterDriverException("Error NoSuchMethodException in open", e);
335
                } catch (IllegalArgumentException e) {
336
                        throw new RasterDriverException("Error IllegalArgumentException in open", e);
337
                } catch (InstantiationException e) {
338
                        throw new RasterDriverException("Error InstantiationException in open", e);
339
                } catch (IllegalAccessException e) {
340
                        throw new RasterDriverException("Error IllegalAccessException in open", e);
341
                } catch (InvocationTargetException e) {
342
                        throw new NotSupportedExtensionException("Error opening this image with " + clase, e);
343
                }
344
                return grf;
345
        }
346

    
347
        /**
348
         * Carga un fichero raster. Puede usarse para calcular el extent e instanciar
349
         * un objeto de este tipo.
350
         */
351
        abstract public RasterProvider load();
352

    
353
        /**
354
         * Cierra el fichero y libera los recursos.
355
         */
356
        abstract public void close();
357

    
358
        /**
359
         * Obtiene el ancho de la imagen
360
         * @return Ancho de la imagen
361
         */
362
        abstract public double getWidth();
363

    
364
        /**
365
         * Obtiene el ancho de la imagen
366
         * @return Ancho de la imagen
367
         */
368
        abstract public double getHeight();
369

    
370
        /**
371
         * Asigna un nuevo Extent
372
         * @param e        Extent
373
         */
374
        public abstract void setView(Extent e);
375

    
376
        /**
377
         * Obtiene el extent asignado
378
         * @return        Extent
379
         */
380
        public abstract Extent getView();
381

    
382
        /**
383
         * Obtiene el valor del raster en la coordenada que se le pasa.
384
         * El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
385
         * raster.
386
         * @param x        coordenada X
387
         * @param y coordenada Y
388
         * @return
389
         */
390
        abstract public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
391

    
392
        /**
393
         * Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
394
         * No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los
395
         * pixeles de disco.
396
         * @param x Posici?n X superior izquierda
397
         * @param y Posici?n Y superior izquierda
398
         * @param w Ancho en coordenadas reales
399
         * @param h Alto en coordenadas reales
400
         * @param rasterBuf        Buffer de datos
401
         * @param bandList
402
         * @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
403
         * @return Buffer de datos
404
         */
405
         abstract public void getWindowRaster(double minX, double minY, double maxX, double maxY, 
406
                         int bufWidth, int bufHeight, BandList bandList, TileListener listener, int frameInPx) throws ProcessInterruptedException, RasterDriverException;
407
        
408
        /**
409
         * Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
410
         * No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los
411
         * pixeles de disco.
412
         * @param ulx Posici?n X superior izquierda
413
         * @param uly Posici?n Y superior izquierda
414
         * @param lrx Posici?n X inferior derecha
415
         * @param lry Posici?n Y inferior derecha
416
         * @param rasterBuf        Buffer de datos
417
         * @param bandList
418
         * @return Buffer de datos
419
         */
420
        abstract public Buffer getWindowRaster(double ulx, double uly, double lrx, double lry, 
421
                        BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException;
422

    
423
        /**
424
         * Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
425
         * No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los
426
         * pixeles de disco.
427
         * @param x Posici?n X superior izquierda
428
         * @param y Posici?n Y superior izquierda
429
         * @param w Ancho en coordenadas reales
430
         * @param h Alto en coordenadas reales
431
         * @param rasterBuf        Buffer de datos
432
         * @param bandList
433
         * @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
434
         * @return Buffer de datos
435
         */
436
        abstract public Buffer getWindowRaster(double x, double y, double w, double h, 
437
                        BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException;
438

    
439
        /**
440
         * Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
441
         * Se aplica supersampleo o subsampleo dependiendo del tama?o del buffer especificado.
442
         *
443
         * @param minX Posici?n m?nima X superior izquierda
444
         * @param minY Posici?n m?nima Y superior izquierda
445
         * @param maxX Posici?n m?xima X inferior derecha
446
         * @param maxY Posici?n m?xima Y inferior derecha
447
         * @param bufWidth Ancho del buffer de datos
448
         * @param bufHeight Alto del buffer de datos
449
         * @param rasterBuf        Buffer de datos
450
         * @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
451
         * @param bandList
452
         * @return Buffer de datos
453
         */
454
        abstract public Buffer getWindowRaster(double minX, double minY, double maxX, double maxY, 
455
                        int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException;
456

    
457
        /**
458
         * Obtiene una ventana de datos de la imagen a partir de coordenadas pixel.
459
         * No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los
460
         * pixeles de disco.
461
         * @param x Posici?n X superior izquierda
462
         * @param y Posici?n Y superior izquierda
463
         * @param w Ancho en coordenadas reales
464
         * @param h Alto en coordenadas reales
465
         * @param rasterBuf        Buffer de datos
466
         * @param bandList
467
         * @return Buffer de datos
468
         */
469
        abstract public Buffer getWindowRaster(int x, int y, int w, int h, 
470
                        BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException;
471

    
472
        /**
473
         * Obtiene una ventana de datos de la imagen a partir de coordenadas pixel.
474
         * Se aplica supersampleo o subsampleo dependiendo del tama?o del buffer especificado.
475
         *
476
         * @param x Posici?n X superior izquierda
477
         * @param y Posici?n Y superior izquierda
478
         * @param w Ancho en coordenadas reales
479
         * @param h Alto en coordenadas reales
480
         * @param bufWidth Ancho del buffer de datos
481
         * @param bufHeight Alto del buffer de datos
482
         * @param rasterBuf        Buffer de datos
483
         * @param bandList
484
         * @return Buffer de datos
485
         */
486
        abstract public Buffer getWindowRaster(int x, int y, int w, int h, int bufWidth, int bufHeight, 
487
                        BandList bandList, Buffer rasterBuf)throws ProcessInterruptedException, RasterDriverException;
488

    
489
        abstract public int getBlockSize();
490
        
491
        /*
492
         * (non-Javadoc)
493
         * @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewHeight(int, int)
494
         */
495
        abstract public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
496

    
497
        /**
498
         * Informa de si el dataset soporta overviews o no.
499
         * @return true si soporta overviews y false si no las soporta.
500
         */
501
        abstract public boolean overviewsSupport();
502
        
503
        /**
504
         * Lee una l?nea completa del raster y devuelve un array del tipo correcto. Esta funci?n es util
505
         * para una lectura rapida de todo el fichero sin necesidad de asignar vista.
506
         * @param nLine N?mero de l?nea a leer
507
         * @param band Banda requerida
508
         * @return Object que es un array unidimendional del tipo de datos del raster
509
         * @throws InvalidSetViewException
510
         * @throws FileNotOpenException
511
         * @throws RasterDriverException
512
         */
513
        abstract public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
514

    
515
        /**
516
         * Lee un bloque completo de datos del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util
517
         * para una lectura rapida de todo el fichero sin necesidad de asignar vista.
518
         * @param pos Posici?n donde se empieza  a leer
519
         * @param blockHeight Altura m?xima del bloque leido
520
         * @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas)
521
         * @throws InvalidSetViewException
522
         * @throws FileNotOpenException
523
         * @throws RasterDriverException
524
         */
525
        abstract public Object readBlock(int pos, int blockHeight)
526
                throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException;
527

    
528
        /**
529
         * Carga metadatos desde el fichero Rmf si estos existen
530
         * @param fName Nombre del fichero
531
         * @throws ParsingException
532
         */
533
        protected void loadFromRmf(RmfBlocksManager manager) throws ParsingException {
534
                if (!manager.checkRmf())
535
                        return;
536

    
537
                if (!new File(manager.getPath()).exists())
538
                        return;
539

    
540
                GeoInfoRmfSerializer geoInfoSerializer = new GeoInfoRmfSerializer(this);
541
                ColorTableRmfSerializer colorTableSerializer = new ColorTableRmfSerializer();
542
                NoDataRmfSerializer noDataSerializer = new NoDataRmfSerializer(new DefaultNoData(noData, RasterLibrary.NODATATYPE_LAYER));
543
                ColorInterpretationRmfSerializer colorInterpSerializer = new ColorInterpretationRmfSerializer();
544
                ProjectionRmfSerializer projectionRmfSerializer = new ProjectionRmfSerializer();
545

    
546
                manager.addClient(geoInfoSerializer);
547
                manager.addClient(colorTableSerializer);
548
                manager.addClient(noDataSerializer);
549
                manager.addClient(colorInterpSerializer);
550
                manager.addClient(projectionRmfSerializer);
551

    
552
                manager.read(null);
553

    
554
                manager.removeAllClients();
555

    
556
                if (colorTableSerializer.getResult() != null)
557
                        setColorTable((ColorTable) colorTableSerializer.getResult());
558

    
559
                if (noDataSerializer.getResult() != null) {
560
                        noData = ((DefaultNoData) noDataSerializer.getResult()).getValue();
561
                        noDataEnabled = (((DefaultNoData) noDataSerializer.getResult()).getType() != RasterLibrary.NODATATYPE_DISABLED);
562
                }
563

    
564
                if (colorInterpSerializer.getResult() != null) {
565
                        DataStoreColorInterpretation ci = (DataStoreColorInterpretation) colorInterpSerializer.getResult();
566
                        setColorInterpretation(ci);
567
                        if (ci.getBand(DataStoreColorInterpretation.ALPHA_BAND) != -1)
568
                                getTransparency().setTransparencyBand(ci.getBand(DataStoreColorInterpretation.ALPHA_BAND));
569
                }
570

    
571
                if (projectionRmfSerializer.getResult() != null)
572
                        wktProjection = RasterLocator.getManager().getCRSUtils().convertIProjectionToWkt((IProjection) projectionRmfSerializer.getResult());
573
        }
574

    
575
        /**
576
         * Obtiene el n?nero de bandas del fichero
577
         * @return Entero que representa el n?mero de bandas
578
         */
579
        public int getBandCount() {
580
                return bandCount;
581
        }
582

    
583
        /**
584
         * @return Returns the dataType.
585
         */
586
        public int[] getDataType() {
587
                return dataType;
588
        }
589

    
590
        /**
591
         * @param dataType The dataType to set.
592
         */
593
        public void setDataType(int[] dataType) {
594
                this.dataType = dataType;
595
        }
596

    
597
        /*
598
         * (non-Javadoc)
599
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeX()
600
         */
601
        public double getPixelSizeX() {
602
                return externalTransformation.getScaleX();
603
        }
604

    
605
        /*
606
         * (non-Javadoc)
607
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeY()
608
         */
609
        public double getPixelSizeY() {
610
                return externalTransformation.getScaleY();
611
        }
612

    
613
        /**
614
         * Obtiene el valor NoData asociado al raster. Si hay un valor en el fichero
615
         * RMF se devuelve este, sino se buscar? en la cabecera del raster o metadatos de
616
         * este. Si finalmente no encuentra ninguno se devuelve el valor por defecto
617
         * definido en la libreria.
618
         * @return
619
         */
620
        public double getNoDataValue() {
621
                return noData;
622
        }
623

    
624
        /**
625
         * Pone el valor original de noData. Primero lo consulta del valor del metadata
626
         * y luego del RMF.
627
         */
628
        public void resetNoDataValue() {
629
                /**
630
                 * Intentamos recuperar el valor del metadatas, en caso de no encontrarlo le
631
                 * asignamos el noData por defecto
632
                 */
633
                noDataEnabled = false;
634
                do {
635
                        if (getMetadata() == null) {
636
                                noData = RasterLibrary.defaultNoDataValue;
637
                                break;
638
                        }
639

    
640
                        if (getMetadata().getNoDataValue().length == 0) {
641
                                noData = RasterLibrary.defaultNoDataValue;
642
                                break;
643
                        }
644

    
645
                        noData = getMetadata().getNoDataValue()[0];
646
                        noDataEnabled = getMetadata().isNoDataEnabled();
647
                } while (false);
648

    
649
                try {
650
                        DefaultNoData noDataObject = (DefaultNoData) loadObjectFromRmf(DefaultNoData.class, null);
651
                        if (noDataObject != null) {
652
                                if (noDataObject.getType() > 0)
653
                                        noData = noDataObject.getValue();
654
                                noDataEnabled = (noDataObject.getType() > 0);
655
                        }
656
                } catch (RmfSerializerException e) {
657
                }
658
        }
659

    
660
        /**
661
         * Establece el valor del NoData
662
         * @param value
663
         */
664
        public void setNoDataValue(double value) {
665
                noData = value;
666
                noDataEnabled = true;
667
        }
668

    
669
        /**
670
         * Dice si el fichero tiene georreferenciaci?n o no.
671
         * @return true si tiene georreferenciaci?n y false si no la tiene
672
         */
673
        public boolean isGeoreferenced(){
674
                return true;
675
        }
676

    
677
        /**
678
         * Dado unas coordenadas reales, un tama?o de buffer y un tama?o de raster.
679
         * Si el buffer es de mayor tama?o que el raster (supersampleo) quiere decir que
680
         * por cada pixel de buffer se repiten varios del raster. Esta funci?n calcula el
681
         * n?mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
682
         * buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
683
         * solicitada es real y puede no caer sobre un pixel completo. Este calculo es
684
         * util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
685
         * el driver autom?ticamente.
686
         * @param dWorldTLX Coordenada real X superior izquierda
687
         * @param dWorldTLY Coordenada real Y superior izquierda
688
         * @param dWorldBRX Coordenada real X inferior derecha
689
         * @param dWorldBRY Coordenada real Y inferior derecha
690
         * @param nWidth Ancho del raster
691
         * @param nHeight Alto del raster
692
         * @param bufWidth Ancho del buffer
693
         * @param bufHeight Alto del buffer
694
         * @return Array de dos elementos con el desplazamiento en X e Y.
695
         */
696
        public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
697
                        double nWidth, double nHeight, int bufWidth, int bufHeight) {
698

    
699
                Point2D p1 = new Point2D.Double(dWorldTLX, dWorldTLY);
700
                Point2D p2 = new Point2D.Double(dWorldBRX, dWorldBRY);
701

    
702
                Point2D tl = worldToRaster(new Point2D.Double(p1.getX(), p1.getY()));
703
                Point2D br = worldToRaster(new Point2D.Double(p2.getX(), p2.getY()));
704

    
705
                double wPx = (bufWidth / Math.abs(br.getX() - tl.getX()));
706
                double hPx = (bufHeight / Math.abs(br.getY() - tl.getY()));
707

    
708
                int x = (int)((tl.getX() > br.getX()) ? Math.floor(br.getX()) : Math.floor(tl.getX()));
709
                int y = (int)((tl.getY() > br.getY()) ? Math.floor(br.getY()) : Math.floor(tl.getY()));
710

    
711
                double a = (tl.getX() > br.getX()) ? (Math.abs(br.getX() - x)) : (Math.abs(tl.getX() - x));
712
                double b = (tl.getY() > br.getY()) ? (Math.abs(br.getY() - y)) : (Math.abs(tl.getY() - y));
713

    
714
                                double stpX = (int)((a * bufWidth) / Math.abs(br.getX() - tl.getX()));
715
                double stpY = (int)((b * bufHeight) / Math.abs(br.getY() - tl.getY()));
716

    
717
                return new double[]{stpX, stpY, wPx, hPx};
718
        }
719

    
720
        /**
721
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
722
         * @param pt Punto a transformar
723
         * @return punto transformado en coordenadas del mundo
724
         */
725
        public Point2D rasterToWorld(Point2D pt) {
726
                Point2D p = new Point2D.Double();
727
                externalTransformation.transform(pt, p);
728
                return p;
729
        }
730

    
731
        /**
732
         * Convierte un punto desde del mundo a coordenadas pixel.
733
         * @param pt Punto a transformar
734
         * @return punto transformado en coordenadas pixel
735
         */
736
        public Point2D worldToRaster(Point2D pt) {
737
                Point2D p = new Point2D.Double();
738
                try {
739
                        externalTransformation.inverseTransform(pt, p);
740
                } catch (NoninvertibleTransformException e) {
741
                        return pt;
742
                }
743
                return p;
744
        }
745

    
746
        /**
747
         * Calcula el extent en coordenadas del mundo real
748
         * @return Extent
749
         */
750
        public Extent getExtent() {
751
                return new ExtentImpl(        rasterToWorld(new Point2D.Double(0, 0)),
752
                                                        rasterToWorld(new Point2D.Double(getWidth(), getHeight())),
753
                                                        rasterToWorld(new Point2D.Double(getWidth(), 0)),
754
                                                        rasterToWorld(new Point2D.Double(0, getHeight())));
755
        }
756

    
757
        /**
758
         * Calcula el extent en coordenadas del mundo real sin rotaci?n. Solo coordenadas y tama?o de pixel
759
         * @return Extent
760
         */
761
        public Extent getExtentWithoutRot() {
762
                AffineTransform at = new AffineTransform(        externalTransformation.getScaleX(), 0,
763
                                                                                                        0, externalTransformation.getScaleY(),
764
                                                                                                        externalTransformation.getTranslateX(), externalTransformation.getTranslateY());
765
                Point2D p1 = new Point2D.Double(0, 0);
766
                Point2D p2 = new Point2D.Double(getWidth(), getHeight());
767
                at.transform(p1, p1);
768
                at.transform(p2, p2);
769
                return new ExtentImpl(p1, p2);
770
        }
771

    
772
        /**
773
         * ASigna el par?metro de inicializaci?n del driver.
774
         */
775
        public void setParam(DataStoreParameters param) {
776
                if(param instanceof RasterStoreParameters)
777
                        this.name = ((RasterStoreParameters)param).getURI();
778
                if(param instanceof RemoteStoreParameters)
779
                        this.name = ((RemoteStoreParameters)param).getHost();
780
                this.param = param;
781
        }
782

    
783
        /*
784
         * (non-Javadoc)
785
         * @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewWidth(int, int)
786
         */
787
        abstract public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
788

    
789
        /**
790
         * Obtiene el gestor de ficheros RMF
791
         * @return RmfBloksManager
792
         */
793
        public RmfBlocksManager getRmfBlocksManager() {
794
                if (rmfBlocksManager == null) {
795
                        String fileRMF = fileUtil.getNameWithoutExtension(getFName()) + ".rmf";
796
                        rmfBlocksManager = new RmfBlocksManager(fileRMF);
797
                }
798
                return rmfBlocksManager;
799
        }
800

    
801
        /*
802
         * (non-Javadoc)
803
         * @see org.gvsig.raster.impl.provider.RasterProvider#isInside(java.awt.geom.Point2D)
804
         */
805
        public boolean isInside(Point2D p){
806
                //Realizamos los calculos solo si el punto est? dentro del extent de la imagen rotada, as? nos ahorramos los calculos
807
                //cuando el puntero est? fuera
808

    
809
                Point2D pt = new Point2D.Double();
810
                try {
811

    
812
                        getAffineTransform().inverseTransform(p, pt);
813
                        if(        pt.getX() >= 0 && pt.getX() < getWidth() &&
814
                                        pt.getY() >= 0 && pt.getY() < getHeight())
815
                                return true;
816
                } catch (NoninvertibleTransformException e) {
817
                        return false;
818
                }
819

    
820
                return false;
821
        }
822

    
823
        /**
824
         * Consulta de si un raster tiene rotaci?n o no.
825
         * @return true si tiene rotaci?n y false si no la tiene.
826
         */
827
        public boolean isRotated() {
828
                if(externalTransformation.getShearX() != 0 || externalTransformation.getShearY() != 0)
829
                        return true;
830
                return false;
831
        }
832

    
833
        /**
834
         * Devuelve si el RasterDataSet tiene el valor noData activo
835
         * @return the noDataEnabled
836
         */
837
        public boolean isNoDataEnabled() {
838
                return noDataEnabled;
839
        }
840

    
841
        /**
842
         * Define si el RasterDataSet tiene el valor noData activo
843
         * @param noDataEnabled the noDataEnabled to set
844
         */
845
        public void setNoDataEnabled(boolean noDataEnabled) {
846
                this.noDataEnabled = noDataEnabled;
847
        }
848

    
849
        /**
850
         * Devuelve si el Dataset es reproyectable
851
         * @return
852
         */
853
        public boolean isReproyectable() {
854
                return false;
855
        }
856

    
857
        public String getWktProjection() {
858
                return wktProjection;
859
        }
860

    
861
        /*
862
         * (non-Javadoc)
863
         * @see org.gvsig.raster.impl.dataset.RasterProvider#saveObjectToRmf(java.lang.Class, java.lang.Object)
864
         */
865
        @SuppressWarnings("unchecked")
866
        public void saveObjectToRmf(Class class1, Object value) throws RmfSerializerException {
867
                ((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).saveObjectToRmfFile(getRmfBlocksManager(), class1, value);
868
        }
869

    
870
        /**
871
         * Carga un objecto desde un serializador del tipo class1. Usa value para iniciar dicho
872
         * serializador
873
         *
874
         * @param class1
875
         * @param value
876
         * @return
877
         * @throws RmfSerializerException
878
         */
879
        @SuppressWarnings("unchecked")
880
        private static Object loadObjectFromRmfFile(RmfBlocksManager blocksManager, Class class1, Object value) throws RmfSerializerException {
881
                ClassSerializer serializerObject = ((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).getSerializerObject(class1, value);
882

    
883
                if (serializerObject == null)
884
                        throw new RmfSerializerException("No se ha podido encontrar el serializador para el Rmf");
885

    
886
                if (!blocksManager.checkRmf())
887
                        throw new RmfSerializerException("Error al comprobar el fichero Rmf");
888

    
889
                blocksManager.addClient(serializerObject);
890
                try {
891
                        blocksManager.read(null);
892
                } catch (ParsingException e) {
893
                        throw new RmfSerializerException("Error al leer el fichero Rmf", e);
894
                }
895
                blocksManager.removeAllClients();
896

    
897
                return serializerObject.getResult();
898
        }
899

    
900
        /*
901
         * (non-Javadoc)
902
         * @see org.gvsig.raster.impl.dataset.RasterProvider#loadObjectFromRmf(java.lang.Class, java.lang.Object)
903
         */
904
        @SuppressWarnings("unchecked")
905
        public Object loadObjectFromRmf(Class class1, Object value) throws RmfSerializerException {
906
                return loadObjectFromRmfFile(getRmfBlocksManager(), class1, value);
907
        }
908

    
909
        /**
910
         * Carga un objeto del fichero RMF especificado por parametro
911
         * @param file
912
         * @param class1
913
         * @param value
914
         * @return
915
         * @throws RmfSerializerException
916
         */
917
        @SuppressWarnings("unchecked")
918
        public static Object loadObjectFromRmfFile(String file, Class class1, Object value) throws RmfSerializerException {
919
                String fileRMF = RasterLocator.getManager().getFileUtils().getNameWithoutExtension(file) + ".rmf";
920
                RmfBlocksManager blocksManager = new RmfBlocksManager(fileRMF);
921
                return loadObjectFromRmfFile(blocksManager, class1, value);
922
        }
923

    
924
        /**
925
         * Guarda en el RMF el objecto actual en caso de que exista un serializador para el
926
         * @param value
927
         * @throws RmfSerializerException
928
         */
929
        public void saveObjectToRmf(Object value) throws RmfSerializerException {
930
                saveObjectToRmf(value.getClass(), value);
931
        }
932

    
933
        /**
934
         * Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
935
         * Usa value para iniciar dicho serializador
936
         * @param value
937
         * @return
938
         * @throws RmfSerializerException
939
         */
940
        public Object loadObjectFromRmf(Object value) throws RmfSerializerException {
941
                return loadObjectFromRmf(value.getClass(), value);
942
        }
943
        
944
        /*
945
         * (non-Javadoc)
946
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getDatasetCount()
947
         */
948
        public int getDatasetCount() {
949
                return 1;
950
        }
951
        
952

    
953
        public double getCellSize() {
954
                try {
955
                        Extent e = getExtent();
956
                        double dCellsize = (e.getMax().getX() - e.getMin().getX() ) / getWidth();
957
                        return dCellsize;
958
                } catch (NullPointerException e) {
959
                        return 1;
960
                }
961
        }
962
        
963
        
964
        public RasterProvider newProvider() {
965
                return null;
966
        }
967
        
968
        /*
969
         * (non-Javadoc)
970
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getColorTable()
971
         */
972
        public ColorTable getColorTable() {
973
                return colorTable;
974
        }
975
        
976
        /**
977
         * Define el objeto paleta. Si se define null quiere decir que no tiene paleta
978
         * para su visualizaci?n.
979
         * @param value
980
         */
981
        public void setColorTable(ColorTable value) {
982
                colorTable = value;
983
        }
984

    
985
        /*
986
         * (non-Javadoc)
987
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getTransparency()
988
         */
989
        public Transparency getTransparency() {
990
                return null;
991
        }
992
        
993
        /*
994
         * (non-Javadoc)
995
         * @see org.gvsig.raster.impl.provider.RasterProvider#getMetadata()
996
         */
997
        public DataStoreMetadata getMetadata() {
998
                return null;
999
        }
1000
        
1001
        /*
1002
         * (non-Javadoc)
1003
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getColorInterpretation()
1004
         */
1005
        public ColorInterpretation getColorInterpretation(){
1006
                return colorInterpretation;
1007
        }
1008

    
1009
        /**
1010
         * Asigna el objeto que contiene que contiene la interpretaci?n de
1011
         * color por banda
1012
         * @param DataStoreColorInterpretation
1013
         */
1014
        public void setColorInterpretation(DataStoreColorInterpretation colorInterpretation){
1015
                this.colorInterpretation = colorInterpretation;
1016
        }
1017
        
1018
        /*
1019
         * (non-Javadoc)
1020
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getStatistics()
1021
         */
1022
        public DataStoreStatistics getStatistics() {
1023
                return stats;
1024
        }
1025
        
1026
        /*
1027
         * (non-Javadoc)
1028
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getHistogram()
1029
         */
1030
        public Histogram getHistogram() {
1031
                if (histogram == null)
1032
                        histogram = new DataStoreHistogram(this);
1033
                return histogram;
1034
        }
1035
        
1036
    //****************************************************
1037
        //*********Implementing Disposable methods************
1038
        //****************************************************
1039
    
1040
    /*
1041
     * (non-Javadoc)
1042
     * @see org.gvsig.tools.dispose.impl.AbstractDisposable#doDispose()
1043
     */
1044
    public void doDispose() {
1045
            
1046
    }
1047
    
1048
    //****************************************************
1049
        //*****Implementing DataStoreProvider methods*********
1050
        //****************************************************
1051
    
1052
    /**
1053
     * Gets the specific parameter. All of them inherit from RasterStoreParameters
1054
     */
1055
    //public abstract RasterStoreParameters getRasterParameters();
1056
    
1057
        @Override
1058
        public DataServerExplorer getExplorer() throws ReadException,
1059
                        ValidateDataParametersException {
1060
            /*DataManager manager = DALLocator.getDataManager();
1061
                FilesystemServerExplorerParameters params;
1062
                try {
1063
                        params = (FilesystemServerExplorerParameters) manager
1064
                                        .createServerExplorerParameters(FilesystemServerExplorer.NAME);
1065
                        params.setRoot(((AbstractRasterStoreParameters)this.getDataParameters()).getFile().getParent());
1066
                        return manager.createServerExplorer(params);
1067
                } catch (DataException e) {
1068
                        throw new ReadException(this.getName(), e);
1069
                }*/
1070
            return null;
1071
        }
1072
  
1073
        
1074
        /**
1075
         * Returs the DataParameters
1076
         * @return
1077
         */
1078
        public DataParameters getDataParameters() {
1079
                return getDataStoreParameters();
1080
        }
1081

    
1082
        /*
1083
         * (non-Javadoc)
1084
         * @see org.gvsig.fmap.dal.spi.DataStoreProvider#getChilds()
1085
         */
1086
        @SuppressWarnings("unchecked")
1087
        public Iterator getChilds() {
1088
                return null;
1089
        }
1090

    
1091
        /*
1092
         * (non-Javadoc)
1093
         * @see org.gvsig.fmap.dal.spi.DataStoreProvider#getResource()
1094
         */
1095
        public ResourceProvider getResource() {
1096
                return null;
1097
        }
1098

    
1099
        /*
1100
         * (non-Javadoc)
1101
         * @see org.gvsig.fmap.dal.spi.DataStoreProvider#getSourceId()
1102
         */
1103
        public Object getSourceId() {
1104
                if( this.getDataParameters() instanceof RasterFileStoreParameters)
1105
                        return ((RasterFileStoreParameters)this.getDataParameters()).getFile();
1106
                else
1107
                        return ((RasterStoreParameters)this.getDataParameters()).getURI();
1108
        }
1109

    
1110
        /*
1111
         * (non-Javadoc)
1112
         * @see org.gvsig.fmap.dal.spi.DataStoreProvider#open()
1113
         */
1114
        public void open() throws OpenException {
1115
        }
1116
        
1117
        /**
1118
         * Traduce el nombre del fichero por un alias asignado por el propio driver.
1119
         * Cuando es traducido por un alias el driver intentar? abrir el alias y no el
1120
         * fichero. Esto es util porque algunos formatos tienen la extensi?n en el
1121
         * fichero de cabecera pero lo que se abre realmente es el fichero de datos.
1122
         * @param fileName
1123
         * @return
1124
         */
1125
        public String translateFileName(String fileName) {
1126
                return fileName;
1127
        }
1128

    
1129
        public String getFName() {
1130
                return name;
1131
        }
1132

    
1133
        public void setFName(String n) {
1134
                name = n;
1135
        }
1136

    
1137
        public long getFileSize() {
1138
                return fileSize;
1139
        }
1140

    
1141
        public void setFileSize(long sz) {
1142
                fileSize = sz;
1143
        }
1144

    
1145
        /*
1146
         * (non-Javadoc)
1147
         * @see org.gvsig.raster.impl.provider.RasterProvider#getProjection()
1148
         */
1149
        public IProjection getProjection() {
1150
                return proj;
1151
        }
1152

    
1153
        public void setProjection(IProjection p) {
1154
                proj = p;
1155
        }
1156

    
1157
        protected long getTime() {
1158
                return (new Date()).getTime();
1159
        }
1160

    
1161
        /*
1162
         * (non-Javadoc)
1163
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#setAffineTransform(java.awt.geom.AffineTransform)
1164
         */
1165
        public void setAffineTransform(AffineTransform t) {
1166
                externalTransformation = (AffineTransform) t.clone();
1167
        }
1168

    
1169
        /*
1170
         * (non-Javadoc)
1171
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getAffineTransform()
1172
         */
1173
        public AffineTransform getAffineTransform() {
1174
                return externalTransformation;
1175
        }
1176

    
1177
        /**
1178
         * Elimina la matriz de transformaci?n asociada al raster y que se tiene en
1179
         * cuenta para el setView. Este reseteo tendr? en cuenta que si el raster
1180
         * tiene asociado un rmf esta transformaci?n no ser? eliminada sino que se
1181
         * asignar? la correspondiente al rmf existente.
1182
         * @return devuelve true si tiene fichero rmf asociado y false si no lo tiene.
1183
         */
1184
        public void resetAffineTransform() {
1185
                externalTransformation.setToIdentity();
1186
        }
1187

    
1188
        /*
1189
         * (non-Javadoc)
1190
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getOwnAffineTransform()
1191
         */
1192
        public AffineTransform getOwnAffineTransform() {
1193
                return ownTransformation;
1194
        }
1195
}