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

History | View | Annotate | Download (43.6 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.util.ArrayList;
29
import java.util.Date;
30
import java.util.Iterator;
31

    
32
import org.cresques.cts.IProjection;
33
import org.gvsig.compat.net.ICancellable;
34
import org.gvsig.fmap.dal.DALLocator;
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.CloneException;
44
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
45
import org.gvsig.fmap.dal.coverage.exception.HistogramException;
46
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
47
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
48
import org.gvsig.fmap.dal.coverage.exception.ParsingException;
49
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
50
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
51
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
52
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
53
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
54
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
55
import org.gvsig.fmap.dal.coverage.store.parameter.RasterFileStoreParameters;
56
import org.gvsig.fmap.dal.coverage.store.parameter.RemoteStoreParameters;
57
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
58
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
59
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
60
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
61
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries;
62
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
63
import org.gvsig.fmap.dal.coverage.util.FileUtils;
64
import org.gvsig.fmap.dal.coverage.util.RasterUtils;
65
import org.gvsig.fmap.dal.exception.InitializeException;
66
import org.gvsig.fmap.dal.exception.OpenException;
67
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
68
import org.gvsig.fmap.dal.exception.ReadException;
69
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
70
import org.gvsig.fmap.dal.raster.spi.AbstractCoverageStoreProvider;
71
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
72
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
73
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
74
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
75
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
76
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
77
import org.gvsig.raster.cache.tile.provider.TileListener;
78
import org.gvsig.raster.cache.tile.provider.TileServer;
79
import org.gvsig.raster.impl.datastruct.DefaultNoData;
80
import org.gvsig.raster.impl.datastruct.ExtentImpl;
81
import org.gvsig.raster.impl.datastruct.serializer.ColorTableRmfSerializer;
82
import org.gvsig.raster.impl.datastruct.serializer.NoDataRmfSerializer;
83
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
84
import org.gvsig.raster.impl.store.DefaultRasterStore;
85
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation;
86
import org.gvsig.raster.impl.store.properties.DataStoreMetadata;
87
import org.gvsig.raster.impl.store.properties.SimpleProviderHistogramComputer;
88
import org.gvsig.raster.impl.store.properties.SimpleProviderStatistics;
89
import org.gvsig.raster.impl.store.rmf.ClassSerializer;
90
import org.gvsig.raster.impl.store.rmf.RmfBlocksManager;
91
import org.gvsig.raster.impl.store.serializer.ColorInterpretationRmfSerializer;
92
import org.gvsig.raster.impl.store.serializer.GeoInfoRmfSerializer;
93
import org.gvsig.raster.impl.store.serializer.ProjectionRmfSerializer;
94
import org.gvsig.raster.util.DefaultProviderServices;
95
import org.gvsig.tools.dynobject.DynObject;
96

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

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

    
327
        /**
328
         * Carga un fichero raster. Puede usarse para calcular el extent e instanciar
329
         * un objeto de este tipo.
330
         */
331
        abstract public RasterProvider load();
332

    
333
        /**
334
         * Cierra el fichero y libera los recursos.
335
         */
336
        abstract public void close();
337

    
338
        /**
339
         * Obtiene el ancho de la imagen
340
         * @return Ancho de la imagen
341
         */
342
        abstract public double getWidth();
343

    
344
        /**
345
         * Obtiene el ancho de la imagen
346
         * @return Ancho de la imagen
347
         */
348
        abstract public double getHeight();
349

    
350
        /**
351
         * Asigna un nuevo Extent
352
         * @param e        Extent
353
         */
354
        public abstract void setView(Extent e);
355

    
356
        /**
357
         * Obtiene el extent asignado
358
         * @return        Extent
359
         */
360
        public abstract Extent getView();
361

    
362
        /**
363
         * Obtiene el valor del raster en la coordenada que se le pasa.
364
         * El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
365
         * raster.
366
         * @param x        coordenada X
367
         * @param y coordenada Y
368
         * @return
369
         */
370
        abstract public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
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) 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) 
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) 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, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException;
434

    
435
        /**
436
         * Obtiene una ventana de datos de la imagen a partir de coordenadas pixel.
437
         * No aplica supersampleo ni subsampleo sino que devuelve una matriz de igual tama?o a los
438
         * pixeles de disco.
439
         * @param x Posici?n X superior izquierda
440
         * @param y Posici?n Y superior izquierda
441
         * @param w Ancho en coordenadas reales
442
         * @param h Alto en coordenadas reales
443
         * @param rasterBuf        Buffer de datos
444
         * @param bandList
445
         * @return Buffer de datos
446
         */
447
        abstract public Buffer getWindow(int x, int y, 
448
                        BandList bandList, Buffer rasterBuf) throws ProcessInterruptedException, RasterDriverException;
449

    
450
        /**
451
         * Obtiene una ventana de datos de la imagen a partir de coordenadas pixel.
452
         * Se aplica supersampleo o subsampleo dependiendo del tama?o del buffer especificado.
453
         *
454
         * @param x Posici?n X superior izquierda
455
         * @param y Posici?n Y superior izquierda
456
         * @param w Ancho en coordenadas reales
457
         * @param h Alto en coordenadas reales
458
         * @param bufWidth Ancho del buffer de datos
459
         * @param bufHeight Alto del buffer de datos
460
         * @param rasterBuf        Buffer de datos
461
         * @param bandList
462
         * @return Buffer de datos
463
         */
464
        abstract public Buffer getWindow(int x, int y, int w, int h, int bufWidth, int bufHeight, 
465
                        BandList bandList, Buffer rasterBuf)throws ProcessInterruptedException, RasterDriverException;
466

    
467
        abstract public int getBlockSize();
468
        
469
        /*
470
         * (non-Javadoc)
471
         * @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewHeight(int, int)
472
         */
473
        abstract public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
474

    
475
        /**
476
         * Informa de si el dataset soporta overviews o no.
477
         * @return true si soporta overviews y false si no las soporta.
478
         */
479
        abstract public boolean isOverviewsSupported();
480
        
481
        /**
482
         * Returns true if supersampling operation is supported by this provider, i.e if 
483
         * a request greater than 1:1 will have a response.
484
         * @return
485
         */
486
        public boolean isSupersamplingSupported() {
487
                return true;
488
        }
489
        
490
        /**
491
         * Carga metadatos desde el fichero Rmf si estos existen
492
         * @param fName Nombre del fichero
493
         * @throws ParsingException
494
         */
495
        protected void loadFromRmf(RmfBlocksManager manager) throws ParsingException {
496
                if (!manager.checkRmf())
497
                        return;
498

    
499
                if (!new File(manager.getPath()).exists())
500
                        return;
501

    
502
                GeoInfoRmfSerializer geoInfoSerializer = new GeoInfoRmfSerializer(this);
503
                ColorTableRmfSerializer colorTableSerializer = new ColorTableRmfSerializer();
504
                NoDataRmfSerializer noDataSerializer = new NoDataRmfSerializer(new DefaultNoData(noData, RasterLibrary.NODATATYPE_LAYER));
505
                ColorInterpretationRmfSerializer colorInterpSerializer = new ColorInterpretationRmfSerializer();
506
                ProjectionRmfSerializer projectionRmfSerializer = new ProjectionRmfSerializer();
507

    
508
                manager.addClient(geoInfoSerializer);
509
                manager.addClient(colorTableSerializer);
510
                manager.addClient(noDataSerializer);
511
                manager.addClient(colorInterpSerializer);
512
                manager.addClient(projectionRmfSerializer);
513

    
514
                manager.read(null);
515

    
516
                manager.removeAllClients();
517

    
518
                if (colorTableSerializer.getResult() != null)
519
                        setColorTable((ColorTable) colorTableSerializer.getResult());
520

    
521
                if (noDataSerializer.getResult() != null) {
522
                        noData = ((DefaultNoData) noDataSerializer.getResult()).getValue();
523
                        noDataEnabled = (((DefaultNoData) noDataSerializer.getResult()).getType() != RasterLibrary.NODATATYPE_DISABLED);
524
                }
525

    
526
                if (colorInterpSerializer.getResult() != null) {
527
                        DataStoreColorInterpretation ci = (DataStoreColorInterpretation) colorInterpSerializer.getResult();
528
                        setColorInterpretation(ci);
529
                        if (ci.getBand(DataStoreColorInterpretation.ALPHA_BAND) != -1)
530
                                getTransparency().setTransparencyBand(ci.getBand(DataStoreColorInterpretation.ALPHA_BAND));
531
                }
532

    
533
                if (projectionRmfSerializer.getResult() != null)
534
                        wktProjection = RasterLocator.getManager().getCRSUtils().convertIProjectionToWkt((IProjection) projectionRmfSerializer.getResult());
535
        }
536

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

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

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

    
559
        /*
560
         * (non-Javadoc)
561
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeX()
562
         */
563
        public double getPixelSizeX() {
564
                return externalTransformation.getScaleX();
565
        }
566

    
567
        /*
568
         * (non-Javadoc)
569
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getPixelSizeY()
570
         */
571
        public double getPixelSizeY() {
572
                return externalTransformation.getScaleY();
573
        }
574

    
575
        /**
576
         * Obtiene el valor NoData asociado al raster. Si hay un valor en el fichero
577
         * RMF se devuelve este, sino se buscar? en la cabecera del raster o metadatos de
578
         * este. Si finalmente no encuentra ninguno se devuelve el valor por defecto
579
         * definido en la libreria.
580
         * @return
581
         */
582
        public double getNoDataValue() {
583
                return noData;
584
        }
585

    
586
        /**
587
         * Pone el valor original de noData. Primero lo consulta del valor del metadata
588
         * y luego del RMF.
589
         */
590
        public void resetNoDataValue() {
591
                /**
592
                 * Intentamos recuperar el valor del metadatas, en caso de no encontrarlo le
593
                 * asignamos el noData por defecto
594
                 */
595
                noDataEnabled = false;
596
                do {
597
                        if (getMetadata() == null) {
598
                                noData = RasterLibrary.defaultNoDataValue;
599
                                break;
600
                        }
601

    
602
                        if (getMetadata().getNoDataValue().length == 0) {
603
                                noData = RasterLibrary.defaultNoDataValue;
604
                                break;
605
                        }
606

    
607
                        noData = getMetadata().getNoDataValue()[0];
608
                        noDataEnabled = getMetadata().isNoDataEnabled();
609
                } while (false);
610

    
611
                try {
612
                        DefaultNoData noDataObject = (DefaultNoData) loadObjectFromRmf(DefaultNoData.class, null);
613
                        if (noDataObject != null) {
614
                                if (noDataObject.getType() > 0)
615
                                        noData = noDataObject.getValue();
616
                                noDataEnabled = (noDataObject.getType() > 0);
617
                        }
618
                } catch (RmfSerializerException e) {
619
                }
620
        }
621

    
622
        /**
623
         * Establece el valor del NoData
624
         * @param value
625
         */
626
        public void setNoDataValue(double value) {
627
                noData = value;
628
                noDataEnabled = true;
629
        }
630

    
631
        /**
632
         * Dice si el fichero tiene georreferenciaci?n o no.
633
         * @return true si tiene georreferenciaci?n y false si no la tiene
634
         */
635
        public boolean isGeoreferenced() {
636
                return true;
637
        }
638

    
639
        /**
640
         * Dado unas coordenadas reales, un tama?o de buffer y un tama?o de raster.
641
         * Si el buffer es de mayor tama?o que el raster (supersampleo) quiere decir que
642
         * por cada pixel de buffer se repiten varios del raster. Esta funci?n calcula el
643
         * n?mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
644
         * buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
645
         * solicitada es real y puede no caer sobre un pixel completo. Este calculo es
646
         * util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
647
         * el driver autom?ticamente.
648
         * @param dWorldTLX Coordenada real X superior izquierda
649
         * @param dWorldTLY Coordenada real Y superior izquierda
650
         * @param dWorldBRX Coordenada real X inferior derecha
651
         * @param dWorldBRY Coordenada real Y inferior derecha
652
         * @param nWidth Ancho del raster
653
         * @param nHeight Alto del raster
654
         * @param bufWidth Ancho del buffer
655
         * @param bufHeight Alto del buffer
656
         * @return Array de dos elementos con el desplazamiento en X e Y.
657
         */
658
        public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
659
                        double nWidth, double nHeight, int bufWidth, int bufHeight) {
660

    
661
                Point2D p1 = new Point2D.Double(dWorldTLX, dWorldTLY);
662
                Point2D p2 = new Point2D.Double(dWorldBRX, dWorldBRY);
663

    
664
                Point2D tl = worldToRaster(new Point2D.Double(p1.getX(), p1.getY()));
665
                Point2D br = worldToRaster(new Point2D.Double(p2.getX(), p2.getY()));
666

    
667
                double wPx = (bufWidth / Math.abs(br.getX() - tl.getX()));
668
                double hPx = (bufHeight / Math.abs(br.getY() - tl.getY()));
669

    
670
                int x = (int)((tl.getX() > br.getX()) ? Math.floor(br.getX()) : Math.floor(tl.getX()));
671
                int y = (int)((tl.getY() > br.getY()) ? Math.floor(br.getY()) : Math.floor(tl.getY()));
672

    
673
                double a = (tl.getX() > br.getX()) ? (Math.abs(br.getX() - x)) : (Math.abs(tl.getX() - x));
674
                double b = (tl.getY() > br.getY()) ? (Math.abs(br.getY() - y)) : (Math.abs(tl.getY() - y));
675

    
676
                                double stpX = (int)((a * bufWidth) / Math.abs(br.getX() - tl.getX()));
677
                double stpY = (int)((b * bufHeight) / Math.abs(br.getY() - tl.getY()));
678

    
679
                return new double[]{stpX, stpY, wPx, hPx};
680
        }
681

    
682
        /**
683
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
684
         * @param pt Punto a transformar
685
         * @return punto transformado en coordenadas del mundo
686
         */
687
        public Point2D rasterToWorld(Point2D pt) {
688
                Point2D p = new Point2D.Double();
689
                externalTransformation.transform(pt, p);
690
                return p;
691
        }
692

    
693
        /**
694
         * Convierte un punto desde del mundo a coordenadas pixel.
695
         * @param pt Punto a transformar
696
         * @return punto transformado en coordenadas pixel
697
         */
698
        public Point2D worldToRaster(Point2D pt) {
699
                Point2D p = new Point2D.Double();
700
                try {
701
                        externalTransformation.inverseTransform(pt, p);
702
                } catch (NoninvertibleTransformException e) {
703
                        return pt;
704
                }
705
                return p;
706
        }
707

    
708
        /**
709
         * Calcula el extent en coordenadas del mundo real
710
         * @return Extent
711
         */
712
        public Extent getExtent() {
713
                return new ExtentImpl(        rasterToWorld(new Point2D.Double(0, 0)),
714
                                                        rasterToWorld(new Point2D.Double(getWidth(), getHeight())),
715
                                                        rasterToWorld(new Point2D.Double(getWidth(), 0)),
716
                                                        rasterToWorld(new Point2D.Double(0, getHeight())));
717
        }
718

    
719
        /**
720
         * Calcula el extent en coordenadas del mundo real sin rotaci?n. Solo coordenadas y tama?o de pixel
721
         * @return Extent
722
         */
723
        public Extent getExtentWithoutRot() {
724
                AffineTransform at = new AffineTransform(        externalTransformation.getScaleX(), 0,
725
                                                                                                        0, externalTransformation.getScaleY(),
726
                                                                                                        externalTransformation.getTranslateX(), externalTransformation.getTranslateY());
727
                Point2D p1 = new Point2D.Double(0, 0);
728
                Point2D p2 = new Point2D.Double(getWidth(), getHeight());
729
                at.transform(p1, p1);
730
                at.transform(p2, p2);
731
                return new ExtentImpl(p1, p2);
732
        }
733

    
734
        /**
735
         * ASigna el par?metro de inicializaci?n del driver.
736
         */
737
        public void setParam(DataStoreProviderServices provServices, DataStoreParameters param) {
738
                if(param instanceof RasterDataParameters)
739
                        this.uri = ((RasterDataParameters)param).getURI();
740
                this.param = param;
741
                this.storeServices = provServices;
742
        }
743

    
744
        /*
745
         * (non-Javadoc)
746
         * @see org.gvsig.raster.impl.provider.RasterProvider#getOverviewWidth(int, int)
747
         */
748
        abstract public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
749
        
750
        /*
751
         * (non-Javadoc)
752
         * @see org.gvsig.raster.impl.provider.RasterProvider#selectSubdataset()
753
         */
754
        public void selectSubdataset() {}
755
        
756
        /**
757
         * Selects the subdataset. This method will select
758
         * the rmf file. 
759
         */
760
        protected void selectSubdataset(String subdataset) {
761
                selectedSubdatasetID = subdataset;
762
                getRmfBlocksManager().setPath(getRMFFile());
763
        }
764

    
765
        /**
766
         * Obtiene el gestor de ficheros RMF
767
         * @return RmfBloksManager
768
         */
769
        public RmfBlocksManager getRmfBlocksManager() {
770
                String fileRMF = getRMFFile();
771
                if (rmfBlocksManager == null || fileRMF.compareTo(rmfBlocksManager.getPath()) != 0) {
772
                        rmfBlocksManager = new RmfBlocksManager(fileRMF);
773
                }
774
                return rmfBlocksManager;
775
        }
776
        
777
        /*
778
         * (non-Javadoc)
779
         * @see org.gvsig.raster.impl.provider.RasterProvider#getRMFFile()
780
         */
781
        public String getRMFFile() {
782
                String tail = selectedSubdatasetID == null ? ".rmf" : "-sd" + selectedSubdatasetID + ".rmf";
783
                return fileUtil.getNameWithoutExtension(getURI()) + tail;
784
        }
785

    
786
        /*
787
         * (non-Javadoc)
788
         * @see org.gvsig.raster.impl.provider.RasterProvider#isInside(java.awt.geom.Point2D)
789
         */
790
        public boolean isInside(Point2D p){
791
                //Realizamos los calculos solo si el punto est? dentro del extent de la imagen rotada, as? nos ahorramos los calculos
792
                //cuando el puntero est? fuera
793

    
794
                Point2D pt = new Point2D.Double();
795
                try {
796

    
797
                        getAffineTransform().inverseTransform(p, pt);
798
                        if(        pt.getX() >= 0 && pt.getX() < getWidth() &&
799
                                        pt.getY() >= 0 && pt.getY() < getHeight())
800
                                return true;
801
                } catch (NoninvertibleTransformException e) {
802
                        return false;
803
                }
804

    
805
                return false;
806
        }
807

    
808
        /**
809
         * Consulta de si un raster tiene rotaci?n o no.
810
         * @return true si tiene rotaci?n y false si no la tiene.
811
         */
812
        public boolean isRotated() {
813
                if(externalTransformation.getShearX() != 0 || externalTransformation.getShearY() != 0)
814
                        return true;
815
                return false;
816
        }
817

    
818
        /**
819
         * Devuelve si el RasterDataSet tiene el valor noData activo
820
         * @return the noDataEnabled
821
         */
822
        public boolean isNoDataEnabled() {
823
                return noDataEnabled;
824
        }
825

    
826
        /**
827
         * Define si el RasterDataSet tiene el valor noData activo
828
         * @param noDataEnabled the noDataEnabled to set
829
         */
830
        public void setNoDataEnabled(boolean noDataEnabled) {
831
                this.noDataEnabled = noDataEnabled;
832
        }
833

    
834
        /**
835
         * Devuelve si el Dataset es reproyectable
836
         * @return
837
         */
838
        public boolean isReproyectable() {
839
                return false;
840
        }
841

    
842
        public String getWktProjection() {
843
                return wktProjection;
844
        }
845

    
846
        /*
847
         * (non-Javadoc)
848
         * @see org.gvsig.raster.impl.dataset.RasterProvider#saveObjectToRmf(java.lang.Class, java.lang.Object)
849
         */
850
        @SuppressWarnings("unchecked")
851
        public void saveObjectToRmf(Class class1, Object value) throws RmfSerializerException {
852
                ((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).saveObjectToRmfFile(getRmfBlocksManager(), class1, value);
853
        }
854

    
855
        /**
856
         * Carga un objecto desde un serializador del tipo class1. Usa value para iniciar dicho
857
         * serializador
858
         *
859
         * @param class1
860
         * @param value
861
         * @return
862
         * @throws RmfSerializerException
863
         */
864
        @SuppressWarnings("unchecked")
865
        private static Object loadObjectFromRmfFile(RmfBlocksManager blocksManager, Class class1, Object value) throws RmfSerializerException {
866
                ClassSerializer serializerObject = ((DefaultProviderServices)RasterLocator.getManager().getProviderServices()).getSerializerObject(class1, value);
867

    
868
                if (serializerObject == null)
869
                        throw new RmfSerializerException("No se ha podido encontrar el serializador para el Rmf");
870

    
871
                if (!blocksManager.checkRmf())
872
                        throw new RmfSerializerException("Error al comprobar el fichero Rmf");
873

    
874
                blocksManager.addClient(serializerObject);
875
                try {
876
                        blocksManager.read(null);
877
                } catch (ParsingException e) {
878
                        throw new RmfSerializerException("Error al leer el fichero Rmf", e);
879
                }
880
                blocksManager.removeAllClients();
881

    
882
                return serializerObject.getResult();
883
        }
884

    
885
        /*
886
         * (non-Javadoc)
887
         * @see org.gvsig.raster.impl.dataset.RasterProvider#loadObjectFromRmf(java.lang.Class, java.lang.Object)
888
         */
889
        @SuppressWarnings("unchecked")
890
        public Object loadObjectFromRmf(Class class1, Object value) throws RmfSerializerException {
891
                return loadObjectFromRmfFile(getRmfBlocksManager(), class1, value);
892
        }
893

    
894
        /**
895
         * Carga un objeto del fichero RMF especificado por parametro
896
         * @param file
897
         * @param class1
898
         * @param value
899
         * @return
900
         * @throws RmfSerializerException
901
         */
902
        @SuppressWarnings("unchecked")
903
        public static Object loadObjectFromRmfFile(String file, Class class1, Object value) throws RmfSerializerException {
904
                String fileRMF = RasterLocator.getManager().getFileUtils().getNameWithoutExtension(file) + ".rmf";
905
                RmfBlocksManager blocksManager = new RmfBlocksManager(fileRMF);
906
                return loadObjectFromRmfFile(blocksManager, class1, value);
907
        }
908

    
909
        /**
910
         * Guarda en el RMF el objecto actual en caso de que exista un serializador para el
911
         * @param value
912
         * @throws RmfSerializerException
913
         */
914
        public void saveObjectToRmf(Object value) throws RmfSerializerException {
915
                saveObjectToRmf(value.getClass(), value);
916
        }
917

    
918
        /**
919
         * Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
920
         * Usa value para iniciar dicho serializador
921
         * @param value
922
         * @return
923
         * @throws RmfSerializerException
924
         */
925
        public Object loadObjectFromRmf(Object value) throws RmfSerializerException {
926
                return loadObjectFromRmf(value.getClass(), value);
927
        }
928
        
929

    
930
        public double getCellSize() {
931
                try {
932
                        Extent e = getExtent();
933
                        double dCellsize = (e.getMax().getX() - e.getMin().getX() ) / getWidth();
934
                        return dCellsize;
935
                } catch (NullPointerException e) {
936
                        return 1;
937
                }
938
        }
939
        
940
        
941
        public RasterProvider newProvider() {
942
                return null;
943
        }
944
        
945
        /*
946
         * (non-Javadoc)
947
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getColorTable()
948
         */
949
        public ColorTable getColorTable() {
950
                return colorTable;
951
        }
952
        
953
        /**
954
         * Define el objeto paleta. Si se define null quiere decir que no tiene paleta
955
         * para su visualizaci?n.
956
         * @param value
957
         */
958
        public void setColorTable(ColorTable value) {
959
                colorTable = value;
960
        }
961

    
962
        /*
963
         * (non-Javadoc)
964
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getTransparency()
965
         */
966
        public Transparency getTransparency() {
967
                return transparency;
968
        }
969
        
970
        /*
971
         * (non-Javadoc)
972
         * @see org.gvsig.raster.impl.provider.RasterProvider#getMetadata()
973
         */
974
        public DataStoreMetadata getMetadata() {
975
                return null;
976
        }
977
        
978
        /*
979
         * (non-Javadoc)
980
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getColorInterpretation()
981
         */
982
        public ColorInterpretation getColorInterpretation() {
983
                return this.colorInterpretation;
984
        }
985

    
986
        /**
987
         * Asigna el objeto que contiene que contiene la interpretaci?n de
988
         * color por banda
989
         * @param DataStoreColorInterpretation
990
         */
991
        public void setColorInterpretation(ColorInterpretation colorInterpretation) {
992
                this.colorInterpretation = colorInterpretation;
993
        }
994
        
995
        /*
996
         * (non-Javadoc)
997
         * @see org.gvsig.raster.impl.dataset.RasterProvider#getStatistics()
998
         */
999
        public Statistics getStatistics() {
1000
                if(stats == null) {
1001
                        stats = new SimpleProviderStatistics(this);
1002
                }
1003
                return stats;
1004
        }
1005
        
1006
        /*
1007
         * (non-Javadoc)
1008
         * @see org.gvsig.fmap.dal.coverage.store.props.Histogramable#getHistogramComputer()
1009
         */
1010
        public HistogramComputer getHistogramComputer() throws HistogramException, InterruptedException {
1011
                if (histogram == null)
1012
                        histogram = new SimpleProviderHistogramComputer(this);
1013
                return histogram;
1014
        }
1015
        
1016
    //****************************************************
1017
        //*********Implementing Disposable methods************
1018
        //****************************************************
1019
    
1020
    /*
1021
     * (non-Javadoc)
1022
     * @see org.gvsig.tools.dispose.impl.AbstractDisposable#doDispose()
1023
     */
1024
    public void doDispose() {
1025
            
1026
    }
1027
    
1028
    //****************************************************
1029
        //*****Implementing DataStoreProvider methods*********
1030
        //****************************************************
1031
    
1032
    /**
1033
     * Gets the specific parameter. All of them inherit from RasterStoreParameters
1034
     */
1035
    //public abstract RasterStoreParameters getRasterParameters();
1036
    
1037
        @Override
1038
        public DataServerExplorer getExplorer() throws ReadException,
1039
                        ValidateDataParametersException {
1040
            /*DataManager manager = DALLocator.getDataManager();
1041
                FilesystemServerExplorerParameters params;
1042
                try {
1043
                        params = (FilesystemServerExplorerParameters) manager
1044
                                        .createServerExplorerParameters(FilesystemServerExplorer.NAME);
1045
                        params.setRoot(((AbstractRasterStoreParameters)this.getDataParameters()).getFile().getParent());
1046
                        return manager.createServerExplorer(params);
1047
                } catch (DataException e) {
1048
                        throw new ReadException(this.getName(), e);
1049
                }*/
1050
            return null;
1051
        }
1052
  
1053
        
1054
        /**
1055
         * Returs the DataParameters
1056
         * @return
1057
         */
1058
        public RasterDataParameters getDataParameters() {
1059
                if(getDataStoreParameters() instanceof RasterDataParameters)
1060
                        return (RasterDataParameters)getDataStoreParameters();
1061
                return null;
1062
        }
1063

    
1064
        /*
1065
         * (non-Javadoc)
1066
         * @see org.gvsig.fmap.dal.spi.DataStoreProvider#getChilds()
1067
         */
1068
        @SuppressWarnings("unchecked")
1069
        public Iterator getChilds() {
1070
                return null;
1071
        }
1072

    
1073
        /*
1074
         * (non-Javadoc)
1075
         * @see org.gvsig.fmap.dal.spi.DataStoreProvider#getResource()
1076
         */
1077
        public ResourceProvider getResource() {
1078
                return null;
1079
        }
1080

    
1081
        /*
1082
         * (non-Javadoc)
1083
         * @see org.gvsig.fmap.dal.spi.DataStoreProvider#getSourceId()
1084
         */
1085
        public Object getSourceId() {
1086
                if( this.getDataParameters() instanceof RasterFileStoreParameters)
1087
                        return ((RasterFileStoreParameters)this.getDataParameters()).getFile();
1088
                else
1089
                        return this.getDataParameters().getURI();
1090
        }
1091

    
1092
        /*
1093
         * (non-Javadoc)
1094
         * @see org.gvsig.fmap.dal.spi.DataStoreProvider#open()
1095
         */
1096
        public void open() throws OpenException {
1097
        }
1098
        
1099
        /**
1100
         * Traduce el nombre del fichero por un alias asignado por el propio driver.
1101
         * Cuando es traducido por un alias el driver intentar? abrir el alias y no el
1102
         * fichero. Esto es util porque algunos formatos tienen la extensi?n en el
1103
         * fichero de cabecera pero lo que se abre realmente es el fichero de datos.
1104
         * @param fileName
1105
         * @return
1106
         */
1107
        public String translateFileName(String fileName) {
1108
                return fileName;
1109
        }
1110
        
1111
        /*
1112
         * (non-Javadoc)
1113
         * @see org.gvsig.raster.impl.provider.RasterProvider#getFileSuffix()
1114
         */
1115
        public String getFileSuffix() {
1116
                return getURIOfFirstProvider().substring(getURIOfFirstProvider().lastIndexOf(".") + 1, getURIOfFirstProvider().length());
1117
        }
1118

    
1119
        /*
1120
         * (non-Javadoc)
1121
         * @see org.gvsig.raster.impl.provider.RasterProvider#getURIOfFirstProvider()
1122
         */
1123
        public String getURIOfFirstProvider() {
1124
                return RasterLocator.getManager().getFileUtils().getFormatedRasterFileName(uri);
1125
        }
1126

    
1127
        /*
1128
         * (non-Javadoc)
1129
         * @see org.gvsig.raster.impl.provider.RasterProvider#getURI()
1130
         */
1131
        public String getURI() {
1132
                return uri;
1133
        }
1134
        
1135
        public void setFName(String n) {
1136
                uri = n;
1137
        }
1138

    
1139
        public long getFileSize() {
1140
                return fileSize;
1141
        }
1142

    
1143
        public void setFileSize(long sz) {
1144
                fileSize = sz;
1145
        }
1146

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

    
1155
        public void setProjection(IProjection p) {
1156
                proj = p;
1157
        }
1158

    
1159
        protected long getTime() {
1160
                return (new Date()).getTime();
1161
        }
1162

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

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

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

    
1190
        /*
1191
         * (non-Javadoc)
1192
         * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getOwnAffineTransform()
1193
         */
1194
        public AffineTransform getOwnAffineTransform() {
1195
                return ownTransformation;
1196
        }
1197
        
1198
        /*
1199
         * (non-Javadoc)
1200
         * @see org.gvsig.raster.impl.provider.RasterProvider#getInfoByPoint(double, double)
1201
         */
1202
        public String getInfoByPoint(double x, double y, ICancellable cancellable) throws RemoteServiceException {
1203
                return null;
1204
        }
1205
        
1206
        /*
1207
         * (non-Javadoc)
1208
         * @see org.gvsig.raster.impl.provider.RasterProvider#setTileServer(java.lang.Class)
1209
         */
1210
        public void setTileServer(Class<?> tileServer) {
1211
                
1212
        }
1213
        
1214
        /*
1215
         * (non-Javadoc)
1216
         * @see org.gvsig.raster.impl.provider.RasterProvider#getTileSize()
1217
         */
1218
        public int[] getTileSize(int level) {
1219
                return new int[]{0, 0};
1220
        }
1221
        
1222
        /*
1223
         * (non-Javadoc)
1224
         * @see org.gvsig.raster.impl.provider.RasterProvider#isRasterEnclosed()
1225
         */
1226
        public boolean isRasterEnclosed() {
1227
                return false;
1228
        }
1229
        
1230
        /*
1231
         * (non-Javadoc)
1232
         * @see org.gvsig.raster.impl.provider.RasterProvider#getOpenParameters()
1233
         */
1234
        public String getOpenParameters() {
1235
                return param.getDataStoreName();
1236
        }
1237
        
1238
        /*
1239
         * (non-Javadoc)
1240
         * @see org.gvsig.raster.impl.provider.RasterProvider#getSourceType()
1241
         */
1242
        public int getSourceType() {
1243
                if(getOpenParameters().startsWith("PG:host"))
1244
                        return RasterDataStore.POSTGIS;
1245
                if(getOpenParameters().startsWith("http:") || getOpenParameters().startsWith("https:"))
1246
                        return RasterDataStore.REMOTE;
1247
                return RasterDataStore.FILE;
1248
        }
1249
        
1250
        /*
1251
         * (non-Javadoc)
1252
         * @see org.gvsig.raster.impl.provider.RasterProvider#getTimeSerials()
1253
         */
1254
        public TimeSeries getTimeSerials() throws RmfSerializerException {
1255
                if(serialInfo == null) {
1256
                        serialInfo =  new DefaultTimeSerials();
1257
                        loadObjectFromRmf(TimeSeries.class, serialInfo);
1258
                        //Seleccionamos la primera serie por defecto. El usuario seleccionar? otra si la necesita
1259
                        serialInfo.selectSerial(0);
1260
                }
1261
                return serialInfo;
1262
        }
1263
        
1264
        /*
1265
         * (non-Javadoc)
1266
         * @see org.gvsig.raster.impl.provider.RasterProvider#setTimeSerials(org.gvsig.fmap.dal.coverage.store.props.TimeSerials)
1267
         */
1268
        public void setTimeSerials(TimeSeries serialInfo) throws RmfSerializerException {
1269
                this.serialInfo = serialInfo;
1270
                saveObjectToRmf(TimeSeries.class, serialInfo);
1271
        }
1272
        
1273
        /*
1274
         * (non-Javadoc)
1275
         * @see org.gvsig.raster.impl.provider.RasterProvider#getFileSizeByProvider()
1276
         */
1277
        public long[] getFileSizeByProvider() {
1278
                return new long[]{getFileSize()};
1279
        }
1280
        
1281
        /*
1282
         * (non-Javadoc)
1283
         * @see org.gvsig.raster.impl.provider.RasterProvider#getFileNameByProvider()
1284
         */
1285
        public String[] getURIByProvider() {
1286
                //For providers with one file
1287
                return new String[]{getURIOfFirstProvider()};
1288
        }
1289
        
1290
        /*
1291
         * (non-Javadoc)
1292
         * @see org.gvsig.raster.impl.provider.RasterProvider#getBandCountByProvider()
1293
         */
1294
        public int[] getBandCountByProvider() {
1295
                return new int[]{getBandCount()};
1296
        }
1297
        
1298
        /*
1299
         * (non-Javadoc)
1300
         * @see org.gvsig.raster.impl.provider.RasterProvider#getInternalProviderCount()
1301
         */
1302
        public int getInternalProviderCount() {
1303
                return 1;
1304
        }
1305
        
1306
        /*
1307
         * (non-Javadoc)
1308
         * @see org.gvsig.raster.impl.provider.RasterProvider#getInternalProvider(int)
1309
         */
1310
        public RasterProvider getInternalProvider(int i) {
1311
                return this;
1312
        }
1313
        
1314
        /*
1315
         * (non-Javadoc)
1316
         * @see org.gvsig.raster.impl.provider.RasterProvider#getURIByBand(int)
1317
         */
1318
        public String getURIByBand(int band) {
1319
                //No matter which band be selected. In providers with one file is always the first URI
1320
                return getURIOfFirstProvider();
1321
        }
1322
        
1323
        /*
1324
         * (non-Javadoc)
1325
         * @see org.gvsig.raster.impl.provider.RasterProvider#getBandPositionByProvider(int)
1326
         */
1327
        public int getBandPositionByProvider(int band) {
1328
                return band;
1329
        }
1330
        
1331
        /*
1332
         * (non-Javadoc)
1333
         * @see org.gvsig.raster.impl.provider.RasterProvider#addFile(java.lang.String)
1334
         */
1335
        public void addFile(String file) throws InvalidSourceException {
1336
                //Do nothing
1337
        }
1338
        
1339
        /*
1340
         * (non-Javadoc)
1341
         * @see org.gvsig.raster.impl.provider.RasterProvider#removeFile(java.lang.String)
1342
         */
1343
        public void removeFile(String file) {
1344
                //Do nothing                
1345
        }
1346
}