Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / provider / RasterProvider.java @ 1800

History | View | Annotate | Download (19.7 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

    
56
/**
57
 * Interfaz que deben implementar cualquier fuente de datos raster. Estas pueden estar
58
 * compuestas por N datasets. B?sicamente hay dos fuentes que deben implementar este interfaz, 
59
 * MultiRasterDataset y CompositeDataset. La primera es un dataset compuesto por varios ficheros
60
 * con el mismo Extent de N bandas cada uno. MultiRasterDataset proporciona una encapsulaci?n al acceso
61
 * a datos de todos ellos. CompositeDataset es un dataset compuesto de N MultiRasterDatasets cuya extensi?n
62
 * es continua formando un Grid de datasets con continuidad espacial. IRasterDataSource proporciona
63
 * una visi?n de acceso a datos com?n para ambos.
64
 * 
65
 * @author Nacho Brodin (nachobrodin@gmail.com)
66
 *
67
 */
68
public interface RasterProvider extends CoverageStoreProvider, Histogramable {
69
        
70
        /**
71
         * Gets a list of sizes. If the provider doesn't have files it will return null.
72
         * If the provider has one file it will return an array of one element with the
73
         * size of this file. If the provider contains others with one file each one.
74
         * @return
75
         */
76
        public long[] getFileSizeByProvider();
77
        
78
        /**
79
         * Gets a list of file names or URI. Each element of this array is the name of a 
80
         * provider 
81
         * @return
82
         */
83
        public String[] getURIByProvider();
84
        
85
        /**
86
         * Gets the URI of the first provider.
87
         * @return String 
88
         *         File name or URI
89
         */
90
        public String getURIOfFirstProvider();
91
        
92
        /**
93
         * Gets the number of bands by provider. 
94
         * @return
95
         */
96
        public int[] getBandCountByProvider();
97
        
98
        /**
99
         * Selecting a number of band this function returns the number of band
100
         * inside the file. If this provider has only one file the result
101
         * will be band parameter.
102
         * @param band
103
         * @return
104
         */
105
        public int getBandPositionByProvider(int band);
106
        
107
        /**
108
         * Returns the number of internal providers that it has
109
         * @return
110
         */
111
        public int getInternalProviderCount();
112
        
113
        /**
114
         * Gets the internal provider of the i position
115
         * @param i
116
         * @return
117
         */
118
        public RasterProvider getInternalProvider(int i);
119
        
120
        /**
121
         * Gets the URI of the source. If the provider has only one band
122
         * the result will be the URI. If it is multifile will have to choose
123
         * among several sources.
124
         * @param band
125
         * @return
126
         */
127
        public String getURIByBand(int band);
128
        
129
        /**
130
         * Gets the uniform resource identifier
131
         * @return
132
         */
133
        public String getURI();
134
        
135
        /**
136
         * Gets the number of subdatasets
137
         * @return
138
         */
139
        public int getSubdatasetCount();
140
        
141
        /**
142
         * Adds a new file. The behavior of this function depends on 
143
         * the kind of provider and its implementation.
144
         * @param file
145
         * @throws InvalidSourceException 
146
         */
147
        public void addFile(String file) throws InvalidSourceException;
148
        
149
        /**
150
         * Removes a file. The behavior of this function depends on 
151
         * the kind of provider and its implementation.
152
         * @param file
153
         */
154
        public void removeFile(String file);
155
        
156
        /**
157
         * Obtiene el n?mero de bandas del raster
158
         * @return N?mero de bandas
159
         */
160
        public int getBandCount();
161
        
162
        /**
163
         * Obtiene el tipo de dato por banda
164
         * @return tipo de dato por banda
165
         */
166
        public int[] getDataType();
167
        
168
        /**
169
         * Obtiene la altura del raster en p?xeles.
170
         * @return altura
171
         */
172
        public double getHeight();
173

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

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

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

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

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

    
432
        /**
433
         * Obtiene la proyecci?n asociada al raster. Como todos los dataset del 
434
         * multiDataset deben tener la misma proyecci?n obtenemos esta del primer
435
         * dataset.
436
         * @return Proyecci?n en formato cadena
437
         * @throws RasterDriverException
438
         */
439
        public String getWktProjection() throws RasterDriverException;
440
        
441
        /**
442
         * Dado unas coordenadas reales, un tama?o de buffer y un tama?o de raster. 
443
         * Si el buffer es de mayor tama?o que el raster (supersampleo) quiere decir que 
444
         * por cada pixel de buffer se repiten varios del raster. Esta funci?n calcula el 
445
         * n?mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
446
         * buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
447
         * solicitada es real y puede no caer sobre un pixel completo. Este calculo es
448
         * util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
449
         * el driver autom?ticamente.
450
         * @param dWorldTLX Coordenada real X superior izquierda
451
         * @param dWorldTLY Coordenada real Y superior izquierda
452
         * @param nWidth Ancho del raster
453
         * @param nHeight Alto del raster
454
         * @param bufWidth Ancho del buffer
455
         * @param bufHeight Alto del buffer
456
         * @return Array de cuatro. Los dos primeros elementos son el desplazamiento en X e Y y los dos segundos
457
         * el tama?o en pixels de buffer de un pixel de la imagen en ancho y alto.  
458
         */
459
        public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY,
460
                        double nWidth, double nHeight, int bufWidth, int bufHeight);
461
        
462
        /**
463
         * Sets the nodata value
464
         * @return
465
         */
466
        public void setNoDataValue(NoData value);
467
        
468
        /**
469
         * Obtiene el flag que dice si el raster est? o no georreferenciado
470
         * @return true si est? georreferenciado y false si no lo est?.
471
         */
472
        public boolean isGeoreferenced();
473
        
474
        /**
475
         * Returns true if the provider has several files and all of them has the same extension
476
         * @return
477
         */
478
        public boolean isMultiFile();
479
        
480
        /**
481
         * Returns true if the source of data is a mosaic of images
482
         * @return
483
         */
484
        public boolean isMosaic();
485
        
486
        /**
487
         * Deletes the cache of this layer composed by the files in the provider list
488
         */
489
        public void deleteLayerFromCache();
490
        
491
        /**
492
         * Clone this RasterProvider
493
         * @return
494
         */
495
        public RasterProvider cloneProvider() throws CloneException;
496
        
497
        /**
498
         * Returs the DataParameters
499
         * @return
500
         */
501
        public RasterDataParameters getDataParameters();
502
        
503
        /**
504
         * Lee un bloque completo de datos del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util
505
         * para una lectura rapida de todo el fichero sin necesidad de asignar vista.
506
         * @param pos Posici?n donde se empieza  a leer
507
         * @param blockHeight Altura m?xima del bloque leido
508
         * @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas)
509
         * @throws InvalidSetViewException
510
         * @throws FileNotOpenException
511
         * @throws RasterDriverException
512
         */
513
        public Object readBlock(int pos, int blockHeight, double scale)
514
                throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException;
515

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

    
633
        /**
634
         * Gets the set of data selected in the {@link RasterQuery}
635
         * @param q
636
         * @return
637
         * @throws RasterDriverException 
638
         * @throws ProcessInterruptedException 
639
         */
640
        public Buffer getDataSet(RasterQuery query) throws ProcessInterruptedException, RasterDriverException;
641
        
642
        /**
643
         * Gets the list of geo points associated to this provider
644
         * @return
645
         */
646
        public GeoPointList getGeoPointList();
647
        
648
        /**
649
         * Sets the list of geo points associated to this provider
650
         */
651
        public void setGeoPointList(GeoPointList geoPointList);
652
}