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

History | View | Annotate | Download (17 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
import java.io.File;
27
import java.util.List;
28

    
29
import org.cresques.cts.ICoordTrans;
30
import org.cresques.cts.IProjection;
31
import org.gvsig.compat.net.ICancellable;
32
import org.gvsig.fmap.dal.DataStore;
33
import org.gvsig.fmap.dal.DataStoreParameters;
34
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
35
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
36
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
37
import org.gvsig.fmap.dal.coverage.datastruct.GeoPointList;
38
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
39
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
40
import org.gvsig.fmap.dal.coverage.exception.CloneException;
41
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
42
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException;
43
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
44
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
45
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
46
import org.gvsig.fmap.dal.coverage.exception.ROIException;
47
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
48
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
49
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
50
import org.gvsig.fmap.dal.coverage.grid.render.Render;
51
import org.gvsig.fmap.dal.coverage.process.vector.Vectorization;
52
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
53
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
54
import org.gvsig.fmap.dal.coverage.store.props.Histogramable;
55
import org.gvsig.fmap.dal.coverage.store.props.Metadata;
56
import org.gvsig.fmap.dal.exception.CloseException;
57
import org.gvsig.fmap.dal.exception.InitializeException;
58
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
59
import org.gvsig.raster.roi.ROI;
60

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

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

    
389
        /**
390
         * Obtiene el alto de una overview de una banda
391
         * @return
392
         */
393
        public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
394

    
395
        /**
396
         * Returns the band list
397
         * @return
398
         */
399
        public BandList getBands();
400
                
401
        /**
402
         * Clones this object
403
         * @return RasterDataStore
404
         * @throws CloneException 
405
         */
406
        public RasterDataStore cloneDataStore() throws CloneException;
407
        
408
        /**
409
         * Gets a provider
410
         * @return
411
         */
412
        public CoverageStoreProvider getProvider();
413
        
414
        /**
415
         * Sets a provider
416
         * @return
417
         */
418
        public void setProvider(CoverageStoreProvider prov);
419
        
420
        /**
421
         * Deletes the cache of this layer composed by the files in the provider list
422
         */
423
        public void deleteLayerFromCache();
424
        
425
        /**
426
         * Sets the parameters
427
         * @param p
428
         */
429
        public void setParameters(DataStoreParameters p);
430
        
431
        /**
432
         * Returns the source type (FILE, POSTGIS, REMOTE,...)
433
         * @return
434
         */
435
        public int getSourceType();
436
        
437
        /**
438
         * This method will return the DataParameters if it has a simple provider behind. If it has
439
         * a TileProvider this method will return the DataParameters used by the TileProvider.  
440
         * @return
441
         */
442
        public RasterDataParameters getInternalParameters();
443
        
444
        /**
445
         * Closes this data store
446
         * @throws CloseException
447
         */
448
        public void close() throws CloseException;
449
        
450
        
451
        //******************************************
452
        //***********Query methods******************
453
        
454
        /**
455
         * Returns the last buffer loaded if the flag storeLastBuffer in the query is true
456
         * @return
457
         */
458
        public Buffer getLastBuffer();
459
        
460
        /**
461
         * Gets the step
462
         * @return
463
         */
464
        public double[] getStep();
465
        
466
        /**
467
         * Gets a pixel 
468
         * @param x
469
         * @param y
470
         * @param band
471
         * @return
472
         * @throws InvalidSetViewException
473
         * @throws FileNotOpenException
474
         * @throws RasterDriverException
475
         */
476
        public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
477
        
478
        /**
479
         * Makes a request to load a buffer of data. This call returns an array of results. The first
480
         * element in the array is the buffer and the other elements are the transparency buffer, 
481
         * the legend and so on. This funtion is mainly used by the getTile call. This array contains
482
         * all visualization properties. 
483
         * @param query 
484
         * @return Object[]
485
         */
486
        public Object[] queryArray(RasterQuery query) throws ProcessInterruptedException, RasterDriverException, InvalidSetViewException;
487
        
488
        /**
489
         * Makes a request to load a buffer of data. This call returns only a buffer. This call is used
490
         * by most functions because the properties are read from the datastore.
491
         * @param query 
492
         * @return Buffer
493
         */
494
        public Buffer query(RasterQuery query) throws ProcessInterruptedException, RasterDriverException, InvalidSetViewException;
495
        
496
        /**
497
         * Sets a tile server to create a second level of cache. This second level will be
498
         * created if the cache structure is different to the current.
499
         * @param tileServer
500
         */
501
        public void setTileServer(Class<?> tileServer) throws InitializeException;
502
        
503
        /**
504
         * Some sevices has neither limits nor pixel size. For instance, WebMapService 
505
         * is a service of this type if the size is not fixed. Other services, like
506
         * WMTS are enclosed too but in this case it will have resolution by level.
507
         * This method returns true if the data source is enclosed.
508
         * @return
509
         */
510
        public boolean isRasterEnclosed();
511
        
512
        /**
513
         * This function returns true if the image to be loaded needs a enhanced filter or
514
         * doesn't. It depends on the format, number of bands, type of data and so on.
515
         * @return The default value is false but each driver can change this value.
516
         */
517
        public boolean needEnhanced();
518
        
519
        /**
520
         * Sets the transformation
521
         * @param t
522
         */
523
        public void setCoordTrans(ICoordTrans t);
524
        
525
        /**
526
         * Gets the information in a real point
527
         * @param x
528
         *        X Pixel position
529
         * @param y
530
         *        Y pixel position
531
         * @return
532
         */
533
        public String getInfoByPoint(double x, double y, ICancellable cancellable) throws InfoByPointException;
534
        
535
        /**
536
         * Gets the information in a pixel point. Some services need additional 
537
         * information as the window where the request is done 
538
         * @param x
539
         *        X Pixel position
540
         * @param y
541
         *        Y pixel position
542
         * @param bbox
543
         *        Bounding box of the window
544
         * @param w
545
         *        Width in pixels of the window
546
         * @param h
547
         *        Height in pixels of the window
548
         * @param cancellable
549
         * @return
550
         * @throws RemoteServiceException
551
         */
552
        public String getInfoByPoint(double x, double y, Extent extent, int w, int h, ICancellable cancellable) throws InfoByPointException;
553
        
554
        /**
555
         * Gets the list of geo points associated to this provider
556
         * @return
557
         */
558
        public GeoPointList getGeoPointList();
559
        
560
        /**
561
         * Sets the list of geo points associated to this provider
562
         */
563
        public void setGeoPointList(GeoPointList geoPointList);
564
        
565
        /**
566
         * Gets the list of regions of interest
567
         * @param defaultProjection
568
         * @return
569
         * @throws ROIException
570
         */
571
        public List<ROI> getRois(IProjection defaultProjection) throws ROIException;
572
        
573
        /**
574
         * Gets the list of regions of interest
575
         * @param defaultProjection
576
         * @return
577
         * @throws ROIException
578
         */
579
        public List<ROI> getRois(String epsg) throws ROIException;
580
        
581
        /**
582
         * Sets the list of regions of interest
583
         * @param rois
584
         */
585
        public void setRois(List<ROI> rois);
586
        
587
}