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 / RasterProvider.java @ 937

History | View | Annotate | Download (17.9 KB)

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

    
24
import java.awt.geom.AffineTransform;
25
import java.awt.geom.Point2D;
26

    
27
import org.cresques.cts.IProjection;
28
import org.gvsig.compat.net.ICancellable;
29
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
30
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
31
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
32
import org.gvsig.fmap.dal.coverage.exception.CloneException;
33
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
34
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
35
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
36
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
37
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
38
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
39
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
40
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
41
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
42
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
43
import org.gvsig.fmap.dal.coverage.store.props.Histogramable;
44
import org.gvsig.fmap.dal.coverage.store.props.Metadata;
45
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
46
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries;
47
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
48
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
49
import org.gvsig.raster.cache.tile.provider.TileServer;
50

    
51
/**
52
 * Interfaz que deben implementar cualquier fuente de datos raster. Estas pueden estar
53
 * compuestas por N datasets. B?sicamente hay dos fuentes que deben implementar este interfaz, 
54
 * MultiRasterDataset y CompositeDataset. La primera es un dataset compuesto por varios ficheros
55
 * con el mismo Extent de N bandas cada uno. MultiRasterDataset proporciona una encapsulaci?n al acceso
56
 * a datos de todos ellos. CompositeDataset es un dataset compuesto de N MultiRasterDatasets cuya extensi?n
57
 * es continua formando un Grid de datasets con continuidad espacial. IRasterDataSource proporciona
58
 * una visi?n de acceso a datos com?n para ambos.
59
 * 
60
 * @author Nacho Brodin (nachobrodin@gmail.com)
61
 *
62
 */
63
public interface RasterProvider extends CoverageStoreProvider, Histogramable {
64
        
65
        /**
66
         * Gets a list of sizes. If the provider doesn't have files it will return null.
67
         * If the provider has one file it will return an array of one element with the
68
         * size of this file. If the provider contains others with one file each one.
69
         * @return
70
         */
71
        public long[] getFileSizeByProvider();
72
        
73
        /**
74
         * Gets a list of file names or URI. Each element of this array is the name of a 
75
         * provider 
76
         * @return
77
         */
78
        public String[] getURIByProvider();
79
        
80
        /**
81
         * Gets the URI of the first provider.
82
         * @return String 
83
         *         File name or URI
84
         */
85
        public String getURIOfFirstProvider();
86
        
87
        /**
88
         * Gets the number of bands by provider. 
89
         * @return
90
         */
91
        public int[] getBandCountByProvider();
92
        
93
        /**
94
         * Selecting a number of band this function returns the number of band
95
         * inside the file. If this provider has only one file the result
96
         * will be band parameter.
97
         * @param band
98
         * @return
99
         */
100
        public int getBandPositionByProvider(int band);
101
        
102
        /**
103
         * Returns the number of internal providers that it has
104
         * @return
105
         */
106
        public int getInternalProviderCount();
107
        
108
        /**
109
         * Gets the internal provider of the i position
110
         * @param i
111
         * @return
112
         */
113
        public RasterProvider getInternalProvider(int i);
114
        
115
        /**
116
         * Gets the URI of the source. If the provider has only one band
117
         * the result will be the URI. If it is multifile will have to choose
118
         * among several sources.
119
         * @param band
120
         * @return
121
         */
122
        public String getURIByBand(int band);
123
        
124
        /**
125
         * Gets the uniform resource identifier
126
         * @return
127
         */
128
        public String getURI();
129
        
130
        /**
131
         * Adds a new file. The behavior of this function depends on 
132
         * the kind of provider and its implementation.
133
         * @param file
134
         * @throws InvalidSourceException 
135
         */
136
        public void addFile(String file) throws InvalidSourceException;
137
        
138
        /**
139
         * Removes a file. The behavior of this function depends on 
140
         * the kind of provider and its implementation.
141
         * @param file
142
         */
143
        public void removeFile(String file);
144
        
145
        /**
146
         * Obtiene el n?mero de bandas del raster
147
         * @return N?mero de bandas
148
         */
149
        public int getBandCount();
150
        
151
        /**
152
         * Obtiene el tipo de dato por banda
153
         * @return tipo de dato por banda
154
         */
155
        public int[] getDataType();
156
        
157
        /**
158
         * Obtiene la altura del raster en p?xeles.
159
         * @return altura
160
         */
161
        public double getHeight();
162

    
163
        /**
164
         * Obtiene la anchura del raster en p?xeles.
165
         * @return anchura
166
         */
167
        public double getWidth();
168
        
169
        /**
170
         * Devuelve si el Dataset es reproyectable
171
         * @return
172
         */
173
        public boolean isReproyectable();
174
        
175
        /**
176
         * Returns true if this raster has rotation and false if don't
177
         */
178
        public boolean isRotated();
179
        
180
        /**
181
         * Returns true if this provider is open and false if don't
182
         * @return
183
         */
184
        public boolean isOpen();
185
        
186
        /**
187
         * Returns true if this provider supports time.
188
         * @return
189
         */
190
        public boolean isTimeSupported();
191
        
192
        /**
193
         * Returns true if the provider support tiles
194
         * @return
195
         */
196
        public boolean isTiled();
197
        
198
        /**
199
         * Informa de si el dataset soporta overviews o no.
200
         * @return true si soporta overviews y false si no las soporta.
201
         */
202
        public boolean isOverviewsSupported();
203
        
204
        /**
205
         * Obtiene el n?mero de overviews de una banda
206
         * @return
207
         */
208
        public int getOverviewCount(int band) throws BandAccessException, RasterDriverException;
209

    
210
        /**
211
         * Obtiene el ancho de una overview de una banda
212
         * @return
213
         */
214
        public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
215

    
216
        /**
217
         * Obtiene el alto de una overview de una banda
218
         * @return
219
         */
220
        public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
221

    
222
        
223
        /**
224
         * Informa de si el punto en coordenadas del mundo real pasado por par?metro cae dentro del
225
         * raster o fuera. Para este calculo cogeremos el punto a averiguar si est? dentro del raster
226
         * y le aplicaremos la transformaci?n inversa de la transformaci?n af?n aplicada. Una vez hecho
227
         * esto ya se puede comprobar si est? dentro de los l?mites del extent del raster.
228
         * @param p Punto a comprobar en coordenadas reales
229
         * @return true si el punto est? dentro y false si est? fuera.
230
         */
231
        public boolean isInside(Point2D p);
232
        
233
        /**
234
         * Gets the nodata value.
235
         * @return
236
         */
237
        public NoData getNoDataValue();
238
        
239
        /**
240
         * Gets statistics of this provider
241
         * @return MultiFileStatistics
242
         */
243
        public Statistics getStatistics();
244
        
245
        /**
246
         * Sets the statistics of this provider. Be careful using this method. 
247
         * Statistics shouldn't be assigned unless you had cloned this provider. 
248
         */
249
        public void setStatistics(Statistics stats);
250
        
251
        /**
252
         * Obtiene el extent del raster.
253
         * @return Extent
254
         */
255
        public Extent getExtent();
256
        
257
        /**
258
         * Gets the suffix of the source file 
259
         * @return
260
         */
261
        public String getFileSuffix();
262
        
263
        /**
264
         * Este es el extent sobre el que se ajusta una petici?n para que esta no
265
         * exceda el extent m?ximo del raster. Para un raster sin rotar ser? igual al
266
         * extent pero para un raster rotado ser? igual al extent del raster como si
267
         * no tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace
268
         * sobre la vista y las peticiones han de hacerse en coordenadas de la imagen
269
         * sin shearing aplicado.
270
         * @return Extent
271
         */
272
        public Extent getExtentWithoutRot();
273
        
274
        /**
275
         * Obtiene la matriz de transformaci?n del propio raster. Esta matriz es la
276
         * encargada de convertir las coordenadas de la petici?n en coordenadas a las
277
         * que se pide a la libreria. En gdal, por ejemplo, se piden las coordenadas a
278
         * la libreria en coordenadas pixel por lo que esta matriz tendr? la
279
         * georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias
280
         * como ermapper la petici?n a la libreria se hace en coordenadas geograficas
281
         * que son las mismas en las que pide el usuario de gvSIG por lo que esta
282
         * matriz en este caso se inicializa con la identidad.
283
         * @return
284
         */
285
        public AffineTransform getOwnAffineTransform();
286
        
287
        /**
288
         * Obtiene la transformaci?n afin aplicada en las peticiones con coordenadas
289
         * reales. Esta corresponde al producto matricial entre la transformaci?n de
290
         * la propia georreferenciaci?n del raster (ownTransformation) y la
291
         * transformaci?n que se le aplique de forma externa. Si esta ?ltima no existe
292
         * ser? la matriz identidad.
293
         * @return Matriz de la transformaci?n af?n.
294
         */
295
        public AffineTransform getAffineTransform();
296
        
297
        /**
298
         * Obtiene la proyecci?n del dataset
299
         * @return IProjection
300
         */
301
        public IProjection getProjection();
302
        
303
        /**
304
         * Obtiene el extent asignado
305
         * @return        Extent
306
         */
307
        public Extent getView();
308
        
309
        /**
310
         * Gets a DatasetMetadata object
311
         * @return
312
         */
313
        public Metadata getMetadata();
314
        
315
        /**
316
         * Gets the object with the color interpretation by band
317
         * @return ColorInterpretation
318
         */
319
        public ColorInterpretation getColorInterpretation();
320
        
321
        /**
322
         * Assigns the object with the color interpretation by band
323
         * @param ci
324
         */
325
        public void setColorInterpretation(ColorInterpretation ci);
326
        
327
        /**
328
         * Define el objeto paleta. Si se define null quiere decir que no tiene paleta
329
         * para su visualizaci?n.
330
         * @param value
331
         */
332
        public void setColorTable(ColorTable value);
333
        
334
        /**
335
         * Obtiene la paleta correspondiente al dataset. 
336
         * @return Paleta asociada a este o null si no tiene
337
         */
338
        public ColorTable getColorTable();
339
        
340
        /**
341
         * Obtiene el estado de transparencia a partir de los estados de transparencia de todos
342
         * los ficheros que lo componen. Si varios de los ficheros que lo componen tienen banda de 
343
         * transparencia estas tendr?n que ser mezcladas sobre una banda de transparencia ?nica.
344
         * @return Objeto FileTransparency con el estado de transparencia
345
         */
346
        public Transparency getTransparency();
347
        
348
        /**
349
         * Cierra los raster asociados.
350
         */
351
        public void close();
352
        
353
        /**
354
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
355
         * @param pt Punto a transformar
356
         * @return punto transformado en coordenadas del mundo
357
         */
358
        public Point2D rasterToWorld(Point2D pt);
359
        
360
        /**
361
         * Convierte un punto desde del mundo a coordenadas pixel.
362
         * @param pt Punto a transformar
363
         * @return punto transformado en coordenadas pixel
364
         */
365
        public Point2D worldToRaster(Point2D pt);
366
        
367
        /**
368
         * Asigna una transformaci?n al raster para que se tenga en cuenta en la
369
         * asignaci?n del setView. Esta asignaci?n recalcula el extent, el
370
         * requestExtent y asigna el AffineTransform que se usar? para la
371
         * transformaci?n. Esta transformaci?n ser? considerada como si la imagen
372
         * tuviera asociado un rmf.
373
         * @param t Transformaci?n af?n a aplicar
374
         */
375
        public void setAffineTransform(AffineTransform t);
376
        
377
        /**
378
         * Gets the pixel size
379
         * @return
380
         */
381
        public double getCellSize();
382
        
383
        /**
384
         * Obtiene el tama?o de pixel en X
385
         * @return tama?o de pixel en X
386
         */
387
        public double getPixelSizeX();
388

    
389
        /**
390
         * Obtiene el tama?o de pixel en Y
391
         * @return tama?o de pixel en Y
392
         */
393
        public double getPixelSizeY();
394
        
395
        /**
396
         * Obtiene el valor del raster en la coordenada que se le pasa.
397
         * El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
398
         * raster.
399
         * @param x        coordenada X
400
         * @param y coordenada Y
401
         * @return
402
         */
403
        public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
404

    
405
        /**
406
         * Obtiene la proyecci?n asociada al raster. Como todos los dataset del 
407
         * multiDataset deben tener la misma proyecci?n obtenemos esta del primer
408
         * dataset.
409
         * @return Proyecci?n en formato cadena
410
         * @throws RasterDriverException
411
         */
412
        public String getWktProjection() throws RasterDriverException;
413
        
414
        /**
415
         * Dado unas coordenadas reales, un tama?o de buffer y un tama?o de raster. 
416
         * Si el buffer es de mayor tama?o que el raster (supersampleo) quiere decir que 
417
         * por cada pixel de buffer se repiten varios del raster. Esta funci?n calcula el 
418
         * n?mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
419
         * buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
420
         * solicitada es real y puede no caer sobre un pixel completo. Este calculo es
421
         * util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
422
         * el driver autom?ticamente.
423
         * @param dWorldTLX Coordenada real X superior izquierda
424
         * @param dWorldTLY Coordenada real Y superior izquierda
425
         * @param nWidth Ancho del raster
426
         * @param nHeight Alto del raster
427
         * @param bufWidth Ancho del buffer
428
         * @param bufHeight Alto del buffer
429
         * @return Array de cuatro. Los dos primeros elementos son el desplazamiento en X e Y y los dos segundos
430
         * el tama?o en pixels de buffer de un pixel de la imagen en ancho y alto.  
431
         */
432
        public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
433
                        double nWidth, double nHeight, int bufWidth, int bufHeight);
434
        
435
        /**
436
         * Sets the nodata value
437
         * @return
438
         */
439
        public void setNoDataValue(NoData value);
440
        
441
        /**
442
         * Obtiene el flag que dice si el raster est? o no georreferenciado
443
         * @return true si est? georreferenciado y false si no lo est?.
444
         */
445
        public boolean isGeoreferenced();
446
        
447
        /**
448
         * Returns true if the provider has several files and all of them has the same extension
449
         * @return
450
         */
451
        public boolean isMultiFile();
452
        
453
        /**
454
         * Returns true if the source of data is a mosaic of images
455
         * @return
456
         */
457
        public boolean isMosaic();
458
        
459
        /**
460
         * Deletes the cache of this layer composed by the files in the provider list
461
         */
462
        public void deleteLayerFromCache();
463
        
464
        /**
465
         * Clone this RasterProvider
466
         * @return
467
         */
468
        public RasterProvider cloneProvider() throws CloneException;
469
        
470
        /**
471
         * Returs the DataParameters
472
         * @return
473
         */
474
        public RasterDataParameters getDataParameters();
475
        
476
        /**
477
         * Lee un bloque completo de datos del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util
478
         * para una lectura rapida de todo el fichero sin necesidad de asignar vista.
479
         * @param pos Posici?n donde se empieza  a leer
480
         * @param blockHeight Altura m?xima del bloque leido
481
         * @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas)
482
         * @throws InvalidSetViewException
483
         * @throws FileNotOpenException
484
         * @throws RasterDriverException
485
         */
486
        public Object readBlock(int pos, int blockHeight, double scale)
487
                throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException;
488

    
489
        
490
        /**
491
         * Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
492
         * Usa value para iniciar dicho serializador
493
         * @param class1
494
         * @param value
495
         * @return
496
         * @throws RmfSerializerException
497
         */
498
        @SuppressWarnings("unchecked")
499
        public Object loadObjectFromRmf(Class class1, Object value) throws RmfSerializerException;
500
        
501
        /**
502
         * Guarda en el RMF el objecto actual en caso de que exista un serializador para el.
503
         * El tipo del objeto se especifica en el parametro class1.
504
         * Esto nos puede permitir poder poner a null un valor y encontrar su serializador.
505
         * @param class1
506
         * @param value
507
         * @throws RmfSerializerException 
508
         */
509
        @SuppressWarnings("unchecked")
510
        public void saveObjectToRmf(Class class1, Object value) throws RmfSerializerException;
511
        
512
        /**
513
         * Sets the status information using other provider of the same type. The first action
514
         * of this method should be to check the type of the parameter.
515
         * @param provider
516
         */
517
        public void setStatus(RasterProvider provider);
518
        
519
        /**
520
         * Gets the information in a real point
521
         * @param x
522
         * @param y
523
         * @return
524
         * @throws RemoteServiceException 
525
         */
526
        public String getInfoByPoint(double x, double y, ICancellable cancellable) throws RemoteServiceException;
527
        
528
        /**
529
         * Gets the tile cache data server
530
         * @return
531
         */
532
        public TileServer getTileServer();
533
        
534
        /**
535
         * Some sevices has neither limits nor pixel size. For instance, WebMapService 
536
         * is a service of this type if the size is not fixed. Other services, like
537
         * WMTS are enclosed too but in this case it will have resolution by level.
538
         * This method returns true if the data source is enclosed.
539
         * @return
540
         */
541
        public boolean isRasterEnclosed();
542
        
543
        /**
544
         * Gets the rmf file path. This method will have to be redefined by providers
545
         * with a different path
546
         * @return
547
         */
548
        public String getRMFFile();
549
        
550
        /**
551
         * Selects the subdataset.
552
         */
553
        public void selectSubdataset();
554
        
555
        /**
556
         * Gets the list of supported formats
557
         * @return
558
         */
559
        public String[] getFormatList();
560
        
561
        /**
562
         * Returns the source type (FILE, POSTGIS, REMOTE,...)
563
         * @return
564
         */
565
        public int getSourceType();
566
        
567
        /**
568
         * This function returns true if the image to be loaded needs a enhanced filter or
569
         * doesn't. It depends on the format, number of bands, type of data and so on.
570
         * @return The default value is false but each driver can change this value.
571
         */
572
        public boolean needEnhanced();
573
        
574
        /**
575
         * Gets the time serial information
576
         * @return
577
         * @throws RmfSerializerException 
578
         */
579
        public TimeSeries getTimeSerials() throws RmfSerializerException;
580
        
581
        /**
582
         * Sets the time serial information
583
         * @throws RmfSerializerException 
584
         */
585
        public void setTimeSerials(TimeSeries serialInfo) throws RmfSerializerException;
586
        
587
}