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

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

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

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

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

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

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

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

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

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

    
605
        /**
606
         * Gets the set of data selected in the {@link RasterQuery}
607
         * @param q
608
         * @return
609
         * @throws RasterDriverException 
610
         * @throws ProcessInterruptedException 
611
         */
612
        public Buffer getDataSet(RasterQuery query) throws ProcessInterruptedException, RasterDriverException;
613
        
614
}