Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.api / src / main / java / org / gvsig / fmap / dal / coverage / store / RasterDataStore.java @ 1356

History | View | Annotate | Download (14.4 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.fmap.dal.coverage.store;
23

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

    
27
import org.cresques.cts.ICoordTrans;
28
import org.gvsig.fmap.dal.DataStore;
29
import org.gvsig.fmap.dal.DataStoreParameters;
30
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
31
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
32
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
33
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
34
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
35
import org.gvsig.fmap.dal.coverage.exception.CloneException;
36
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
37
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
38
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
39
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
40
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
41
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
42
import org.gvsig.fmap.dal.coverage.grid.render.Render;
43
import org.gvsig.fmap.dal.coverage.process.vector.Vectorization;
44
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
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.exception.CloseException;
49
import org.gvsig.fmap.dal.exception.InitializeException;
50
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
51

    
52
/**
53
 * Interfaz que deben implementar los almacenes de datos raster.
54
 * 
55
 * @author Nacho Brodin (nachobrodin@gmail.com)
56
 */
57
public interface RasterDataStore extends DataStore, TRasterStore, 
58
        RemoteRasterStore, RasterStoreProperties, Histogramable {
59
        public static final int              RED_BAND            = 0x01;
60
        public static final int              GREEN_BAND          = 0x02;
61
        public static final int              BLUE_BAND           = 0x04;
62
        public static final int              ALPHA_BAND          = 0x08;
63
        
64
        /**
65
        * Tipos de raster dependiendo de su fuente
66
        */
67
        public static final int              FILE                = 0;
68
        public static final int              POSTGIS             = 1;
69
        public static final int              REMOTE              = 2;
70
        public static final int              MOSAIC              = 3;
71
        
72
        /**
73
         * Gets a list of data parameters. If it doesn't have
74
         * internal providers this method will return only one DataParameter
75
         * @return
76
         */
77
        public RasterDataParameters[] getDataParametersByProvider();
78
        
79
        /**
80
         * Gets a list of sizes. If the provider doesn't have files it will return null.
81
         * If the provider has one file it will return an array of one element with the
82
         * size of this file. If the provider contains others with one file each one.
83
         * @return
84
         */
85
        public long[] getFileSizeByProvider();
86
        
87
        /**
88
         * Gets a list of file names or URI. Each element of this array is the name of a 
89
         * provider 
90
         * @return
91
         */
92
        public String[] getURIByProvider();
93
        
94
        /**
95
         * Gets the number of bands by provider. 
96
         * @return
97
         */
98
        public int[] getBandCountByProvider();
99
        
100
        /**
101
         * Gets a list of Metadata 
102
         * @return
103
         */
104
        public Metadata[] getMetadataByProvider();
105
        
106
        /**
107
         * Gets the number of overviews by provider
108
         * @param number of band
109
         * @return
110
         */
111
        public int[] getOverviewCountByProvider(int band) throws BandAccessException;
112
        
113
        /**
114
         * Gets the size of a overview in one band. The result is a list of strings (WidthXHeight)
115
         * 
116
         * @param band
117
         * @return
118
         */
119
        public String[] getOverviewSizeByProvider(int band, int overview) throws BandAccessException;
120
        
121
        /**
122
         * Gets a list of affine transforms
123
         * @return
124
         */
125
        public AffineTransform[] getAffineTransformByProvider();
126
        
127
        /**
128
         * Gets the height by provider
129
         * @return
130
         */
131
        public double[] getHeightByProvider();
132
        
133
        /**
134
         * Gets the width by provider
135
         * @return
136
         */
137
        public double[] getWidthByProvider();
138
        
139
        /**
140
         * Gets the URI of the source. If the provider has only one band
141
         * the result will be the URI. If it is multifile will have to choose
142
         * among several sources.
143
         * @param band
144
         * @return
145
         */
146
        public String getURIByBand(int band);
147
        
148
        /**
149
         * Returns the number of internal providers that it has
150
         * @return
151
         */
152
        public int getProviderCount();
153
        
154
        /**
155
         * Adds a new file. The behavior of this function depends on 
156
         * the kind of provider and its implementation.
157
         * @param file
158
         * @throws InvalidSourceException 
159
         */
160
        public void addFile(String file) throws InvalidSourceException;
161
        
162
        /**
163
         * Removes a file. The behavior of this function depends on 
164
         * the kind of provider and its implementation.
165
         * @param file
166
         */
167
        public void removeFile(String file);
168

    
169
        /**
170
         * Define el valor NoData asociado al raster.
171
         * @return
172
         */
173
        public void setNoDataValue(NoData value);
174
        
175
        /**
176
         * Obtiene el extent asignado
177
         * @return        Extent
178
         */
179
        public Extent getView();
180
        
181
        /**
182
         * Crea un un nuevo dataset que referencia al mismo fichero en disco
183
         * @return IRasterDataSource
184
         */
185
        public RasterDataStore newDataStore();
186
        
187
        /**
188
         * Obtiene el Tama?o de cada fichero de que consta el raster en bytes. 
189
         * @return long que representa el tama?o
190
         */
191
        public long getFileSize();
192
        
193
        /**
194
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
195
         * @param pt Punto a transformar
196
         * @return punto transformado en coordenadas del mundo
197
         */
198
        public Point2D rasterToWorld(Point2D pt);
199
        
200
        /**
201
         * Convierte un punto desde del mundo a coordenadas pixel.
202
         * @param pt Punto a transformar
203
         * @return punto transformado en coordenadas pixel
204
         */
205
        public Point2D worldToRaster(Point2D pt);
206
        
207
        /**
208
         * Metodo que obtiene si un punto cae dentro de los l?mites de la extensi?n de la fuente de 
209
         * datos raster o fuera de ellos.
210
         * @param p Punto a calcular
211
         * @return true si est? dentro de los l?mites y false si est? fuera
212
         */
213
        public boolean isInside(Point2D p);
214
        
215
        /**
216
         * Returns true if the data source is tiled
217
         * @return
218
         */
219
        public boolean isTiled();
220
        
221
        /**
222
         * Returns true if the provider has several files and all of them has the same extension
223
         * @return
224
         */
225
        public boolean isMultiFile();
226
        
227
        /**
228
         * Returns true if the source of data is a mosaic of images
229
         * @return
230
         */
231
        public boolean isMosaic();
232
        
233
        /**
234
         * Obtiene la matriz de transformaci?n del propio raster. Esta matriz es la
235
         * encargada de convertir las coordenadas de la petici?n en coordenadas a las
236
         * que se pide a la libreria. En gdal, por ejemplo, se piden las coordenadas a
237
         * la libreria en coordenadas pixel por lo que esta matriz tendr? la
238
         * georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias
239
         * como ermapper la petici?n a la libreria se hace en coordenadas geograficas
240
         * que son las mismas en las que pide el usuario de gvSIG por lo que esta
241
         * matriz en este caso se inicializa con la identidad.
242
         * @return
243
         */
244
        public AffineTransform getOwnAffineTransform();
245
        
246
        /**
247
         * Obtiene la transformaci?n afin aplicada en las peticiones con coordenadas
248
         * reales. Esta corresponde al producto matricial entre la transformaci?n de
249
         * la propia georreferenciaci?n del raster (ownTransformation) y la
250
         * transformaci?n que se le aplique de forma externa. Si esta ?ltima no existe
251
         * ser? la matriz identidad.
252
         * @return Matriz de la transformaci?n af?n.
253
         */
254
        public AffineTransform getAffineTransform();
255
        
256
        /**
257
         * Asigna una transformaci?n al raster para que se tenga en cuenta en la
258
         * asignaci?n del setView. Esta asignaci?n recalcula el extent, el
259
         * requestExtent y asigna el AffineTransform que se usar? para la
260
         * transformaci?n. Esta transformaci?n ser? considerada como si la imagen
261
         * tuviera asociado un rmf.
262
         * @param t Transformaci?n af?n a aplicar
263
         */
264
        public void setAffineTransform(AffineTransform transf);
265
        
266
        /**
267
         * Gets an object which vectorize a raster
268
         * @return
269
         * @throws RasterDriverException
270
         * @throws ProcessInterruptedException
271
         *         When the object Vectorization is built the raster data buffer is loaded. 
272
         *         This operation can be interrupted
273
         */
274
        public Vectorization createVectorizeObject() throws RasterDriverException, ProcessInterruptedException;
275
        
276
        /**
277
         * Builds an render object using this RasterDataStore
278
         * @return Render
279
         */
280
        public Render getRender();
281
        
282
        /**
283
         * Assigns a render object
284
         * @param render
285
         */
286
        public void setRender(Render render);
287
        
288
        /**
289
         * Saves georeferencing information in the rmf file
290
         * @throws RmfSerializerException
291
         */
292
        public void saveGeoreferencingToRmf() throws RmfSerializerException;
293
        
294
        /**
295
         * Saves a color table
296
         * @param table
297
         * @throws RmfSerializerException
298
         */
299
        public void saveColorTableToRmf(ColorTable table) throws RmfSerializerException;
300
        
301
        /**
302
         * Tipo de fichero soportado.
303
         * Devuelve true si el tipo de fichero (extension) est? soportado, si no
304
         * devuelve false.
305
         *
306
         * @param fName Fichero raster
307
         * @return  true si est? soportado, si no false.
308
                */
309
        public boolean isFileSupported(String fName);
310
        
311
        /**
312
         * Returns true if this DataStore is open and false if not
313
         * @return
314
         */
315
        public boolean isOpen();
316
        
317
        /**
318
         * Obtiene el flag que dice si el raster est? o no georreferenciado
319
         * @return true si est? georreferenciado y false si no lo est?.
320
         */
321
        public boolean isGeoreferenced();
322
        
323
        /**
324
         * Returns true if this data store is reproyectable or false if not
325
         * @return
326
         */
327
        public boolean isReproyectable();
328
        
329
        /**
330
         * Consulta de si un raster tiene rotaci?n o no.
331
         * @return true si tiene rotaci?n y false si no la tiene.
332
         */
333
        public boolean isRotated();
334
        
335
        /**
336
         * Obtiene el n?mero de overviews de una banda
337
         * @return N?mero de overviews del raster.
338
         */
339
        public int getOverviewCount(int band) throws BandAccessException, RasterDriverException;
340
        
341
        /**
342
         * Informa de si el dataset soporta overviews o no.
343
         * @return true si soporta overviews y false si no las soporta.
344
         */
345
        public boolean overviewsSupport();
346
        
347
        /**
348
         * Obtiene el ancho de una overview de una banda
349
         * @return
350
         */
351
        public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
352

    
353
        /**
354
         * Obtiene el alto de una overview de una banda
355
         * @return
356
         */
357
        public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
358

    
359
        /**
360
         * Returns the band list
361
         * @return
362
         */
363
        public BandList getBands();
364
                
365
        /**
366
         * Clones this object
367
         * @return RasterDataStore
368
         * @throws CloneException 
369
         */
370
        public RasterDataStore cloneDataStore() throws CloneException;
371
        
372
        /**
373
         * Gets a provider
374
         * @return
375
         */
376
        public CoverageStoreProvider getProvider();
377
        
378
        /**
379
         * Sets a provider
380
         * @return
381
         */
382
        public void setProvider(CoverageStoreProvider prov);
383
        
384
        /**
385
         * Deletes the cache of this layer composed by the files in the provider list
386
         */
387
        public void deleteLayerFromCache();
388
        
389
        /**
390
         * Sets the parameters
391
         * @param p
392
         */
393
        public void setParameters(DataStoreParameters p);
394
        
395
        /**
396
         * Returns the source type (FILE, POSTGIS, REMOTE,...)
397
         * @return
398
         */
399
        public int getSourceType();
400
        
401
        /**
402
         * This method will return the DataParameters if it has a simple provider behind. If it has
403
         * a TileProvider this method will return the DataParameters used by the TileProvider.  
404
         * @return
405
         */
406
        public RasterDataParameters getInternalParameters();
407
        
408
        /**
409
         * Closes this data store
410
         * @throws CloseException
411
         */
412
        public void close() throws CloseException;
413
        
414
        
415
        //******************************************
416
        //***********Query methods******************
417
        
418
        /**
419
         * Returns the last buffer loaded if the flag storeLastBuffer in the query is true
420
         * @return
421
         */
422
        public Buffer getLastBuffer();
423
        
424
        /**
425
         * Gets the step
426
         * @return
427
         */
428
        public double[] getStep();
429
        
430
        /**
431
         * Gets a pixel 
432
         * @param x
433
         * @param y
434
         * @param band
435
         * @return
436
         * @throws InvalidSetViewException
437
         * @throws FileNotOpenException
438
         * @throws RasterDriverException
439
         */
440
        public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
441
        
442
        /**
443
         * Makes a request to load a buffer of data. This call returns an array of results. The first
444
         * element in the array is the buffer and the other elements are the transparency buffer, 
445
         * the legend and so on. This funtion is mainly used by the getTile call. This array contains
446
         * all visualization properties. 
447
         * @param query 
448
         * @return Object[]
449
         */
450
        public Object[] queryArray(RasterQuery query) throws ProcessInterruptedException, RasterDriverException, InvalidSetViewException;
451
        
452
        /**
453
         * Makes a request to load a buffer of data. This call returns only a buffer. This call is used
454
         * by most functions because the properties are read from the datastore.
455
         * @param query 
456
         * @return Buffer
457
         */
458
        public Buffer query(RasterQuery query) throws ProcessInterruptedException, RasterDriverException, InvalidSetViewException;
459
        
460
        /**
461
         * Sets a tile server to create a second level of cache. This second level will be
462
         * created if the cache structure is different to the current.
463
         * @param tileServer
464
         */
465
        public void setTileServer(Class<?> tileServer) throws InitializeException;
466
        
467
        /**
468
         * Some sevices has neither limits nor pixel size. For instance, WebMapService 
469
         * is a service of this type if the size is not fixed. Other services, like
470
         * WMTS are enclosed too but in this case it will have resolution by level.
471
         * This method returns true if the data source is enclosed.
472
         * @return
473
         */
474
        public boolean isRasterEnclosed();
475
        
476
        /**
477
         * This function returns true if the image to be loaded needs a enhanced filter or
478
         * doesn't. It depends on the format, number of bands, type of data and so on.
479
         * @return The default value is false but each driver can change this value.
480
         */
481
        public boolean needEnhanced();
482
        
483
        /**
484
         * Sets the transformation
485
         * @param t
486
         */
487
        public void setCoordTrans(ICoordTrans t);
488
}