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 @ 2177

History | View | Annotate | Download (42.3 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.Image;
25
import java.awt.geom.AffineTransform;
26
import java.awt.geom.NoninvertibleTransformException;
27
import java.awt.geom.Point2D;
28
import java.io.File;
29
import java.security.NoSuchAlgorithmException;
30
import java.util.Collection;
31
import java.util.Date;
32
import java.util.Iterator;
33
import java.util.List;
34

    
35
import org.cresques.cts.IProjection;
36
import org.gvsig.compat.net.ICancellable;
37
import org.gvsig.fmap.dal.DALLocator;
38
import org.gvsig.fmap.dal.DataServerExplorer;
39
import org.gvsig.fmap.dal.DataStoreParameters;
40
import org.gvsig.fmap.dal.coverage.RasterLibrary;
41
import org.gvsig.fmap.dal.coverage.RasterLocator;
42
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
43
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
44
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
45
import org.gvsig.fmap.dal.coverage.datastruct.GeoPointList;
46
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
47
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
48
import org.gvsig.fmap.dal.coverage.exception.CloneException;
49
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
50
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException;
51
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
52
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
53
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
54
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
55
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
56
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
57
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
58
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
59
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
60
import org.gvsig.fmap.dal.coverage.store.parameter.RasterFileStoreParameters;
61
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters;
62
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
63
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
64
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
65
import org.gvsig.fmap.dal.coverage.store.props.Metadata;
66
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
67
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries;
68
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
69
import org.gvsig.fmap.dal.coverage.util.FileUtils;
70
import org.gvsig.fmap.dal.coverage.util.RasterUtils;
71
import org.gvsig.fmap.dal.exception.InitializeException;
72
import org.gvsig.fmap.dal.exception.OpenException;
73
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
74
import org.gvsig.fmap.dal.exception.ReadException;
75
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
76
import org.gvsig.fmap.dal.raster.spi.AbstractCoverageStoreProvider;
77
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
78
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
79
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
80
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
81
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
82
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
83
import org.gvsig.raster.cache.tile.provider.TileListener;
84
import org.gvsig.raster.cache.tile.provider.TileServer;
85
import org.gvsig.raster.impl.buffer.DefaultRasterQuery;
86
import org.gvsig.raster.impl.datastruct.DefaultNoData;
87
import org.gvsig.raster.impl.datastruct.ExtentImpl;
88
import org.gvsig.raster.impl.datastruct.serializer.ColorTableRmfSerializer;
89
import org.gvsig.raster.impl.datastruct.serializer.NoDataRmfSerializer;
90
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
91
import org.gvsig.raster.impl.store.DefaultRasterStore;
92
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
93
import org.gvsig.raster.impl.store.properties.SimpleProviderHistogramComputer;
94
import org.gvsig.raster.impl.store.properties.SimpleProviderStatistics;
95
import org.gvsig.raster.impl.store.rmf.ClassSerializer;
96
import org.gvsig.raster.impl.store.rmf.RmfBlocksManager;
97
import org.gvsig.raster.impl.store.serializer.ColorInterpretationRmfSerializer;
98
import org.gvsig.raster.impl.store.serializer.GeoInfoRmfSerializer;
99
import org.gvsig.raster.impl.store.serializer.GeoPointListRmfSerializer;
100
import org.gvsig.raster.impl.store.serializer.ProjectionRmfSerializer;
101
import org.gvsig.raster.impl.store.serializer.StatisticsRmfSerializer;
102
import org.gvsig.raster.util.DefaultProviderServices;
103
import org.gvsig.timesupport.Interval;
104
import org.gvsig.timesupport.Time;
105
import org.gvsig.tools.dynobject.DynObject;
106
import org.gvsig.tools.locator.LocatorException;
107
import org.gvsig.tools.task.TaskStatus;
108
import org.slf4j.Logger;
109
import org.slf4j.LoggerFactory;
110

    
111
/**
112
 * Base class for all raster providers. 
113
 * @author Nacho Brodin (nachobrodin@gmail.com)
114
 */
115
public abstract class DefaultRasterProvider extends AbstractCoverageStoreProvider implements RasterProvider {
116
        /**
117
         * Flags que representan a las bandas visualizables
118
         */
119
        public static final int                   RED_BAND               = 0x01;
120
        public static final int                   GREEN_BAND             = 0x02;
121
        public static final int                   BLUE_BAND              = 0x04;
122
        public static final int                   ALPHA_BAND             = 0x08;
123
        
124
        protected int                             bandCount              = 1;
125
        private int[]                             dataType               = null;
126
        protected NoData                          noData                 = null;
127

    
128
        protected Statistics                      stats                  = null;
129
        protected HistogramComputer               histogram              = null;
130
        protected DataStoreParameters             param                  = null;
131
        protected DataStoreProviderServices       storeServices          = null;
132
        protected RmfBlocksManager                rmfBlocksManager       = null;
133
        protected ColorTable                      colorTable             = null;
134
        private ColorInterpretation               colorInterpretation    = null;
135
        protected TimeSeries                      serialInfo             = null;
136
        protected Transparency                    transparency           = null;
137
        protected TileServer                      tileServer             = null;
138
        protected GeoPointList                    geoPointList           = null;
139
        
140
        protected FileUtils                       fileUtil               = RasterLocator.getManager().getFileUtils();
141
        protected RasterUtils                     rasterUtil             = RasterLocator.getManager().getRasterUtils();
142
        
143
        protected IProjection                     proj                   = null;
144
        protected long                            fileSize               = 0;
145
        protected long                            bytesReaded            = 0;
146
        protected long                            lineCnt                = 0;
147
        protected String                          uri;
148
        protected String                          selectedSubdatasetID   = null;
149
        /**
150
         * Transformaci�n creada a partir de la informaci�n de georreferencia de la
151
         * propia imagen. Esta informaci�n est� en la cabecera o en ficheros
152
         * worldfile.
153
         */
154
        protected AffineTransform                 ownTransformation      = null;
155
        /**
156
         * Transformaci�n asignada de forma externa, bien desde el fichero rmf o
157
         * asignada directamente por el usuario.
158
         */
159
        protected AffineTransform                 externalTransformation = null;
160
        private static Logger                     logger                 = LoggerFactory.getLogger(DefaultRasterProvider.class.getName());
161
        
162
        public DefaultRasterProvider(AbstractRasterDataParameters params,
163
                        DataStoreProviderServices storeServices, DynObject metadata) {
164
                super(params, storeServices, metadata);
165
                if(params.getURI() != null) {
166
                        File f = new File(params.getURI());
167
                        if(f.exists())
168
                                setFileSize(f.length());
169
                }
170
                
171
                if(params.getURI() != null)
172
                        uri = translateFileName(params.getURI());
173
                
174
                ownTransformation = new AffineTransform();
175
                externalTransformation = new AffineTransform();
176
        }
177
        
178
        public DefaultRasterProvider(DataStoreParameters params,
179
                        DataStoreProviderServices storeServices, DynObject metadata) {
180
                super(params, storeServices, metadata);
181
                if(((RasterDataParameters)params).getURI() != null) {
182
                        File f = new File(((RasterDataParameters)params).getURI());
183
                        if(f.exists())
184
                                setFileSize(f.length());
185
                        if(params instanceof RemoteStoreParameters)
186
                                uri = translateFileName(((RasterDataParameters)params).getURI());
187
                }
188
                
189
                ownTransformation = new AffineTransform();
190
                externalTransformation = new AffineTransform();
191
        }
192
        
193
        public DefaultRasterProvider(String params) {
194
                super();
195
        }
196
        
197
        public DefaultRasterProvider() {
198
                super(null, null, null);
199
        }
200
        
201
        public String getFullName() {
202
                return getName();
203
        }
204
        
205
        public String getProviderName() {
206
                return getName();
207
        }
208
        
209
        public String[] getFormatList() {
210
                return null;
211
        }
212
        
213
        /**
214
         * Acciones de inicilizaci�n comunes a todos los drivers.
215
         * Este m�todo debe ser llamado explicitamente por el constructor de cada driver.
216
         * Estas son acciones de inicializaci�n que se ejecutan despu�s del constructor de cada driver.
217
         * Las acciones que hayan de ser realizadas antes se definen en el constructor de RasterDataset.
218
         */
219
        protected void init() {
220
        }
221
        
222
        public boolean isTiled() {
223
                return false;
224
        }
225
        
226
        public boolean isTimeSupported() {
227
                return false;
228
        }
229
        
230
        public RasterProvider cloneProvider() throws CloneException {
231
                try {
232
                        DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
233
                        DefaultRasterProvider provider = (DefaultRasterProvider)dataManager.createProvider(storeServices, param);
234
                        //DefaultRasterProvider provider = singleDatasetInstance(storeServices, param);
235
                        // Estas van por referencia
236
                        provider.histogram = histogram;
237
                        provider.stats = stats;
238
                        return provider;
239
                } catch (ProviderNotRegisteredException e) {
240
                        e.printStackTrace();
241
                } catch (InitializeException e) {
242
                        e.printStackTrace();
243
                }
244
                return null;
245
        }
246
        
247
        /**
248
         * Factoria para abrir distintos tipos de raster.
249
         * @param fName Nombre del fichero.
250
         *
251
         * @return SingleDataset, o null si hay problemas.
252
         */
253
        public static DefaultRasterProvider singleDatasetInstance(DataStoreProviderServices storeServices, String param) throws RasterDriverException {
254
                DataManagerProviderServices dataManager = (DataManagerProviderServices)DALLocator.getDataManager();
255
                //We have to locate a provider's name which manages the selected file
256
                //A FilesystemServerExplorer will give a getProviderNames service
257
                
258
                FilesystemServerExplorer serverExplorer = null;
259
                try {
260
                        FilesystemServerExplorerParameters paramsExplorer = (FilesystemServerExplorerParameters)dataManager.createServerExplorerParameters(FilesystemServerExplorer.NAME);
261
                        paramsExplorer.setRoot(File.separator);
262
                        serverExplorer = (FilesystemServerExplorer)dataManager.openServerExplorer(FilesystemServerExplorer.NAME, paramsExplorer);
263
                } catch (ValidateDataParametersException e) {
264
                        throw new RasterDriverException("Error validating parameters", e);
265
                } catch (InitializeException e) {
266
                        throw new RasterDriverException("Error creating a server explorer ", e);
267
                } catch (ProviderNotRegisteredException e) {
268
                        throw new RasterDriverException("Provider not registered", e);
269
                }
270
                
271
                //Gets the list of provider's name to manage the file
272
                File file = new File(param);
273
                List<String> provName = serverExplorer.getProviderNameList(file);
274
                if(provName.size() > 0) {
275
                        for (int i = 0; i < provName.size(); i++) {
276
                                //Gets the first provider what is not a TileProvider
277
                                if(provName.get(i).compareTo("Tile Store") != 0) {
278
                                        DataStoreParameters newparams;
279
                                        try {
280
                                                newparams = dataManager.createStoreParameters(provName.get(i));
281
                                                ((FilesystemStoreParameters)newparams).setFile(file); 
282
                                                if(storeServices == null)
283
                                                        storeServices = new DefaultRasterStore();
284
                                                return (DefaultRasterProvider)dataManager.createProvider(storeServices, newparams);
285
                                        } catch (InitializeException e) {
286
                                                throw new RasterDriverException("Error creating a server explorer ", e);
287
                                        } catch (ProviderNotRegisteredException e) {
288
                                                throw new RasterDriverException("Provider not registered", e);
289
                                        }
290
                                }
291
                        }
292
                }
293
                return null;
294
        }
295

    
296
        /**
297
         * Carga un fichero raster. Puede usarse para calcular el extent e instanciar
298
         * un objeto de este tipo.
299
         */
300
        abstract public RasterProvider load();
301

    
302
        /**
303
         * Obtiene el ancho de la imagen
304
         * @return Ancho de la imagen
305
         */
306
        abstract public double getWidth();
307

    
308
        /**
309
         * Obtiene el ancho de la imagen
310
         * @return Ancho de la imagen
311
         */
312
        abstract public double getHeight();
313

    
314
        /**
315
         * Asigna un nuevo Extent
316
         * @param e        Extent
317
         */
318
        public abstract void setView(Extent e);
319

    
320
        /**
321
         * Obtiene el extent asignado
322
         * @return        Extent
323
         */
324
        public abstract Extent getView();
325

    
326
        /**
327
         * Obtiene el valor del raster en la coordenada que se le pasa.
328
         * El valor ser� Double, Int, Byte, etc. dependiendo del tipo de
329
         * raster.
330
         * @param x        coordenada X
331
         * @param y coordenada Y
332
         * @return
333
         */
334
        abstract public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
335

    
336
        /**
337
         * Gets the set of data selected in the {@link RasterQuery}
338
         * @param q
339
         * @return
340
         * @throws RasterDriverException 
341
         * @throws ProcessInterruptedException 
342
         */
343
        public Buffer getDataSet(RasterQuery query) throws ProcessInterruptedException, RasterDriverException {
344
                DefaultRasterQuery q = (DefaultRasterQuery)query;
345
                if( q.getType() == DefaultRasterQuery.TYPE_ENTIRE || 
346
                        q.getType() == DefaultRasterQuery.TYPE_PX_SIZE || 
347
                        q.getType() == DefaultRasterQuery.TYPE_PX) {
348
                        return getWindow(q.getPixelX(), q.getPixelY(), q.getPixelW(), q.getPixelH(), 
349
                                        q.getBandList(), q.getBuffer(), q.getTaskStatus());
350
                }
351
                
352
                if(q.getType() == DefaultRasterQuery.TYPE_COORDS_SIZE) {
353
                        return getWindow(q.getBBox(), q.getBufWidth(), q.getBufHeight(), 
354
                                        q.getBandList(), q.getBuffer(), q.isAdjustToExtent(), q.getTaskStatus());
355
                }
356
                
357
                if(q.getType() == DefaultRasterQuery.TYPE_COORDS) {
358
                        if(q.getBBox() == null)
359
                                return getWindow(q.getX(), q.getY(), q.getW(), q.getH(), 
360
                                                q.getBandList(), q.getBuffer(), q.isAdjustToExtent(), q.getTaskStatus());
361
                        else
362
                                return getWindow(q.getBBox(), q.getBandList(), q.getBuffer(), q.getTaskStatus());
363
                }
364
                
365
                if(q.getType() == DefaultRasterQuery.TYPE_COORDS_SIZE_TILED) {
366
                        getWindow(q.getBBox(), q.getBufWidth(), q.getBufHeight(), 
367
                                        q.getBandList(), q.getTileListener(), q.getTaskStatus());
368
                }
369
                return null;
370
        }
371
        
372
        /**
373
         * Gets a window of data from the source. The result of this operation could be a list of tiles
374
         * that are sent through the listener.
375
         * @param ex
376
         * @param bufWidth
377
         * @param bufHeight
378
         * @param bandList
379
         * @param listener
380
         * @throws ProcessInterruptedException
381
         * @throws RasterDriverException
382
         */
383
         abstract public void getWindow(Extent ex, int bufWidth, int bufHeight, 
384
                         BandList bandList, TileListener listener, TaskStatus taskStatus) throws ProcessInterruptedException, RasterDriverException;
385
        
386
        /**
387
         * Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
388
         * No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama�o a los
389
         * pixeles de disco.
390
         * @param ulx Posici�n X superior izquierda
391
         * @param uly Posici�n Y superior izquierda
392
         * @param lrx Posici�n X inferior derecha
393
         * @param lry Posici�n Y inferior derecha
394
         * @param rasterBuf        Buffer de datos
395
         * @param bandList
396
         * @return Buffer de datos
397
         */
398
        abstract public Buffer getWindow(Extent extent, BandList bandList, Buffer rasterBuf, TaskStatus status) 
399
                throws ProcessInterruptedException, RasterDriverException;
400

    
401
        /**
402
         * Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
403
         * No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama�o a los
404
         * pixeles de disco.
405
         * @param x Posici�n X superior izquierda
406
         * @param y Posici�n Y superior izquierda
407
         * @param w Ancho en coordenadas reales
408
         * @param h Alto en coordenadas reales
409
         * @param rasterBuf        Buffer de datos
410
         * @param bandList
411
         * @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
412
         * @return Buffer de datos
413
         */
414
        abstract public Buffer getWindow(double x, double y, double w, double h, 
415
                        BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException;
416

    
417
        /**
418
         * Obtiene una ventana de datos de la imagen a partir de coordenadas reales.
419
         * Se aplica supersampleo o subsampleo dependiendo del tama�o del buffer especificado.
420
         *
421
         * @param minX Posici�n m�nima X superior izquierda
422
         * @param minY Posici�n m�nima Y superior izquierda
423
         * @param maxX Posici�n m�xima X inferior derecha
424
         * @param maxY Posici�n m�xima Y inferior derecha
425
         * @param bufWidth Ancho del buffer de datos
426
         * @param bufHeight Alto del buffer de datos
427
         * @param rasterBuf        Buffer de datos
428
         * @param adjustToExtent Flag que dice si el extent solicitado debe ajustarse al extent del raster o no.
429
         * @param bandList
430
         * @return Buffer de datos
431
         */
432
        abstract public Buffer getWindow(Extent extent, 
433
                        int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf, 
434
                        boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException;
435

    
436
        /**
437
         * Obtiene una ventana de datos de la imagen a partir de coordenadas pixel.
438
         * Se aplica supersampleo o subsampleo dependiendo del tama�o del buffer especificado.
439
         *
440
         * @param x Posici�n X superior izquierda
441
         * @param y Posici�n Y superior izquierda
442
         * @param w Ancho en coordenadas reales
443
         * @param h Alto en coordenadas reales
444
         * @param bufWidth Ancho del buffer de datos
445
         * @param bufHeight Alto del buffer de datos
446
         * @param rasterBuf        Buffer de datos
447
         * @param bandList
448
         * @return Buffer de datos
449
         */
450
        abstract public Buffer getWindow(int x, int y, int w, int h, 
451
                        BandList bandList, Buffer rasterBuf, TaskStatus status)throws ProcessInterruptedException, RasterDriverException;
452

    
453
        abstract public int getBlockSize();
454
        
455
        abstract public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
456

    
457
        /**
458
         * Informa de si el dataset soporta overviews o no.
459
         * @return true si soporta overviews y false si no las soporta.
460
         */
461
        abstract public boolean isOverviewsSupported();
462
        
463
        /**
464
         * Returns true if supersampling operation is supported by this provider, i.e if 
465
         * a request greater than 1:1 will have a response.
466
         * @return
467
         */
468
        public boolean isSupersamplingSupported() {
469
                return true;
470
        }
471
        
472
        public void reload() {
473
                try {
474
                        loadFromRmf(getRmfBlocksManager());
475
                } catch (ParsingException e) {
476
                        logger.debug("No se ha podido leer el RMF", e);
477
                }
478
        }
479
        
480
        /**
481
         * Carga metadatos desde el fichero Rmf si estos existen
482
         * @param fName Nombre del fichero
483
         * @throws ParsingException
484
         */
485
        protected void loadFromRmf(RmfBlocksManager manager) throws ParsingException {
486
                if (!manager.checkRmf())
487
                        return;
488

    
489
                if (!new File(manager.getPath()).exists())
490
                        return;
491
                
492
                GeoInfoRmfSerializer geoInfoSerializer = new GeoInfoRmfSerializer(this);
493
                ColorTableRmfSerializer colorTableSerializer = new ColorTableRmfSerializer();
494
                GeoPointListRmfSerializer gcpSerializer = new GeoPointListRmfSerializer();
495
                NoDataRmfSerializer noDataSerializer = null;
496
                if(noData == null)
497
                        noData = new DefaultNoData(null, null, manager.getPath(), getBandCount());
498
                noDataSerializer = new NoDataRmfSerializer((DefaultNoData)noData);                        
499
                ColorInterpretationRmfSerializer colorInterpSerializer = new ColorInterpretationRmfSerializer();
500
                ProjectionRmfSerializer projectionRmfSerializer = new ProjectionRmfSerializer();
501
                StatisticsRmfSerializer statsRmfSerializer = new StatisticsRmfSerializer(getStatistics());
502

    
503
                manager.addClient(geoInfoSerializer);
504
                manager.addClient(colorTableSerializer);
505
                manager.addClient(gcpSerializer);
506
                manager.addClient(noDataSerializer);
507
                manager.addClient(colorInterpSerializer);
508
                manager.addClient(projectionRmfSerializer);
509
                manager.addClient(statsRmfSerializer);
510

    
511
                manager.read(null);
512

    
513
                manager.removeAllClients();
514

    
515
                if (colorTableSerializer.getResult() != null)
516
                        setColorTable((ColorTable) colorTableSerializer.getResult());
517

    
518
                if (colorInterpSerializer.getResult() != null) {
519
                        DataStoreColorInterpretation ci = (DataStoreColorInterpretation) colorInterpSerializer.getResult();
520
                        setColorInterpretation(ci);
521
                        getTransparency().setTransparencyBand(ci.getBand(DataStoreColorInterpretation.ALPHA_BAND));
522
                }
523

    
524
                if (projectionRmfSerializer.getResult() != null) {
525
                        proj = (IProjection) projectionRmfSerializer.getResult();
526
                }
527
                
528
                if( gcpSerializer.getResult() != null && 
529
                        gcpSerializer.getResult() instanceof GeoPointList && 
530
                        ((GeoPointList)gcpSerializer.getResult()).size() > 0) {
531
                        setGeoPointList((GeoPointList)gcpSerializer.getResult());
532
                }
533
        }
534

    
535
        /**
536
         * Obtiene el n�nero de bandas del fichero
537
         * @return Entero que representa el n�mero de bandas
538
         */
539
        public int getBandCount() {
540
                return bandCount;
541
        }
542

    
543
        /**
544
         * @return Returns the dataType.
545
         */
546
        public int[] getDataType() {
547
                return dataType;
548
        }
549

    
550
        /**
551
         * @param dataType The dataType to set.
552
         */
553
        public void setDataType(int[] dataType) {
554
                this.dataType = dataType;
555
        }
556

    
557
        public double getPixelSizeX() {
558
                return externalTransformation.getScaleX();
559
        }
560

    
561
        public double getPixelSizeY() {
562
                return externalTransformation.getScaleY();
563
        }
564

    
565
        public NoData getNoDataValue() {
566
                if(noData == null) {
567
                        noData = RasterLocator.getManager().getDataStructFactory().createNoData(null, null, getRMFFile(), getBandCount());
568
                        noData.setDataType(getDataType()[0]);
569
                }
570
                return noData;
571
        }
572
        
573
        public void setNoDataValue(NoData value) {
574
                this.noData = value;
575
        }
576

    
577
        /**
578
         * Dice si el fichero tiene georreferenciaci�n o no.
579
         * @return true si tiene georreferenciaci�n y false si no la tiene
580
         */
581
        public boolean isGeoreferenced() {
582
                return true;
583
        }
584

    
585
        /**
586
         * Dado unas coordenadas reales, un tama�o de buffer y un tama�o de raster.
587
         * Si el buffer es de mayor tama�o que el raster (supersampleo) quiere decir que
588
         * por cada pixel de buffer se repiten varios del raster. Esta funci�n calcula el
589
         * n�mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
590
         * buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
591
         * solicitada es real y puede no caer sobre un pixel completo. Este calculo es
592
         * util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
593
         * el driver autom�ticamente.
594
         * @param dWorldTLX Coordenada real X superior izquierda
595
         * @param dWorldTLY Coordenada real Y superior izquierda
596
         * @param dWorldBRX Coordenada real X inferior derecha
597
         * @param dWorldBRY Coordenada real Y inferior derecha
598
         * @param nWidth Ancho del raster
599
         * @param nHeight Alto del raster
600
         * @param bufWidth Ancho del buffer
601
         * @param bufHeight Alto del buffer
602
         * @return Array de dos elementos con el desplazamiento en X e Y.
603
         */
604
        public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
605
                        double nWidth, double nHeight, int bufWidth, int bufHeight) {
606

    
607
                Point2D p1 = new Point2D.Double(dWorldTLX, dWorldTLY);
608
                Point2D p2 = new Point2D.Double(dWorldBRX, dWorldBRY);
609

    
610
                Point2D tl = worldToRaster(new Point2D.Double(p1.getX(), p1.getY()));
611
                Point2D br = worldToRaster(new Point2D.Double(p2.getX(), p2.getY()));
612

    
613
                double wPx = (bufWidth / Math.abs(br.getX() - tl.getX()));
614
                double hPx = (bufHeight / Math.abs(br.getY() - tl.getY()));
615

    
616
                int x = (int)((tl.getX() > br.getX()) ? Math.floor(br.getX()) : Math.floor(tl.getX()));
617
                int y = (int)((tl.getY() > br.getY()) ? Math.floor(br.getY()) : Math.floor(tl.getY()));
618

    
619
                double a = (tl.getX() > br.getX()) ? (Math.abs(br.getX() - x)) : (Math.abs(tl.getX() - x));
620
                double b = (tl.getY() > br.getY()) ? (Math.abs(br.getY() - y)) : (Math.abs(tl.getY() - y));
621

    
622
                                double stpX = (int)((a * bufWidth) / Math.abs(br.getX() - tl.getX()));
623
                double stpY = (int)((b * bufHeight) / Math.abs(br.getY() - tl.getY()));
624

    
625
                return new double[]{stpX, stpY, wPx, hPx};
626
        }
627

    
628
        /**
629
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
630
         * @param pt Punto a transformar
631
         * @return punto transformado en coordenadas del mundo
632
         */
633
        public Point2D rasterToWorld(Point2D pt) {
634
                Point2D p = new Point2D.Double();
635
                externalTransformation.transform(pt, p);
636
                return p;
637
        }
638

    
639
        /**
640
         * Convierte un punto desde del mundo a coordenadas pixel.
641
         * @param pt Punto a transformar
642
         * @return punto transformado en coordenadas pixel
643
         */
644
        public Point2D worldToRaster(Point2D pt) {
645
                Point2D p = new Point2D.Double();
646
                try {
647
                        externalTransformation.inverseTransform(pt, p);
648
                } catch (NoninvertibleTransformException e) {
649
                        return pt;
650
                }
651
                return p;
652
        }
653

    
654
        /**
655
         * Calcula el extent en coordenadas del mundo real
656
         * @return Extent
657
         */
658
        public Extent getExtent() {
659
                return new ExtentImpl(        rasterToWorld(new Point2D.Double(0, 0)),
660
                                                        rasterToWorld(new Point2D.Double(getWidth(), getHeight())),
661
                                                        rasterToWorld(new Point2D.Double(getWidth(), 0)),
662
                                                        rasterToWorld(new Point2D.Double(0, getHeight())));
663
        }
664

    
665
        /**
666
         * Calcula el extent en coordenadas del mundo real sin rotaci�n. Solo coordenadas y tama�o de pixel
667
         * @return Extent
668
         */
669
        public Extent getExtentWithoutRot() {
670
                AffineTransform at = new AffineTransform(        externalTransformation.getScaleX(), 0,
671
                                                                                                        0, externalTransformation.getScaleY(),
672
                                                                                                        externalTransformation.getTranslateX(), externalTransformation.getTranslateY());
673
                Point2D p1 = new Point2D.Double(0, 0);
674
                Point2D p2 = new Point2D.Double(getWidth(), getHeight());
675
                at.transform(p1, p1);
676
                at.transform(p2, p2);
677
                return new ExtentImpl(p1, p2);
678
        }
679

    
680
        /**
681
         * ASigna el par�metro de inicializaci�n del driver.
682
         */
683
        public void setParam(DataStoreProviderServices provServices, DataStoreParameters param) {
684
                if(param instanceof RasterDataParameters)
685
                        this.uri = ((RasterDataParameters)param).getURI();
686
                this.param = param;
687
                this.storeServices = provServices;
688
        }
689

    
690
        abstract public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
691
        
692
        public void selectSubdataset() {}
693
        
694
        /**
695
         * Selects the subdataset. This method will select
696
         * the rmf file. 
697
         */
698
        protected void selectSubdataset(String subdataset) {
699
                selectedSubdatasetID = subdataset;
700
                getRmfBlocksManager().setPath(getRMFFile());
701
        }
702

    
703
        /**
704
         * Obtiene el gestor de ficheros RMF
705
         * @return RmfBloksManager
706
         */
707
        public RmfBlocksManager getRmfBlocksManager() {
708
                String fileRMF = getRMFFile();
709
                if(fileRMF != null) {
710
                        if (rmfBlocksManager == null || fileRMF.compareTo(rmfBlocksManager.getPath()) != 0) {
711
                                rmfBlocksManager = new RmfBlocksManager(fileRMF);
712
                        }
713
                }
714
                return rmfBlocksManager;
715
        }
716
        
717
        public String getRMFFile() {
718
                String tail = selectedSubdatasetID == null ? ".rmf" : "-sd" + selectedSubdatasetID + ".rmf";
719
                File rmfFolder = (getDataParameters() != null && getDataParameters() instanceof RasterDataParameters) ? 
720
                                                ((RasterDataParameters)getDataParameters()).getRMFFolder() : 
721
                                                null;
722
                        
723
                String fileName = getURI();
724
                if(fileName.contains(File.separator)) {
725
                        if(!fileName.endsWith(File.separator)) {
726
                                fileName = fileName.substring(fileName.lastIndexOf(File.separator) + 1);
727
                                fileName = fileUtil.getNameWithoutExtension(fileName);
728
                        }
729
                }
730
                
731
                if(rmfFolder == null) {
732
                        if(getURI().contains(File.separator)) {
733
                                if(!getURI().endsWith(File.separator)) {
734
                                        String folder = getURI().substring(0, getURI().lastIndexOf(fileName));
735
                                        if((getDataParameters() != null && getDataParameters() instanceof RasterDataParameters))
736
                                                ((RasterDataParameters)getDataParameters()).setRMFFolder(new File(folder));
737
                                }
738
                        }
739
                        return fileUtil.getNameWithoutExtension(getURI()) + tail;
740
                } else {
741
                        return rmfFolder.getAbsolutePath() + File.separator + fileName + tail;
742
                }
743
                
744
        }
745
        
746
        protected String getRMFFileForRemoteServices(String layerName) {
747
                String md5 = "";
748
                try {
749
                        md5 = RasterLocator.getManager().getFileUtils().convertPathToMD5(uri);
750
                } catch (LocatorException e) {
751
                        logger.debug("Error getting the Locator", e);
752
                } catch (NoSuchAlgorithmException e) {
753
                        logger.debug("Error getting the algorithm MD5", e);
754
                }
755
                File path = new File(RasterLibrary.pathRMFRemote);
756
                if(!path.exists())
757
                        path.mkdir();
758
                return RasterLibrary.pathRMFRemote + File.separator + md5 + "-" + layerName + ".rmf";
759
        }
760

    
761
        public boolean isInside(Point2D p){
762
                //Realizamos los calculos solo si el punto est� dentro del extent de la imagen rotada, as� nos ahorramos los calculos
763
                //cuando el puntero est� fuera
764

    
765
                Point2D pt = new Point2D.Double();
766
                try {
767

    
768
                        getAffineTransform().inverseTransform(p, pt);
769
                        if(        pt.getX() >= 0 && pt.getX() < getWidth() &&
770
                                        pt.getY() >= 0 && pt.getY() < getHeight())
771
                                return true;
772
                } catch (NoninvertibleTransformException e) {
773
                        return false;
774
                }
775

    
776
                return false;
777
        }
778

    
779
        /**
780
         * Consulta de si un raster tiene rotaci�n o no.
781
         * @return true si tiene rotaci�n y false si no la tiene.
782
         */
783
        public boolean isRotated() {
784
                if(externalTransformation.getShearX() != 0 || externalTransformation.getShearY() != 0)
785
                        return true;
786
                return false;
787
        }
788
        
789
        public boolean isMultiFile() {
790
                return false;
791
        }
792
        
793
        public boolean isMosaic() {
794
                return false;
795
        }
796

    
797
        /**
798
         * Devuelve si el Dataset es reproyectable
799
         * @return
800
         */
801
        public boolean isReproyectable() {
802
                return true;
803
        }
804

    
805
        public String getWktProjection() {
806
                if(proj != null && RasterLocator.getManager().isCRSUtilSupported())
807
                        return RasterLocator.getManager().getCRSUtils().convertIProjectionToWkt((IProjection) proj);
808
                return null;
809
        }
810

    
811
        public void saveObjectToRmf(Class class1, Object value) throws RmfSerializerException {
812
                ((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).saveObjectToRmfFile(getRmfBlocksManager(), class1, value);
813
        }
814

    
815
        /**
816
         * Carga un objecto desde un serializador del tipo class1. Usa value para iniciar dicho
817
         * serializador
818
         *
819
         * @param class1
820
         * @param value
821
         * @return
822
         * @throws RmfSerializerException
823
         */
824
        private static Object loadObjectFromRmfFile(RmfBlocksManager blocksManager, Class class1, Object value) throws RmfSerializerException {
825
                ClassSerializer serializerObject = ((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).getSerializerObject(class1, value);
826

    
827
                if (serializerObject == null)
828
                        throw new RmfSerializerException("No se ha podido encontrar el serializador para el Rmf");
829

    
830
                if (!blocksManager.checkRmf())
831
                        throw new RmfSerializerException("Error al comprobar el fichero Rmf");
832

    
833
                blocksManager.addClient(serializerObject);
834
                try {
835
                        blocksManager.read(null);
836
                } catch (ParsingException e) {
837
                        throw new RmfSerializerException("Error al leer el fichero Rmf", e);
838
                }
839
                blocksManager.removeAllClients();
840

    
841
                return serializerObject.getResult();
842
        }
843

    
844
        @SuppressWarnings("unchecked")
845
        public Object loadObjectFromRmf(Class class1, Object value) throws RmfSerializerException {
846
                return loadObjectFromRmfFile(getRmfBlocksManager(), class1, value);
847
        }
848

    
849
        /**
850
         * Carga un objeto del fichero RMF especificado por parametro
851
         * @param file
852
         * @param class1
853
         * @param value
854
         * @return
855
         * @throws RmfSerializerException
856
         */
857
        @SuppressWarnings("unchecked")
858
        public static Object loadObjectFromRmfFile(String file, Class class1, Object value) throws RmfSerializerException {
859
                String fileRMF = RasterLocator.getManager().getFileUtils().getNameWithoutExtension(file) + ".rmf";
860
                RmfBlocksManager blocksManager = new RmfBlocksManager(fileRMF);
861
                return loadObjectFromRmfFile(blocksManager, class1, value);
862
        }
863

    
864
        /**
865
         * Guarda en el RMF el objecto actual en caso de que exista un serializador para el
866
         * @param value
867
         * @throws RmfSerializerException
868
         */
869
        public void saveObjectToRmf(Object value) throws RmfSerializerException {
870
                saveObjectToRmf(value.getClass(), value);
871
        }
872

    
873
        /**
874
         * Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
875
         * Usa value para iniciar dicho serializador
876
         * @param value
877
         * @return
878
         * @throws RmfSerializerException
879
         */
880
        public Object loadObjectFromRmf(Object value) throws RmfSerializerException {
881
                return loadObjectFromRmf(value.getClass(), value);
882
        }
883
        
884

    
885
        public double getCellSize() {
886
                try {
887
                        Extent e = getExtent();
888
                        double dCellsize = (e.getMax().getX() - e.getMin().getX() ) / getWidth();
889
                        return dCellsize;
890
                } catch (NullPointerException e) {
891
                        return 1;
892
                }
893
        }
894
        
895
        
896
        public RasterProvider newProvider() {
897
                return null;
898
        }
899
        
900
        public ColorTable getColorTable() {
901
                return colorTable;
902
        }
903
        
904
        public Image getImageLegend() {
905
                return null;
906
        }
907
        
908
        public void setColorTable(ColorTable value) {
909
                colorTable = value;
910
        }
911

    
912
        public Transparency getTransparency() {
913
                return transparency;
914
        }
915
        
916
        public Metadata getMetadata() {
917
                return null;
918
        }
919
        
920
        public ColorInterpretation getColorInterpretation() {
921
                return this.colorInterpretation;
922
        }
923

    
924
        /**
925
         * Asigna el objeto que contiene que contiene la interpretaci�n de
926
         * color por banda
927
         * @param DataStoreColorInterpretation
928
         */
929
        public void setColorInterpretation(ColorInterpretation colorInterpretation) {
930
                this.colorInterpretation = colorInterpretation;
931
        }
932
        
933
        /*
934
         * (non-Javadoc)
935
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getStatistics()
936
         */
937
        public Statistics getStatistics() {
938
                if(stats == null) {
939
                        stats = new SimpleProviderStatistics(this);
940
                }
941
                return stats;
942
        }
943
        
944
        public void setStatistics(Statistics stats) throws RmfSerializerException {
945
                this.stats = stats;
946
                saveObjectToRmf(Statistics.class, stats);
947
        }
948
        
949
        public HistogramComputer getHistogramComputer() {
950
                if (histogram == null)
951
                        histogram = new SimpleProviderHistogramComputer(this);
952
                return histogram;
953
        }
954
        
955
    //****************************************************
956
        //*********Implementing Disposable methods************
957
        //****************************************************
958
    
959
    public void doDispose() {
960
            
961
    }
962
    
963
    //****************************************************
964
        //*****Implementing DataStoreProvider methods*********
965
        //****************************************************
966
    
967
        @Override
968
        public DataServerExplorer getExplorer() throws ReadException,
969
                        ValidateDataParametersException {
970
            /*DataManager manager = DALLocator.getDataManager();
971
                FilesystemServerExplorerParameters params;
972
                try {
973
                        params = (FilesystemServerExplorerParameters) manager
974
                                        .createServerExplorerParameters(FilesystemServerExplorer.NAME);
975
                        params.setRoot(((AbstractRasterStoreParameters)this.getDataParameters()).getFile().getParent());
976
                        return manager.createServerExplorer(params);
977
                } catch (DataException e) {
978
                        throw new ReadException(this.getName(), e);
979
                }*/
980
            return null;
981
        }
982
  
983
        
984
        /**
985
         * Returs the DataParameters
986
         * @return
987
         */
988
        public RasterDataParameters getDataParameters() {
989
                if(getDataStoreParameters() instanceof RasterDataParameters)
990
                        return (RasterDataParameters)getDataStoreParameters();
991
                return null;
992
        }
993

    
994
        @SuppressWarnings("unchecked")
995
        public Iterator getChilds() {
996
                return null;
997
        }
998

    
999
        public ResourceProvider getResource() {
1000
                return null;
1001
        }
1002

    
1003
        public Object getSourceId() {
1004
                if( this.getDataParameters() instanceof RasterFileStoreParameters)
1005
                        return ((RasterFileStoreParameters)this.getDataParameters()).getFile();
1006
                else
1007
                        return this.getDataParameters().getURI();
1008
        }
1009

    
1010
        public void open() throws OpenException {
1011
        }
1012
        
1013
        /**
1014
         * Traduce el nombre del fichero por un alias asignado por el propio driver.
1015
         * Cuando es traducido por un alias el driver intentar� abrir el alias y no el
1016
         * fichero. Esto es util porque algunos formatos tienen la extensi�n en el
1017
         * fichero de cabecera pero lo que se abre realmente es el fichero de datos.
1018
         * @param fileName
1019
         * @return
1020
         */
1021
        public String translateFileName(String fileName) {
1022
                return fileName;
1023
        }
1024
        
1025
        public String getFileSuffix() {
1026
                return getURIOfFirstProvider().substring(getURIOfFirstProvider().lastIndexOf(".") + 1, getURIOfFirstProvider().length());
1027
        }
1028

    
1029
        public String getURIOfFirstProvider() {
1030
                return RasterLocator.getManager().getFileUtils().getFormatedRasterFileName(uri);
1031
        }
1032

    
1033
        public String getURI() {
1034
                return uri;
1035
        }
1036
        
1037
        public void setFName(String n) {
1038
                uri = n;
1039
        }
1040

    
1041
        /**
1042
         * Gets the size of the file if exists in Bytes
1043
         * @return
1044
         */
1045
        public long getFileSize() {
1046
                return fileSize;
1047
        }
1048

    
1049
        public void setFileSize(long sz) {
1050
                fileSize = sz;
1051
        }
1052

    
1053
        public IProjection getProjection() {
1054
                return proj;
1055
        }
1056

    
1057
        public void setProjection(IProjection proj, boolean persist) throws RmfSerializerException {
1058
                this.proj = proj;
1059
                if(persist)
1060
                        saveObjectToRmf(IProjection.class, proj);
1061
        }
1062

    
1063
        protected long getTime() {
1064
                return (new Date()).getTime();
1065
        }
1066

    
1067
        public void setAffineTransform(AffineTransform t) {
1068
                externalTransformation = (AffineTransform) t.clone();
1069
        }
1070

    
1071
        public AffineTransform getAffineTransform() {
1072
                return externalTransformation;
1073
        }
1074

    
1075
        /**
1076
         * Elimina la matriz de transformaci�n asociada al raster y que se tiene en
1077
         * cuenta para el setView. Este reseteo tendr� en cuenta que si el raster
1078
         * tiene asociado un rmf esta transformaci�n no ser� eliminada sino que se
1079
         * asignar� la correspondiente al rmf existente.
1080
         * @return devuelve true si tiene fichero rmf asociado y false si no lo tiene.
1081
         */
1082
        public void resetAffineTransform() {
1083
                externalTransformation.setToIdentity();
1084
        }
1085

    
1086
        public AffineTransform getOwnAffineTransform() {
1087
                return ownTransformation;
1088
        }
1089

    
1090
        public String getInfoByPoint(double x, double y, ICancellable cancellable) throws InfoByPointException {
1091
                return null;
1092
        }
1093
        
1094
        public String getInfoByPoint(int x, int y, Extent bbox, int w, int h, ICancellable cancellable) throws InfoByPointException {
1095
                return null;
1096
        }
1097
        
1098
        public void setTileServer(Class<?> tileServer) throws InitializeException {
1099
                
1100
        }
1101
        
1102
        public int[] getTileSize(int level) {
1103
                return new int[]{0, 0};
1104
        }
1105
        
1106
        public boolean isRasterEnclosed() {
1107
                return false;
1108
        }
1109
        
1110
        public int getSourceType() {
1111
                if(getURI().startsWith("PG:host"))
1112
                        return RasterDataStore.POSTGIS;
1113
                if(getURI().startsWith("http:") || getURI().startsWith("https:"))
1114
                        return RasterDataStore.REMOTE;
1115
                return RasterDataStore.FILE;
1116
        }
1117
        
1118
        /**
1119
         * Most of providers don't need tiles. It those cases this method
1120
         * won't execute anything. Only providers that use tile cache will need
1121
         * implement this function, for instance TileProvider and MosaicProvider.
1122
         */
1123
        public void deleteLayerFromCache() {
1124
                
1125
        }
1126
        
1127
        public TimeSeries getTimeSerials() throws RmfSerializerException {
1128
                if(serialInfo == null) {
1129
                        serialInfo =  new DefaultTimeSerials();
1130
                        loadObjectFromRmf(TimeSeries.class, serialInfo);
1131
                        //Seleccionamos la primera serie por defecto. El usuario seleccionar� otra si la necesita
1132
                        serialInfo.selectSerial(0);
1133
                }
1134
                return serialInfo;
1135
        }
1136
        
1137
        public void setTimeSerials(TimeSeries serialInfo) throws RmfSerializerException {
1138
                this.serialInfo = serialInfo;
1139
                saveObjectToRmf(TimeSeries.class, serialInfo);
1140
        }
1141
        
1142
        public long[] getFileSizeByProvider() {
1143
                return new long[]{getFileSize()};
1144
        }
1145
        
1146
        public String[] getURIByProvider() {
1147
                //For providers with one file
1148
                return new String[]{getURIOfFirstProvider()};
1149
        }
1150
        
1151
        public int[] getBandCountByProvider() {
1152
                return new int[]{getBandCount()};
1153
        }
1154
        
1155
        public int getInternalProviderCount() {
1156
                return 1;
1157
        }
1158
        
1159
        public RasterProvider getInternalProvider(int i) {
1160
                return this;
1161
        }
1162
        
1163
        public String getURIByBand(int band) {
1164
                //No matter which band be selected. In providers with one file is always the first URI
1165
                return getURIOfFirstProvider();
1166
        }
1167
        
1168
        public int getBandPositionByProvider(int band) {
1169
                return band;
1170
        }
1171
        
1172
        public int getSubdatasetCount() {
1173
                return 0;
1174
        }
1175
        
1176
        public void addFile(String file) throws InvalidSourceException {
1177
                //Do nothing
1178
        }
1179
        
1180
        public void removeFile(String file) {
1181
                //Do nothing                
1182
        }
1183
        
1184
        public boolean needEnhanced() {
1185
                return false;
1186
        }
1187
        
1188
        /**
1189
         * Gets the {@link Interval} of the store, that means the temporal
1190
         * interval where the store has valid data.
1191
         * In raster this method has sense in a mosaic. Therefore this has to be implemented 
1192
         * by the provider.
1193
         * @return
1194
         *         a time interval or null if there is not time support
1195
         */
1196
        public Interval getInterval() {
1197
                return null;
1198
        }
1199
        
1200
        /**
1201
         * Gets all the possible values of time for which the store has data.  
1202
         * In raster this method has sense in a mosaic. Therefore this has to be implemented 
1203
         * by the provider.
1204
         * @return
1205
         *         a collection of {@link Time} objects.
1206
         */
1207
        @SuppressWarnings("unchecked")
1208
        public Collection getTimes() {
1209
                return null;
1210
        }
1211
        
1212
        /**
1213
         * Gets all the possible values of time for which the store has data
1214
         * and intersects with an interval.
1215
         * In raster this method has sense in a mosaic. Therefore this has to be implemented 
1216
         * by the provider.
1217
         * @param interval
1218
         *         the interval of time
1219
         * @return
1220
         *         a collection of {@link Time} objects.
1221
         */
1222
        @SuppressWarnings("unchecked")
1223
        public Collection getTimes(Interval interval) {
1224
                return null;
1225
        }
1226
        
1227
        /**
1228
         * Gets the list of geo points associated to this provider
1229
         * @return
1230
         */
1231
        public GeoPointList getGeoPointList() {
1232
                return geoPointList;
1233
        }
1234
        
1235
        /**
1236
         * Sets the list of geo points associated to this provider
1237
         */
1238
        public void setGeoPointList(GeoPointList geoPointList) {
1239
                this.geoPointList = geoPointList;
1240
        }
1241
        
1242
        public void close() {
1243
                if(transparency != null)
1244
                        transparency.dispose();
1245
                try {
1246
                        finalize();
1247
                } catch (Throwable e) {
1248
                }
1249
        }
1250
        
1251
        protected void finalize() throws Throwable {
1252
                dataType               = null;
1253
                noData                 = null;
1254
                stats                  = null;
1255
                histogram              = null;
1256
                param                  = null;
1257
                storeServices          = null;
1258
                rmfBlocksManager       = null;
1259
                colorTable             = null;
1260
                colorInterpretation    = null;
1261
                serialInfo             = null;
1262
                transparency           = null;
1263
                tileServer             = null;
1264
                fileUtil               = null;
1265
                rasterUtil             = null;
1266
                proj                   = null;
1267
                uri                    = null;
1268
                selectedSubdatasetID   = null;
1269
                ownTransformation      = null;
1270
                externalTransformation = null;
1271
        }
1272
}