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

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

    
30
import org.cresques.cts.ICoordTrans;
31
import org.cresques.cts.IProjection;
32

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

    
64
/**
65
 * Interfaz que deben implementar los almacenes de datos raster.
66
 *
67
 * @author Nacho Brodin (nachobrodin@gmail.com)
68
 */
69
public interface RasterDataStore extends DataStore, TRasterStore,
70
        PyramidRasterStore, RasterStoreProperties, Histogramable {
71
        public static final int              RED_BAND            = 0x01;
72
        public static final int              GREEN_BAND          = 0x02;
73
        public static final int              BLUE_BAND           = 0x04;
74
        public static final int              ALPHA_BAND          = 0x08;
75

    
76
        /**
77
        * Tipos de raster dependiendo de su fuente
78
        */
79
        public static final int              FILE                = 0;
80
        public static final int              POSTGIS             = 1;
81
        public static final int              REMOTE              = 2;
82
        public static final int              MOSAIC              = 3;
83

    
84
        /**
85
         * Actions to reload the information of a layer such as, read rmf or
86
         * tfw files
87
         */
88
        public void reload();
89

    
90
        /**
91
         * Gets a default band list for this provider
92
         * @return
93
         */
94
        public BandList getDefaultBandList();
95

    
96
        /**
97
         * Gets a list of data parameters. If it doesn't have
98
         * internal providers this method will return only one DataParameter
99
         * @return
100
         */
101
        public RasterDataParameters[] getDataParametersByProvider();
102

    
103
        /**
104
         * Gets a list of sizes. If the provider doesn't have files it will return null.
105
         * If the provider has one file it will return an array of one element with the
106
         * size of this file. If the provider contains others with one file each one.
107
         * @return
108
         */
109
        public long[] getFileSizeByProvider();
110

    
111
        /**
112
         * Gets a list of file names or URI. Each element of this array is the name of a
113
         * provider
114
         * @return
115
         */
116
        public URI[] getURIByProvider();
117

    
118
        /**
119
         * Gets the number of bands by provider.
120
         * @return
121
         */
122
        public int[] getBandCountByProvider();
123

    
124
        /**
125
         * Gets a list of Metadata
126
         * @return
127
         */
128
        public Metadata[] getMetadataByProvider();
129

    
130
        /**
131
         * Gets the number of overviews by provider
132
         * @param number of band
133
         * @return
134
         */
135
        public int[] getOverviewCountByProvider(int band) throws BandAccessException;
136

    
137
        /**
138
         * Gets the size of a overview in one band. The result is a list of strings (WidthXHeight)
139
         *
140
         * @param band
141
         * @return
142
         */
143
        public String[] getOverviewSizeByProvider(int band, int overview) throws BandAccessException;
144

    
145
        /**
146
         * Gets a list of affine transforms
147
         * @return
148
         */
149
        public AffineTransform[] getAffineTransformByProvider();
150

    
151
        /**
152
         * Gets the height by provider
153
         * @return
154
         */
155
        public double[] getHeightByProvider();
156

    
157
        /**
158
         * Gets the width by provider
159
         * @return
160
         */
161
        public double[] getWidthByProvider();
162

    
163
        /**
164
         * Gets the URI of the source. If the provider has only one band
165
         * the result will be the URI. If it is multifile will have to choose
166
         * among several sources.
167
         * @param band
168
         * @return
169
         */
170
        public URI getURIByBand(int band);
171

    
172
        /**
173
         * Returns the number of internal providers that it has
174
         * @return
175
         */
176
        public int getProviderCount();
177

    
178
        /**
179
         * Adds a new file. The behavior of this function depends on
180
         * the kind of provider and its implementation.
181
         * @param file
182
         * @throws InvalidSourceException
183
         */
184
        public void addFile(File file) throws InvalidSourceException;
185

    
186
        /**
187
         * Removes a file. The behavior of this function depends on
188
         * the kind of provider and its implementation.
189
         * @param file
190
         */
191
        public void removeFile(File file);
192

    
193
        /**
194
         * Define el valor NoData asociado al raster.
195
         * @return
196
         */
197
        public void setNoDataValue(NoData value);
198

    
199
        /**
200
         * Obtiene el extent asignado
201
         * @return        Extent
202
         */
203
        public Extent getView();
204

    
205
        /**
206
         * Creates a new dataset which has the same source reference
207
         * @return RasterDataStore
208
         */
209
        public RasterDataStore newDataStore();
210

    
211
        /**
212
         * Creates a new dataset which has the same source reference but insure
213
         * that the provider will be not tiled. Most of processes has to be applied
214
         * over not tiled providers
215
         * @return RasterDataStore
216
         */
217
        public RasterDataStore newNotTiledDataStore();
218

    
219
        /**
220
         * Obtiene el Tama?o de cada fichero de que consta el raster en bytes.
221
         * @return long que representa el tama?o
222
         */
223
        public long getFileSize();
224

    
225
        /**
226
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
227
         * @param pt Punto a transformar
228
         * @return punto transformado en coordenadas del mundo
229
         */
230
        public Point2D rasterToWorld(Point2D pt);
231

    
232
        /**
233
         * Convierte un punto desde del mundo a coordenadas pixel.
234
         * @param pt Punto a transformar
235
         * @return punto transformado en coordenadas pixel
236
         */
237
        public Point2D worldToRaster(Point2D pt);
238

    
239
        /**
240
         * Metodo que obtiene si un punto cae dentro de los l?mites de la extensi?n de la fuente de
241
         * datos raster o fuera de ellos.
242
         * @param p Punto a calcular
243
         * @return true si est? dentro de los l?mites y false si est? fuera
244
         */
245
        public boolean isInside(Point2D p);
246

    
247
        /**
248
         * Returns true if the data source is tiled
249
         * @return
250
         */
251
        public boolean isTiled();
252

    
253
        /**
254
         * Returns true if the provider has several files and all of them has the same extension
255
         * @return
256
         */
257
        public boolean isMultiFile();
258

    
259
        /**
260
         * Returns true if the source of data is a mosaic of images
261
         * @return
262
         */
263
        public boolean isMosaic();
264

    
265
        /**
266
         * Obtiene la matriz de transformaci?n del propio raster. Esta matriz es la
267
         * encargada de convertir las coordenadas de la petici?n en coordenadas a las
268
         * que se pide a la libreria. En gdal, por ejemplo, se piden las coordenadas a
269
         * la libreria en coordenadas pixel por lo que esta matriz tendr? la
270
         * georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias
271
         * como ermapper la petici?n a la libreria se hace en coordenadas geograficas
272
         * que son las mismas en las que pide el usuario de gvSIG por lo que esta
273
         * matriz en este caso se inicializa con la identidad.
274
         * @return
275
         */
276
        public AffineTransform getOwnAffineTransform();
277

    
278
        /**
279
         * Obtiene la transformaci?n afin aplicada en las peticiones con coordenadas
280
         * reales. Esta corresponde al producto matricial entre la transformaci?n de
281
         * la propia georreferenciaci?n del raster (ownTransformation) y la
282
         * transformaci?n que se le aplique de forma externa. Si esta ?ltima no existe
283
         * ser? la matriz identidad.
284
         * @return Matriz de la transformaci?n af?n.
285
         */
286
        public AffineTransform getAffineTransform();
287

    
288
        /**
289
         * Asigna una transformaci?n al raster para que se tenga en cuenta en la
290
         * asignaci?n del setView. Esta asignaci?n recalcula el extent, el
291
         * requestExtent y asigna el AffineTransform que se usar? para la
292
         * transformaci?n. Esta transformaci?n ser? considerada como si la imagen
293
         * tuviera asociado un rmf.
294
         * @param t Transformaci?n af?n a aplicar
295
         */
296
        public void setAffineTransform(AffineTransform transf);
297

    
298
        /**
299
         * Gets an object which vectorize a raster
300
         * @return
301
         * @throws RasterDriverException
302
         * @throws ProcessInterruptedException
303
         *         When the object Vectorization is built the raster data buffer is loaded.
304
         *         This operation can be interrupted
305
         */
306
        public Vectorization createVectorizeObject() throws QueryException, ProcessInterruptedException;
307

    
308
        /**
309
         * Builds an render object using this RasterDataStore
310
         * @return Render
311
         */
312
        public Render getRender();
313

    
314
        /**
315
         * Assigns a render object
316
         * @param render
317
         */
318
        public void setRender(Render render);
319

    
320
        /**
321
         * Saves georeferencing information in the rmf file
322
         * @throws RmfSerializerException
323
         */
324
        public void saveGeoreferencingToRmf() throws RmfSerializerException;
325

    
326
        /**
327
         * Saves a color table
328
         * @param table
329
         * @throws RmfSerializerException
330
         */
331
        public void saveColorTableToRmf(ColorTable table) throws RmfSerializerException;
332

    
333
        /**
334
         * Saves the geo point list to a RMF file
335
         * @param pointList
336
         * @throws RmfSerializerException
337
         */
338
        public void saveGeoPointListToRmf(GeoPointList pointList) throws RmfSerializerException;
339

    
340
        /**
341
         * Saves a list of files in the RMF file
342
         * @param fileList
343
         * @throws RmfSerializerException
344
         */
345
        public void saveROIFileListToRmf(List<File> fileList) throws RmfSerializerException;
346

    
347
        /**
348
         * Gets the list of ROI files in the RMF
349
         * @return
350
         * @throws RmfSerializerException
351
         */
352
        public List<File> getROIFileListFromRmf();
353

    
354
        /**
355
         * Tipo de fichero soportado.
356
         * Devuelve true si el tipo de fichero (extension) est? soportado, si no
357
         * devuelve false.
358
         *
359
         * @param fName Fichero raster
360
         * @return  true si est? soportado, si no false.
361
                */
362
        public boolean isFileSupported(String fName);
363

    
364
        /**
365
         * Returns true if this DataStore is open and false if not
366
         * @return
367
         */
368
        public boolean isOpen();
369

    
370
        /**
371
         * Obtiene el flag que dice si el raster est? o no georreferenciado
372
         * @return true si est? georreferenciado y false si no lo est?.
373
         */
374
        public boolean isGeoreferenced();
375

    
376
        /**
377
         * Returns true if this data store is reproyectable or false if not
378
         * @return
379
         */
380
        public boolean isReproyectable();
381

    
382
        /**
383
         * Consulta de si un raster tiene rotaci?n o no.
384
         * @return true si tiene rotaci?n y false si no la tiene.
385
         */
386
        public boolean isRotated();
387

    
388
        /**
389
         * Obtiene el n?mero de overviews de una banda
390
         * @return N?mero de overviews del raster.
391
         */
392
        public int getOverviewCount(int band) throws BandAccessException, RasterDriverException;
393

    
394
        /**
395
         * Informa de si el dataset soporta overviews o no.
396
         * @return true si soporta overviews y false si no las soporta.
397
         */
398
        public boolean overviewsSupport();
399

    
400
        /**
401
         * Obtiene el ancho de una overview de una banda
402
         * @return
403
         */
404
        public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
405

    
406
        /**
407
         * Obtiene el alto de una overview de una banda
408
         * @return
409
         */
410
        public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
411

    
412
        /**
413
         * Returns the band list
414
         * @return
415
         */
416
        public BandList getBands();
417

    
418
        /**
419
         * Clones this object
420
         * @return RasterDataStore
421
         * @throws CloneException
422
         */
423
        public RasterDataStore cloneDataStore() throws CloneException;
424

    
425
        /**
426
         * Gets a provider
427
         * @return
428
         */
429
        public CoverageStoreProvider getProvider();
430

    
431
        /**
432
         * Sets a provider
433
         * @return
434
         */
435
        public void setProvider(CoverageStoreProvider prov);
436

    
437
        /**
438
         * Deletes the cache of this layer composed by the files in the provider list
439
         */
440
        public void deleteLayerFromCache();
441

    
442
        /**
443
         * Sets the parameters
444
         * @param p
445
         */
446
        public void setParameters(DataStoreParameters p);
447

    
448
        /**
449
         * Returns the source type (FILE, POSTGIS, REMOTE,...)
450
         * @return
451
         */
452
        public int getSourceType();
453

    
454
        /**
455
         * This method will return the DataParameters if it has a simple provider behind. If it has
456
         * a TileProvider this method will return the DataParameters used by the TileProvider.
457
         * @return
458
         */
459
        public RasterDataParameters getInternalParameters();
460

    
461
        /**
462
     * Sets the explorer
463
     * @param explorer
464
     */
465
    public void setExplorer(RasterDataServerExplorer explorer);
466

    
467
        /**
468
         * Closes this data store
469
         * @throws CloseException
470
         */
471
        public void close() throws CloseException;
472

    
473

    
474
        //******************************************
475
        //***********Query methods******************
476

    
477
        /**
478
         * Returns the last buffer loaded if the flag storeLastBuffer in the query is true
479
         * @return
480
         */
481
        public Buffer getLastBuffer();
482

    
483
        /**
484
         * Gets a pixel
485
         * @param x
486
         * @param y
487
         * @param band
488
         * @return
489
         * @throws InvalidSetViewException
490
         * @throws FileNotOpenException
491
         * @throws RasterDriverException
492
         */
493
        public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
494

    
495
        /**
496
         * Makes a request to load a buffer of data. This call returns an array of results. The first
497
         * element in the array is the buffer and the other elements are the transparency buffer,
498
         * the legend and so on. This funtion is mainly used by the getTile call. This array contains
499
         * all visualization properties.
500
         * @param query
501
         * @return Object[]
502
         */
503
        public Object[] queryArray(RasterQuery query) throws ProcessInterruptedException, QueryException;
504

    
505
        /**
506
         * Makes a request to load a buffer of data. This call returns only a buffer. This call is used
507
         * by most functions because the properties are read from the datastore.
508
         * @param query
509
         * @return Buffer
510
         */
511
        public Buffer query(RasterQuery query) throws ProcessInterruptedException, QueryException;
512

    
513
        /**
514
         * Sets a tile server to create a second level of cache. This second level will be
515
         * created if the cache structure is different to the current.
516
         * @param tileServer
517
         */
518
        public void setTileServer(Class<?> tileServer) throws InitializeException;
519

    
520
        /**
521
         * Some sevices has neither limits nor pixel size. For instance, WebMapService
522
         * is a service of this type if the size is not fixed. Other services, like
523
         * WMTS are enclosed too but in this case it will have resolution by level.
524
         * This method returns true if the data source is enclosed.
525
         * @return
526
         */
527
        public boolean isRasterEnclosed();
528

    
529
        /**
530
         * This function returns true if the image to be loaded needs a enhanced filter or
531
         * doesn't. It depends on the format, number of bands, type of data and so on.
532
         * @return The default value is false but each driver can change this value.
533
         */
534
        public boolean needEnhanced();
535

    
536
        /**
537
         * Sets the transformation
538
         * @param t
539
         */
540
        public void setCoordTrans(ICoordTrans t);
541

    
542
        /**
543
         * Gets the information in a real point
544
         * @param x
545
         *        X Pixel position
546
         * @param y
547
         *        Y pixel position
548
         * @return
549
         */
550
        public String getInfoByPoint(double x, double y, ICancellable cancellable) throws InfoByPointException;
551

    
552
        /**
553
         * Gets the information in a pixel point. Some services need additional
554
         * information as the window where the request is done
555
         * @param x
556
         *        X Pixel position
557
         * @param y
558
         *        Y pixel position
559
         * @param bbox
560
         *        Bounding box of the window
561
         * @param w
562
         *        Width in pixels of the window
563
         * @param h
564
         *        Height in pixels of the window
565
         * @param cancellable
566
         * @return
567
         * @throws RemoteServiceException
568
         */
569
        public String getInfoByPoint(double x, double y, Extent extent, int w, int h, ICancellable cancellable) throws InfoByPointException;
570

    
571
        /**
572
         * Gets the list of geo points associated to this provider
573
         * @return
574
         */
575
        public GeoPointList getGeoPointList();
576

    
577
        /**
578
         * Sets the list of geo points associated to this provider
579
         */
580
        public void setGeoPointList(GeoPointList geoPointList);
581

    
582
        /**
583
         * Gets the list of regions of interest
584
         * @param defaultProjection
585
         * @return
586
         * @throws ROIException
587
         */
588
        public List<ROI> getRois(IProjection defaultProjection) throws ROIException;
589

    
590
        /**
591
         * Gets the list of regions of interest
592
         * @param defaultProjection
593
         * @return
594
         * @throws ROIException
595
         */
596
        public List<ROI> getRois(String epsg) throws ROIException;
597

    
598
        /**
599
         * Sets the list of regions of interest
600
         * @param rois
601
         */
602
        public void setRois(List<ROI> rois);
603

    
604
}