Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster_dataaccess_refactoring / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / provider / RasterProvider.java @ 2308

History | View | Annotate | Download (18.1 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.Image;
25
import java.awt.geom.AffineTransform;
26
import java.awt.geom.Point2D;
27

    
28
import org.cresques.cts.IProjection;
29
import org.gvsig.compat.net.ICancellable;
30
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
31
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
32
import org.gvsig.fmap.dal.coverage.datastruct.GeoPointList;
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.InfoByPointException;
38
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
39
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
40
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
41
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
42
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
43
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
44
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
45
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
46
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
47
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
48
import org.gvsig.fmap.dal.coverage.store.props.Histogramable;
49
import org.gvsig.fmap.dal.coverage.store.props.Metadata;
50
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
51
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries;
52
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
53
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
54
import org.gvsig.raster.cache.tile.provider.TileServer;
55
import org.gvsig.raster.impl.buffer.SpiRasterQuery;
56

    
57
/**
58
 * This interface have to be implemented by a raster data source. Is used by a store to
59
 * provide services from a specific source.
60
 * 
61
 * @author Nacho Brodin (nachobrodin@gmail.com)
62
 *
63
 */
64
public interface RasterProvider extends CoverageStoreProvider, Histogramable {
65
        
66
        public void reload();
67
        
68
        /**
69
         * Gets a list of sizes. If the provider doesn't have files it will return null.
70
         * If the provider has one file it will return an array of one element with the
71
         * size of this file. If the provider contains others with one file each one.
72
         * @return
73
         */
74
        public long[] getFileSizeByProvider();
75
        
76
        /**
77
         * Gets a list of file names or URI. Each element of this array is the name of a 
78
         * provider 
79
         * @return
80
         */
81
        public String[] getURIByProvider();
82
        
83
        /**
84
         * Gets the URI of the first provider.
85
         * @return String 
86
         *         File name or URI
87
         */
88
        public String getURIOfFirstProvider();
89
        
90
        /**
91
         * Gets the number of bands by provider. 
92
         * @return
93
         */
94
        public int[] getBandCountByProvider();
95
        
96
        /**
97
         * Selecting a number of band this function returns the number of band
98
         * inside the file. If this provider has only one file the result
99
         * will be band parameter.
100
         * @param band
101
         * @return
102
         */
103
        public int getBandPositionByProvider(int band);
104
        
105
        /**
106
         * Returns the number of internal providers that it has
107
         * @return
108
         */
109
        public int getInternalProviderCount();
110
        
111
        /**
112
         * Gets the internal provider of the i position
113
         * @param i
114
         * @return
115
         */
116
        public RasterProvider getInternalProvider(int i);
117
        
118
        /**
119
         * Gets the URI of the source. If the provider has only one band
120
         * the result will be the URI. If it is multifile will have to choose
121
         * among several sources.
122
         * @param band
123
         * @return
124
         */
125
        public String getURIByBand(int band);
126
        
127
        /**
128
         * Gets the uniform resource identifier
129
         * @return
130
         */
131
        public String getURI();
132
        
133
        /**
134
         * Gets the number of subdatasets
135
         * @return
136
         */
137
        public int getSubdatasetCount();
138
        
139
        /**
140
         * Adds a new file. The behavior of this function depends on 
141
         * the kind of provider and its implementation.
142
         * @param file
143
         * @throws InvalidSourceException 
144
         */
145
        public void addFile(String file) throws InvalidSourceException;
146
        
147
        /**
148
         * Removes a file. The behavior of this function depends on 
149
         * the kind of provider and its implementation.
150
         * @param file
151
         */
152
        public void removeFile(String file);
153
        
154
        /**
155
         * Obtiene el n?mero de bandas del raster
156
         * @return N?mero de bandas
157
         */
158
        public int getBandCount();
159
        
160
        /**
161
         * Obtiene el tipo de dato por banda
162
         * @return tipo de dato por banda
163
         */
164
        public int[] getDataType();
165
        
166
        /**
167
         * Obtiene la altura del raster en p?xeles.
168
         * @return altura
169
         */
170
        public double getHeight();
171

    
172
        /**
173
         * Obtiene la anchura del raster en p?xeles.
174
         * @return anchura
175
         */
176
        public double getWidth();
177
        
178
        /**
179
         * Devuelve si el Dataset es reproyectable
180
         * @return
181
         */
182
        public boolean isReproyectable();
183
        
184
        /**
185
         * Returns true if this raster has rotation and false if don't
186
         */
187
        public boolean isRotated();
188
        
189
        /**
190
         * Returns true if this provider is open and false if don't
191
         * @return
192
         */
193
        public boolean isOpen();
194
        
195
        /**
196
         * Returns true if this provider supports time.
197
         * @return
198
         */
199
        public boolean isTimeSupported();
200
        
201
        /**
202
         * Returns true if the provider support tiles
203
         * @return
204
         */
205
        public boolean isTiled();
206
        
207
        /**
208
         * Informa de si el dataset soporta overviews o no.
209
         * @return true si soporta overviews y false si no las soporta.
210
         */
211
        public boolean isOverviewsSupported();
212
        
213
        /**
214
         * Obtiene el n?mero de overviews de una banda
215
         * @return
216
         */
217
        public int getOverviewCount(int band) throws BandAccessException, RasterDriverException;
218

    
219
        /**
220
         * Obtiene el ancho de una overview de una banda
221
         * @return
222
         */
223
        public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException;
224

    
225
        /**
226
         * Obtiene el alto de una overview de una banda
227
         * @return
228
         */
229
        public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException;
230

    
231
        
232
        /**
233
         * Informa de si el punto en coordenadas del mundo real pasado por par?metro cae dentro del
234
         * raster o fuera. Para este calculo cogeremos el punto a averiguar si est? dentro del raster
235
         * y le aplicaremos la transformaci?n inversa de la transformaci?n af?n aplicada. Una vez hecho
236
         * esto ya se puede comprobar si est? dentro de los l?mites del extent del raster.
237
         * @param p Punto a comprobar en coordenadas reales
238
         * @return true si el punto est? dentro y false si est? fuera.
239
         */
240
        public boolean isInside(Point2D p);
241
        
242
        /**
243
         * Gets the nodata value.
244
         * @return
245
         */
246
        public NoData getNoDataValue();
247
        
248
        /**
249
         * Gets statistics of this provider
250
         * @return MultiFileStatistics
251
         */
252
        public Statistics getStatistics();
253
        
254
        /**
255
         * Sets the statistics of this provider. Be careful using this method. 
256
         * Statistics shouldn't be assigned unless you had cloned this provider. 
257
         * @throws RmfSerializerException 
258
         */
259
        public void setStatistics(Statistics stats) throws RmfSerializerException;
260
        
261
        /**
262
         * Obtiene el extent del raster.
263
         * @return Extent
264
         */
265
        public Extent getExtent();
266
        
267
        /**
268
         * Gets the suffix of the source file 
269
         * @return
270
         */
271
        public String getFileSuffix();
272
        
273
        /**
274
         * Este es el extent sobre el que se ajusta una petici?n para que esta no
275
         * exceda el extent m?ximo del raster. Para un raster sin rotar ser? igual al
276
         * extent pero para un raster rotado ser? igual al extent del raster como si
277
         * no tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace
278
         * sobre la vista y las peticiones han de hacerse en coordenadas de la imagen
279
         * sin shearing aplicado.
280
         * @return Extent
281
         */
282
        public Extent getExtentWithoutRot();
283
        
284
        /**
285
         * Obtiene la matriz de transformaci?n del propio raster. Esta matriz es la
286
         * encargada de convertir las coordenadas de la petici?n en coordenadas a las
287
         * que se pide a la libreria. En gdal, por ejemplo, se piden las coordenadas a
288
         * la libreria en coordenadas pixel por lo que esta matriz tendr? la
289
         * georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias
290
         * como ermapper la petici?n a la libreria se hace en coordenadas geograficas
291
         * que son las mismas en las que pide el usuario de gvSIG por lo que esta
292
         * matriz en este caso se inicializa con la identidad.
293
         * @return
294
         */
295
        public AffineTransform getOwnAffineTransform();
296
        
297
        /**
298
         * Obtiene la transformaci?n afin aplicada en las peticiones con coordenadas
299
         * reales. Esta corresponde al producto matricial entre la transformaci?n de
300
         * la propia georreferenciaci?n del raster (ownTransformation) y la
301
         * transformaci?n que se le aplique de forma externa. Si esta ?ltima no existe
302
         * ser? la matriz identidad.
303
         * @return Matriz de la transformaci?n af?n.
304
         */
305
        public AffineTransform getAffineTransform();
306
        
307
        /**
308
         * Sets the provider projection
309
         * @return IProjection
310
         */
311
        public IProjection getProjection();
312
        
313
        /**
314
         * Gets the provider projection
315
         * @return IProjection
316
         */
317
        public void setProjection(IProjection proj, boolean persist) throws RmfSerializerException;
318
        
319
        /**
320
         * Obtiene el extent asignado
321
         * @return        Extent
322
         */
323
        public Extent getView();
324
        
325
        /**
326
         * Gets a DatasetMetadata object
327
         * @return
328
         */
329
        public Metadata getMetadata();
330
        
331
        /**
332
         * Gets the object with the color interpretation by band
333
         * @return ColorInterpretation
334
         */
335
        public ColorInterpretation getColorInterpretation();
336
        
337
        /**
338
         * Assigns the object with the color interpretation by band
339
         * @param ci
340
         */
341
        public void setColorInterpretation(ColorInterpretation ci);
342
        
343
        /**
344
         * Define el objeto paleta. Si se define null quiere decir que no tiene paleta
345
         * para su visualizaci?n.
346
         * @param value
347
         */
348
        public void setColorTable(ColorTable value);
349
        
350
        /**
351
         * Gets the {@link ColorTable} or null if the raster
352
         * does not have
353
         * @return
354
         */
355
        public ColorTable getColorTable();
356
        
357
        /**
358
         * Gets the legend as a image. The store could not have implemented this method .
359
         * This is useful above all for WMS but whatever raster layer 
360
         * could return a legend as image.
361
         * @return
362
         */
363
        public Image getImageLegend();
364
        
365
        /**
366
         * Obtiene el estado de transparencia a partir de los estados de transparencia de todos
367
         * los ficheros que lo componen. Si varios de los ficheros que lo componen tienen banda de 
368
         * transparencia estas tendr?n que ser mezcladas sobre una banda de transparencia ?nica.
369
         * @return Objeto FileTransparency con el estado de transparencia
370
         */
371
        public Transparency getTransparency();
372
        
373
        /**
374
         * Cierra los raster asociados.
375
         */
376
        public void close();
377
        
378
        /**
379
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
380
         * @param pt Punto a transformar
381
         * @return punto transformado en coordenadas del mundo
382
         */
383
        public Point2D rasterToWorld(Point2D pt);
384
        
385
        /**
386
         * Convierte un punto desde del mundo a coordenadas pixel.
387
         * @param pt Punto a transformar
388
         * @return punto transformado en coordenadas pixel
389
         */
390
        public Point2D worldToRaster(Point2D pt);
391
        
392
        /**
393
         * Asigna una transformaci?n al raster para que se tenga en cuenta en la
394
         * asignaci?n del setView. Esta asignaci?n recalcula el extent, el
395
         * requestExtent y asigna el AffineTransform que se usar? para la
396
         * transformaci?n. Esta transformaci?n ser? considerada como si la imagen
397
         * tuviera asociado un rmf.
398
         * @param t Transformaci?n af?n a aplicar
399
         */
400
        public void setAffineTransform(AffineTransform t);
401
        
402
        /**
403
         * Gets the pixel size
404
         * @return
405
         */
406
        public double getCellSize();
407
        
408
        /**
409
         * Obtiene el tama?o de pixel en X
410
         * @return tama?o de pixel en X
411
         */
412
        public double getPixelSizeX();
413

    
414
        /**
415
         * Obtiene el tama?o de pixel en Y
416
         * @return tama?o de pixel en Y
417
         */
418
        public double getPixelSizeY();
419
        
420
        /**
421
         * Obtiene el valor del raster en la coordenada que se le pasa.
422
         * El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
423
         * raster.
424
         * @param x        coordenada X
425
         * @param y coordenada Y
426
         * @return
427
         */
428
        public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException;
429

    
430
        /**
431
         * Obtiene la proyecci?n asociada al raster. Como todos los dataset del 
432
         * multiDataset deben tener la misma proyecci?n obtenemos esta del primer
433
         * dataset.
434
         * @return Proyecci?n en formato cadena
435
         * @throws RasterDriverException
436
         */
437
        public String getWktProjection() throws RasterDriverException;
438
        
439
        /**
440
         * Sets the nodata value
441
         * @return
442
         */
443
        public void setNoDataValue(NoData value);
444
        
445
        /**
446
         * Obtiene el flag que dice si el raster est? o no georreferenciado
447
         * @return true si est? georreferenciado y false si no lo est?.
448
         */
449
        public boolean isGeoreferenced();
450
        
451
        /**
452
         * Returns true if the provider has several files and all of them has the same extension
453
         * @return
454
         */
455
        public boolean isMultiFile();
456
        
457
        /**
458
         * Returns true if the source of data is a mosaic of images
459
         * @return
460
         */
461
        public boolean isMosaic();
462
        
463
        /**
464
         * Deletes the cache of this layer composed by the files in the provider list
465
         */
466
        public void deleteLayerFromCache();
467
        
468
        /**
469
         * Clone this RasterProvider
470
         * @return
471
         */
472
        public RasterProvider cloneProvider() throws CloneException;
473
        
474
        /**
475
         * Returs the DataParameters
476
         * @return
477
         */
478
        public RasterDataParameters getDataParameters();
479
        
480
        /**
481
         * Lee un bloque completo de datos del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util
482
         * para una lectura rapida de todo el fichero sin necesidad de asignar vista.
483
         * @param pos Posici?n donde se empieza  a leer
484
         * @param blockHeight Altura m?xima del bloque leido
485
         * @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas)
486
         * @throws InvalidSetViewException
487
         * @throws FileNotOpenException
488
         * @throws RasterDriverException
489
         */
490
        public Object readBlock(int pos, int blockHeight, double scale)
491
                throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException;
492

    
493
        
494
        /**
495
         * Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
496
         * Usa value para iniciar dicho serializador
497
         * @param class1
498
         * @param value
499
         * @return
500
         * @throws RmfSerializerException
501
         */
502
        public Object loadObjectFromRmf(Class<?> class1, Object value) throws RmfSerializerException;
503
        
504
        /**
505
         * Guarda en el RMF el objecto actual en caso de que exista un serializador para el.
506
         * El tipo del objeto se especifica en el parametro class1.
507
         * Esto nos puede permitir poder poner a null un valor y encontrar su serializador.
508
         * @param class1
509
         * @param value
510
         * @throws RmfSerializerException 
511
         */
512
        public void saveObjectToRmf(Class<?> class1, Object value) throws RmfSerializerException;
513
        
514
        /**
515
         * Sets the status information using other provider of the same type. The first action
516
         * of this method should be to check the type of the parameter.
517
         * @param provider
518
         */
519
        public void setStatus(RasterProvider provider);
520
        
521
        /**
522
         * Gets the information in a real point
523
         * @param x
524
         * @param y
525
         * @return
526
         * @throws RemoteServiceException 
527
         */
528
        public String getInfoByPoint(double x, double y, ICancellable cancellable) throws InfoByPointException;
529
        
530
        /**
531
         * Gets the information in a pixel point. Some services need additional 
532
         * information as the window where the request is done 
533
         * @param x
534
         *        X Pixel position
535
         * @param y
536
         *        Y pixel position
537
         * @param bbox
538
         *        Bounding box of the window
539
         * @param w
540
         *        Width in pixels of the window
541
         * @param h
542
         *        Height in pixels of the window
543
         * @param cancellable
544
         * @return
545
         * @throws RemoteServiceException
546
         */
547
        public String getInfoByPoint(int x, int y, Extent bbox, int w, int h, ICancellable cancellable) throws InfoByPointException;
548
        
549
        /**
550
         * Gets the tile cache data server
551
         * @return
552
         */
553
        public TileServer getTileServer();
554
        
555
        /**
556
         * Some services neither has limits nor pixel size. For instance, WebMapService 
557
         * is a service of this type if the size is not fixed. Other services, like
558
         * WMTS are enclosed too but in this case it will have resolution by level.
559
         * This method returns true if the data source is enclosed.
560
         * @return
561
         */
562
        public boolean isRasterEnclosed();
563
        
564
        /**
565
         * Gets the rmf file path. This method will have to be redefined by providers
566
         * with a different path
567
         * @return
568
         */
569
        public String getRMFFile();
570
        
571
        /**
572
         * Selects the subdataset.
573
         */
574
        public void selectSubdataset();
575
        
576
        /**
577
         * Gets the list of supported formats
578
         * @return
579
         */
580
        public String[] getFormatList();
581
        
582
        /**
583
         * Returns the source type (FILE, POSTGIS, REMOTE,...)
584
         * @return
585
         */
586
        public int getSourceType();
587
        
588
        /**
589
         * This function returns true if the image to be loaded needs a enhanced filter or
590
         * doesn't. It depends on the format, number of bands, type of data and so on.
591
         * @return The default value is false but each driver can change this value.
592
         */
593
        public boolean needEnhanced();
594
        
595
        /**
596
         * Gets the time serial information
597
         * @return
598
         * @throws RmfSerializerException 
599
         */
600
        public TimeSeries getTimeSerials() throws RmfSerializerException;
601
        
602
        /**
603
         * Sets the time serial information
604
         * @throws RmfSerializerException 
605
         */
606
        public void setTimeSerials(TimeSeries serialInfo) throws RmfSerializerException;
607

    
608
        /**
609
         * Gets the set of data selected in the {@link RasterQuery}
610
         * @param q
611
         * @return
612
         * @throws RasterDriverException 
613
         * @throws ProcessInterruptedException 
614
         */
615
        public Buffer getDataSet(SpiRasterQuery query) throws ProcessInterruptedException, RasterDriverException;
616
        
617
        /**
618
         * Gets the list of geo points associated to this provider
619
         * @return
620
         */
621
        public GeoPointList getGeoPointList();
622
        
623
        /**
624
         * Sets the list of geo points associated to this provider
625
         */
626
        public void setGeoPointList(GeoPointList geoPointList);
627
        
628
}