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

History | View | Annotate | Download (15.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.compat.net.ICancellable;
29
import org.gvsig.fmap.dal.DataStore;
30
import org.gvsig.fmap.dal.DataStoreParameters;
31
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
32
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
33
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
34
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
35
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
36
import org.gvsig.fmap.dal.coverage.exception.CloneException;
37
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
38
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException;
39
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
40
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
41
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
42
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
43
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
44
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
45
import org.gvsig.fmap.dal.coverage.grid.render.Render;
46
import org.gvsig.fmap.dal.coverage.process.vector.Vectorization;
47
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
48
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
49
import org.gvsig.fmap.dal.coverage.store.props.Histogramable;
50
import org.gvsig.fmap.dal.coverage.store.props.Metadata;
51
import org.gvsig.fmap.dal.exception.CloseException;
52
import org.gvsig.fmap.dal.exception.InitializeException;
53
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
54

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

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

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

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