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

History | View | Annotate | Download (18.2 KB)

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

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

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

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

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

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

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

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

    
405
        /**
406
         * Obtiene el tama?o de pixel en Y
407
         * @return tama?o de pixel en Y
408
         */
409
        public double getPixelSizeY();
410
        
411
        /**
412
         * Obtiene el valor del raster en la coordenada que se le pasa.
413
         * El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
414
         * raster.
415
         * @param x        coordenada X
416
         * @param y coordenada Y
417
         * @return
418
         */
419
        public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
420

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

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