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

History | View | Annotate | Download (17.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.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.exception.BandAccessException;
31
import org.gvsig.fmap.dal.coverage.exception.CloneException;
32
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
33
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
34
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
35
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
36
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
37
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
38
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
39
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
40
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
41
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
42
import org.gvsig.fmap.dal.coverage.store.props.Histogramable;
43
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
44
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries;
45
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
46
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
47
import org.gvsig.raster.cache.tile.provider.TileServer;
48
import org.gvsig.raster.impl.store.properties.DataStoreMetadata;
49

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

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

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

    
221
        /**
222
         * Obtiene el alto de una overview de una banda
223
         * @return
224
         */
225
        public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
226

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

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

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

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