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

History | View | Annotate | Download (15.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.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.DataParameters;
30
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
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.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.props.ColorInterpretation;
40
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
41
import org.gvsig.fmap.dal.coverage.store.props.Histogramable;
42
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries;
43
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
44
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
45
import org.gvsig.raster.cache.tile.provider.TileServer;
46
import org.gvsig.raster.impl.store.properties.DataStoreMetadata;
47
import org.gvsig.raster.impl.store.properties.DataStoreStatistics;
48

    
49
/**
50
 * Interfaz que deben implementar cualquier fuente de datos raster. Estas pueden estar
51
 * compuestas por N datasets. B?sicamente hay dos fuentes que deben implementar este interfaz, 
52
 * MultiRasterDataset y CompositeDataset. La primera es un dataset compuesto por varios ficheros
53
 * con el mismo Extent de N bandas cada uno. MultiRasterDataset proporciona una encapsulaci?n al acceso
54
 * a datos de todos ellos. CompositeDataset es un dataset compuesto de N MultiRasterDatasets cuya extensi?n
55
 * es continua formando un Grid de datasets con continuidad espacial. IRasterDataSource proporciona
56
 * una visi?n de acceso a datos com?n para ambos.
57
 * 
58
 * @author Nacho Brodin (nachobrodin@gmail.com)
59
 *
60
 */
61
public interface RasterProvider extends CoverageStoreProvider, Histogramable {
62
        
63
        /**
64
         * Obtiene el n?mero de bandas del raster
65
         * @return N?mero de bandas
66
         */
67
        public int getBandCount();
68
        
69
        /**
70
         * Obtiene el tipo de dato por banda
71
         * @return tipo de dato por banda
72
         */
73
        public int[] getDataType();
74
        
75
        /**
76
         * Obtiene la altura del raster en p?xeles.
77
         * @return altura
78
         */
79
        public double getHeight();
80

    
81
        /**
82
         * Obtiene la anchura del raster en p?xeles.
83
         * @return anchura
84
         */
85
        public double getWidth();
86
        
87
        /**
88
         * Obtiene si esta activo el valor NoData asociado al raster.
89
         * @return
90
         */
91
        public boolean isNoDataEnabled();
92
        
93
        /**
94
         * Devuelve si el Dataset es reproyectable
95
         * @return
96
         */
97
        public boolean isReproyectable();
98
        
99
        /**
100
         * Returns true if this raster has rotation and false if don't
101
         */
102
        public boolean isRotated();
103
        
104
        /**
105
         * Returns true if this provider is open and false if don't
106
         * @return
107
         */
108
        public boolean isOpen();
109
        
110
        /**
111
         * Returns true if this provider supports time.
112
         * @return
113
         */
114
        public boolean isTimeSupported();
115
        
116
        /**
117
         * Informa de si el dataset soporta overviews o no.
118
         * @return true si soporta overviews y false si no las soporta.
119
         */
120
        public boolean isOverviewsSupported();
121
        
122
        /**
123
         * Obtiene el n?mero de overviews de una banda
124
         * @return
125
         */
126
        public int getOverviewCount(int band) throws BandAccessException, RasterDriverException;
127

    
128
        /**
129
         * Obtiene el ancho de una overview de una banda
130
         * @return
131
         */
132
        public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
133

    
134
        /**
135
         * Obtiene el alto de una overview de una banda
136
         * @return
137
         */
138
        public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
139

    
140
        
141
        /**
142
         * Informa de si el punto en coordenadas del mundo real pasado por par?metro cae dentro del
143
         * raster o fuera. Para este calculo cogeremos el punto a averiguar si est? dentro del raster
144
         * y le aplicaremos la transformaci?n inversa de la transformaci?n af?n aplicada. Una vez hecho
145
         * esto ya se puede comprobar si est? dentro de los l?mites del extent del raster.
146
         * @param p Punto a comprobar en coordenadas reales
147
         * @return true si el punto est? dentro y false si est? fuera.
148
         */
149
        public boolean isInside(Point2D p);
150
        
151
        /**
152
         * Obtiene el valor NoData asociado al raster.
153
         * @return
154
         */
155
        public double getNoDataValue();
156
        
157
        /**
158
         * Obtiene el objeto con las estadisticas
159
         * @return MultiFileStatistics
160
         */
161
        public DataStoreStatistics getStatistics();
162
        
163
        /**
164
         * Obtiene el extent del raster.
165
         * @return Extent
166
         */
167
        public Extent getExtent();
168
        
169
        /**
170
         * Obtiene el nombre del fichero
171
         * @return String 
172
         *         nombre del fichero
173
         */
174
        public String getFName();
175
        
176
        /**
177
         * Gets the suffix of the source file 
178
         * @return
179
         */
180
        public String getFileSuffix();
181
        
182
        /**
183
         * Este es el extent sobre el que se ajusta una petici?n para que esta no
184
         * exceda el extent m?ximo del raster. Para un raster sin rotar ser? igual al
185
         * extent pero para un raster rotado ser? igual al extent del raster como si
186
         * no tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace
187
         * sobre la vista y las peticiones han de hacerse en coordenadas de la imagen
188
         * sin shearing aplicado.
189
         * @return Extent
190
         */
191
        public Extent getExtentWithoutRot();
192
        
193
        /**
194
         * Obtiene la matriz de transformaci?n del propio raster. Esta matriz es la
195
         * encargada de convertir las coordenadas de la petici?n en coordenadas a las
196
         * que se pide a la libreria. En gdal, por ejemplo, se piden las coordenadas a
197
         * la libreria en coordenadas pixel por lo que esta matriz tendr? la
198
         * georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias
199
         * como ermapper la petici?n a la libreria se hace en coordenadas geograficas
200
         * que son las mismas en las que pide el usuario de gvSIG por lo que esta
201
         * matriz en este caso se inicializa con la identidad.
202
         * @return
203
         */
204
        public AffineTransform getOwnAffineTransform();
205
        
206
        /**
207
         * Obtiene la transformaci?n afin aplicada en las peticiones con coordenadas
208
         * reales. Esta corresponde al producto matricial entre la transformaci?n de
209
         * la propia georreferenciaci?n del raster (ownTransformation) y la
210
         * transformaci?n que se le aplique de forma externa. Si esta ?ltima no existe
211
         * ser? la matriz identidad.
212
         * @return Matriz de la transformaci?n af?n.
213
         */
214
        public AffineTransform getAffineTransform();
215
        
216
        /**
217
         * Obtiene la proyecci?n del dataset
218
         * @return IProjection
219
         */
220
        public IProjection getProjection();
221
        
222
        /**
223
         * Obtiene el extent asignado
224
         * @return        Extent
225
         */
226
        public Extent getView();
227
        
228
        /**
229
         * Gets a DatasetMetadata object
230
         * @return
231
         */
232
        public DataStoreMetadata getMetadata();
233
        
234
        /**
235
         * Obtiene el objeto que contiene que contiene la interpretaci?n de 
236
         * color por banda para el dataset seleccionado
237
         * @param dataset Dataset del que se necesesita la informaci?n de color dentro del RasterMultiDataset
238
         * @return DatasetColorInterpretation
239
         */
240
        public ColorInterpretation getColorInterpretation();
241
        
242
        /**
243
         * Obtiene la paleta correspondiente al dataset. 
244
         * @return Paleta asociada a este o null si no tiene
245
         */
246
        public ColorTable getColorTable();
247
        
248
        /**
249
         * Obtiene el estado de transparencia a partir de los estados de transparencia de todos
250
         * los ficheros que lo componen. Si varios de los ficheros que lo componen tienen banda de 
251
         * transparencia estas tendr?n que ser mezcladas sobre una banda de transparencia ?nica.
252
         * @return Objeto FileTransparency con el estado de transparencia
253
         */
254
        public Transparency getTransparency();
255
        
256
        /**
257
         * Cierra los raster asociados.
258
         */
259
        public void close();
260
        
261
        /**
262
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
263
         * @param pt Punto a transformar
264
         * @return punto transformado en coordenadas del mundo
265
         */
266
        public Point2D rasterToWorld(Point2D pt);
267
        
268
        /**
269
         * Convierte un punto desde del mundo a coordenadas pixel.
270
         * @param pt Punto a transformar
271
         * @return punto transformado en coordenadas pixel
272
         */
273
        public Point2D worldToRaster(Point2D pt);
274
        
275
        /**
276
         * Asigna una transformaci?n al raster para que se tenga en cuenta en la
277
         * asignaci?n del setView. Esta asignaci?n recalcula el extent, el
278
         * requestExtent y asigna el AffineTransform que se usar? para la
279
         * transformaci?n. Esta transformaci?n ser? considerada como si la imagen
280
         * tuviera asociado un rmf.
281
         * @param t Transformaci?n af?n a aplicar
282
         */
283
        public void setAffineTransform(AffineTransform t);
284
        
285
        /**
286
         * Define si se activa el valor NoData asociado al raster.
287
         * @return
288
         */
289
        public void setNoDataEnabled(boolean enabled);
290
        
291
        /**
292
         * Obtiene el tama?o de pixel en X
293
         * @return tama?o de pixel en X
294
         */
295
        public double getPixelSizeX();
296

    
297
        /**
298
         * Obtiene el tama?o de pixel en Y
299
         * @return tama?o de pixel en Y
300
         */
301
        public double getPixelSizeY();
302
        
303
        /**
304
         * Obtiene el valor del raster en la coordenada que se le pasa.
305
         * El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
306
         * raster.
307
         * @param x        coordenada X
308
         * @param y coordenada Y
309
         * @return
310
         */
311
        public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
312

    
313
        /**
314
         * Obtiene la proyecci?n asociada al raster. Como todos los dataset del 
315
         * multiDataset deben tener la misma proyecci?n obtenemos esta del primer
316
         * dataset.
317
         * @return Proyecci?n en formato cadena
318
         * @throws RasterDriverException
319
         */
320
        public String getWktProjection() throws RasterDriverException;
321
        
322
        /**
323
         * Dado unas coordenadas reales, un tama?o de buffer y un tama?o de raster. 
324
         * Si el buffer es de mayor tama?o que el raster (supersampleo) quiere decir que 
325
         * por cada pixel de buffer se repiten varios del raster. Esta funci?n calcula el 
326
         * n?mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
327
         * buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
328
         * solicitada es real y puede no caer sobre un pixel completo. Este calculo es
329
         * util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
330
         * el driver autom?ticamente.
331
         * @param dWorldTLX Coordenada real X superior izquierda
332
         * @param dWorldTLY Coordenada real Y superior izquierda
333
         * @param nWidth Ancho del raster
334
         * @param nHeight Alto del raster
335
         * @param bufWidth Ancho del buffer
336
         * @param bufHeight Alto del buffer
337
         * @return Array de cuatro. Los dos primeros elementos son el desplazamiento en X e Y y los dos segundos
338
         * el tama?o en pixels de buffer de un pixel de la imagen en ancho y alto.  
339
         */
340
        public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
341
                        double nWidth, double nHeight, int bufWidth, int bufHeight);
342
        
343
        /**
344
         * Define el valor NoData asociado al raster.
345
         * @return
346
         */
347
        public void setNoDataValue(double value);
348
        
349
        /**
350
         * Vuelve a poner el valor noData como estaba inicialmente
351
         */
352
        public void resetNoDataValue();
353
        
354
        /**
355
         * Obtiene el flag que dice si el raster est? o no georreferenciado
356
         * @return true si est? georreferenciado y false si no lo est?.
357
         */
358
        public boolean isGeoreferenced();
359
        
360
        /**
361
         * Clone this RasterProvider
362
         * @return
363
         */
364
        public RasterProvider cloneProvider() throws CloneException;
365
        
366
        /**
367
         * Returs the DataParameters
368
         * @return
369
         */
370
        public DataParameters getDataParameters();
371
        
372
        /**
373
         * Lee un bloque completo de datos del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util
374
         * para una lectura rapida de todo el fichero sin necesidad de asignar vista.
375
         * @param pos Posici?n donde se empieza  a leer
376
         * @param blockHeight Altura m?xima del bloque leido
377
         * @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas)
378
         * @throws InvalidSetViewException
379
         * @throws FileNotOpenException
380
         * @throws RasterDriverException
381
         */
382
        public Object readBlock(int pos, int blockHeight)
383
                throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException;
384

    
385
        
386
        /**
387
         * Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
388
         * Usa value para iniciar dicho serializador
389
         * @param class1
390
         * @param value
391
         * @return
392
         * @throws RmfSerializerException
393
         */
394
        @SuppressWarnings("unchecked")
395
        public Object loadObjectFromRmf(Class class1, Object value) throws RmfSerializerException;
396
        
397
        /**
398
         * Guarda en el RMF el objecto actual en caso de que exista un serializador para el.
399
         * El tipo del objeto se especifica en el parametro class1.
400
         * Esto nos puede permitir poder poner a null un valor y encontrar su serializador.
401
         * @param class1
402
         * @param value
403
         * @throws RmfSerializerException 
404
         */
405
        @SuppressWarnings("unchecked")
406
        public void saveObjectToRmf(Class class1, Object value) throws RmfSerializerException;
407
        
408
        /**
409
         * Sets the status information using other provider of the same type. The first action
410
         * of this method should be to check the type of the parameter.
411
         * @param provider
412
         */
413
        public void setStatus(RasterProvider provider);
414
        
415
        /**
416
         * Gets the information in a real point
417
         * @param x
418
         * @param y
419
         * @return
420
         * @throws RemoteServiceException 
421
         */
422
        public String getInfoByPoint(double x, double y, ICancellable cancellable) throws RemoteServiceException;
423
        
424
        /**
425
         * Gets the tile cache data server
426
         * @return
427
         */
428
        public TileServer getTileServer();
429
        
430
        /**
431
         * Some sevices has neither limits nor pixel size. For instance, WebMapService 
432
         * is a service of this type if the size is not fixed. Other services, like
433
         * WMTS are enclosed too but in this case it will have resolution by level.
434
         * This method returns true if the data source is enclosed.
435
         * @return
436
         */
437
        public boolean isRasterEnclosed();
438
        
439
        /**
440
         * Gets the rmf file path. This method will have to be redefined by providers
441
         * with a different path
442
         * @return
443
         */
444
        public String getRMFFile();
445
        
446
        /**
447
         * Selects the subdataset.
448
         */
449
        public void selectSubdataset();
450
        
451
        /**
452
         * Gets the list of supported formats
453
         * @return
454
         */
455
        public String[] getFormatList();
456
        
457
        /**
458
         * Gets the input parameters
459
         * @return
460
         */
461
        public String getOpenParameters();
462
        
463
        /**
464
         * Returns the source type (FILE, POSTGIS, REMOTE,...)
465
         * @return
466
         */
467
        public int getSourceType();
468
        
469
        /**
470
         * Gets the time serial information
471
         * @return
472
         * @throws RmfSerializerException 
473
         */
474
        public TimeSeries getTimeSerials() throws RmfSerializerException;
475
        
476
        /**
477
         * Sets the time serial information
478
         * @throws RmfSerializerException 
479
         */
480
        public void setTimeSerials(TimeSeries serialInfo) throws RmfSerializerException;
481
        
482
}