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

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

    
30
import org.cresques.cts.IProjection;
31

    
32
import org.gvsig.compat.net.ICancellable;
33
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
34
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
35
import org.gvsig.fmap.dal.coverage.datastruct.GeoPointList;
36
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
37
import org.gvsig.fmap.dal.coverage.exception.BandAccessException;
38
import org.gvsig.fmap.dal.coverage.exception.CloneException;
39
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
40
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException;
41
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException;
42
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
43
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
44
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
45
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
46
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
47
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
48
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
49
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation;
50
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
51
import org.gvsig.fmap.dal.coverage.store.props.Histogramable;
52
import org.gvsig.fmap.dal.coverage.store.props.Metadata;
53
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
54
import org.gvsig.fmap.dal.coverage.store.props.TimeSeries;
55
import org.gvsig.fmap.dal.coverage.store.props.Transparency;
56
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
57
import org.gvsig.raster.cache.tile.provider.TileServer;
58
import org.gvsig.raster.impl.buffer.SpiRasterQuery;
59

    
60
/**
61
 * This interface have to be implemented by a raster data source. Is used by a store to
62
 * provide services from a specific source.
63
 *
64
 * @author Nacho Brodin (nachobrodin@gmail.com)
65
 *
66
 */
67
public interface RasterProvider extends CoverageStoreProvider, Histogramable {
68

    
69
        public void reload();
70

    
71
        /**
72
         * Gets a list of sizes. If the provider doesn't have files it will return null.
73
         * If the provider has one file it will return an array of one element with the
74
         * size of this file. If the provider contains others with one file each one.
75
         * @return
76
         */
77
        public long[] getFileSizeByProvider();
78

    
79
        /**
80
         * Gets a list of file names or URI. Each element of this array is the name of a
81
         * provider
82
         * @return
83
         */
84
        public URI[] getURIByProvider();
85

    
86
        /**
87
         * Gets the URI of the first provider.
88
         * @return String
89
         *         File name or URI
90
         */
91
        public URI getURIOfFirstProvider();
92

    
93
        /**
94
         * Gets the number of bands by provider.
95
         * @return
96
         */
97
        public int[] getBandCountByProvider();
98

    
99
        /**
100
         * Selecting a number of band this function returns the number of band
101
         * inside the file. If this provider has only one file the result
102
         * will be band parameter.
103
         * @param band
104
         * @return
105
         */
106
        public int getBandPositionByProvider(int band);
107

    
108
        /**
109
         * Returns the number of internal providers that it has
110
         * @return
111
         */
112
        public int getInternalProviderCount();
113

    
114
        /**
115
         * Gets the internal provider of the i position
116
         * @param i
117
         * @return
118
         */
119
        public RasterProvider getInternalProvider(int i);
120

    
121
        /**
122
         * Gets the URI of the source. If the provider has only one band
123
         * the result will be the URI. If it is multifile will have to choose
124
         * among several sources.
125
         * @param band
126
         * @return
127
         */
128
        public URI getURIByBand(int band);
129

    
130
        /**
131
         * Gets the uniform resource identifier
132
         * @return
133
         */
134
        public URI getURI();
135

    
136
        /**
137
         * Gets the number of subdatasets
138
         * @return
139
         */
140
        public int getSubdatasetCount();
141

    
142
        /**
143
         * Adds a new file. The behavior of this function depends on
144
         * the kind of provider and its implementation.
145
         * @param file
146
         * @throws InvalidSourceException
147
         */
148
        public void addFile(File file) throws InvalidSourceException;
149

    
150
        /**
151
         * Removes a file. The behavior of this function depends on
152
         * the kind of provider and its implementation.
153
         * @param file
154
         */
155
        public void removeFile(File file);
156

    
157
        /**
158
         * Obtiene el n?mero de bandas del raster
159
         * @return N?mero de bandas
160
         */
161
        public int getBandCount();
162

    
163
        /**
164
         * Obtiene el tipo de dato por banda
165
         * @return tipo de dato por banda
166
         */
167
        public int[] getDataType();
168

    
169
        /**
170
         * Obtiene la altura del raster en p?xeles.
171
         * @return altura
172
         */
173
        public double getHeight();
174

    
175
        /**
176
         * Obtiene la anchura del raster en p?xeles.
177
         * @return anchura
178
         */
179
        public double getWidth();
180

    
181
        /**
182
         * Devuelve si el Dataset es reproyectable
183
         * @return
184
         */
185
        public boolean isReproyectable();
186

    
187
        /**
188
         * Returns true if this raster has rotation and false if don't
189
         */
190
        public boolean isRotated();
191

    
192
        /**
193
         * Returns true if this provider is open and false if don't
194
         * @return
195
         */
196
        public boolean isOpen();
197

    
198
        /**
199
         * Returns true if this provider supports time.
200
         * @return
201
         */
202
        public boolean isTimeSupported();
203

    
204
        /**
205
         * Returns true if the provider support tiles
206
         * @return
207
         */
208
        public boolean isTiled();
209

    
210
        /**
211
         * Informa de si el dataset soporta overviews o no.
212
         * @return true si soporta overviews y false si no las soporta.
213
         */
214
        public boolean isOverviewsSupported();
215

    
216
        /**
217
         * Obtiene el n?mero de overviews de una banda
218
         * @return
219
         */
220
        public int getOverviewCount(int band) throws BandAccessException, RasterDriverException;
221

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

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

    
234

    
235
        /**
236
         * Informa de si el punto en coordenadas del mundo real pasado por par?metro cae dentro del
237
         * raster o fuera. Para este calculo cogeremos el punto a averiguar si est? dentro del raster
238
         * y le aplicaremos la transformaci?n inversa de la transformaci?n af?n aplicada. Una vez hecho
239
         * esto ya se puede comprobar si est? dentro de los l?mites del extent del raster.
240
         * @param p Punto a comprobar en coordenadas reales
241
         * @return true si el punto est? dentro y false si est? fuera.
242
         */
243
        public boolean isInside(Point2D p);
244

    
245
        /**
246
         * Gets the nodata value.
247
         * @return
248
         */
249
        public NoData getNoDataValue();
250

    
251
        /**
252
         * Gets statistics of this provider
253
         * @return MultiFileStatistics
254
         */
255
        public Statistics getStatistics();
256

    
257
        /**
258
         * Sets the statistics of this provider. Be careful using this method.
259
         * Statistics shouldn't be assigned unless you had cloned this provider.
260
         * @throws RmfSerializerException
261
         */
262
        public void setStatistics(Statistics stats) throws RmfSerializerException;
263

    
264
        /**
265
         * Obtiene el extent del raster.
266
         * @return Extent
267
         */
268
        public Extent getExtent();
269

    
270
        /**
271
         * Gets the suffix of the source file
272
         * @return
273
         */
274
        public String getFileSuffix();
275

    
276
        /**
277
         * Este es el extent sobre el que se ajusta una petici?n para que esta no
278
         * exceda el extent m?ximo del raster. Para un raster sin rotar ser? igual al
279
         * extent pero para un raster rotado ser? igual al extent del raster como si
280
         * no tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace
281
         * sobre la vista y las peticiones han de hacerse en coordenadas de la imagen
282
         * sin shearing aplicado.
283
         * @return Extent
284
         */
285
        public Extent getExtentWithoutRot();
286

    
287
        /**
288
         * Obtiene la matriz de transformaci?n del propio raster. Esta matriz es la
289
         * encargada de convertir las coordenadas de la petici?n en coordenadas a las
290
         * que se pide a la libreria. En gdal, por ejemplo, se piden las coordenadas a
291
         * la libreria en coordenadas pixel por lo que esta matriz tendr? la
292
         * georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias
293
         * como ermapper la petici?n a la libreria se hace en coordenadas geograficas
294
         * que son las mismas en las que pide el usuario de gvSIG por lo que esta
295
         * matriz en este caso se inicializa con la identidad.
296
         * @return
297
         */
298
        public AffineTransform getOwnAffineTransform();
299

    
300
        /**
301
         * Obtiene la transformaci?n afin aplicada en las peticiones con coordenadas
302
         * reales. Esta corresponde al producto matricial entre la transformaci?n de
303
         * la propia georreferenciaci?n del raster (ownTransformation) y la
304
         * transformaci?n que se le aplique de forma externa. Si esta ?ltima no existe
305
         * ser? la matriz identidad.
306
         * @return Matriz de la transformaci?n af?n.
307
         */
308
        public AffineTransform getAffineTransform();
309

    
310
        /**
311
         * Sets the provider projection
312
         * @return IProjection
313
         */
314
        public IProjection getProjection();
315

    
316
        /**
317
         * Gets the provider projection
318
         * @return IProjection
319
         */
320
        public void setProjection(IProjection proj, boolean persist) throws RmfSerializerException;
321

    
322
        /**
323
         * Obtiene el extent asignado
324
         * @return        Extent
325
         */
326
        public Extent getView();
327

    
328
        /**
329
         * Gets a DatasetMetadata object
330
         * @return
331
         */
332
        public Metadata getMetadata();
333

    
334
        /**
335
         * Gets the object with the color interpretation by band
336
         * @return ColorInterpretation
337
         */
338
        public ColorInterpretation getColorInterpretation();
339

    
340
        /**
341
         * Assigns the object with the color interpretation by band
342
         * @param ci
343
         */
344
        public void setColorInterpretation(ColorInterpretation ci);
345

    
346
        /**
347
         * Define el objeto paleta. Si se define null quiere decir que no tiene paleta
348
         * para su visualizaci?n.
349
         * @param value
350
         */
351
        public void setColorTable(ColorTable value);
352

    
353
        /**
354
         * Gets the {@link ColorTable} or null if the raster
355
         * does not have
356
         * @return
357
         */
358
        public ColorTable getColorTable();
359

    
360
        /**
361
         * Gets the legend as a image. The store could not have implemented this method .
362
         * This is useful above all for WMS but whatever raster layer
363
         * could return a legend as image.
364
         * @return
365
         */
366
        public Image getImageLegend();
367

    
368
        /**
369
         * Obtiene el estado de transparencia a partir de los estados de transparencia de todos
370
         * los ficheros que lo componen. Si varios de los ficheros que lo componen tienen banda de
371
         * transparencia estas tendr?n que ser mezcladas sobre una banda de transparencia ?nica.
372
         * @return Objeto FileTransparency con el estado de transparencia
373
         */
374
        public Transparency getTransparency();
375

    
376
        /**
377
         * Cierra los raster asociados.
378
         */
379
        public void close();
380

    
381
        /**
382
         * Convierte un punto desde coordenadas pixel a coordenadas del mundo.
383
         * @param pt Punto a transformar
384
         * @return punto transformado en coordenadas del mundo
385
         */
386
        public Point2D rasterToWorld(Point2D pt);
387

    
388
        /**
389
         * Convierte un punto desde del mundo a coordenadas pixel.
390
         * @param pt Punto a transformar
391
         * @return punto transformado en coordenadas pixel
392
         */
393
        public Point2D worldToRaster(Point2D pt);
394

    
395
        /**
396
         * Asigna una transformaci?n al raster para que se tenga en cuenta en la
397
         * asignaci?n del setView. Esta asignaci?n recalcula el extent, el
398
         * requestExtent y asigna el AffineTransform que se usar? para la
399
         * transformaci?n. Esta transformaci?n ser? considerada como si la imagen
400
         * tuviera asociado un rmf.
401
         * @param t Transformaci?n af?n a aplicar
402
         */
403
        public void setAffineTransform(AffineTransform t);
404

    
405
        /**
406
         * Gets the pixel size
407
         * @return
408
         */
409
        public double getCellSize();
410

    
411
        /**
412
         * Obtiene el tama?o de pixel en X
413
         * @return tama?o de pixel en X
414
         */
415
        public double getPixelSizeX();
416

    
417
        /**
418
         * Obtiene el tama?o de pixel en Y
419
         * @return tama?o de pixel en Y
420
         */
421
        public double getPixelSizeY();
422

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

    
433
        /**
434
         * Obtiene la proyecci?n asociada al raster. Como todos los dataset del
435
         * multiDataset deben tener la misma proyecci?n obtenemos esta del primer
436
         * dataset.
437
         * @return Proyecci?n en formato cadena
438
         * @throws RasterDriverException
439
         */
440
        public String getWktProjection() throws RasterDriverException;
441

    
442
        /**
443
         * Sets the nodata value
444
         * @return
445
         */
446
        public void setNoDataValue(NoData value);
447

    
448
        /**
449
         * Obtiene el flag que dice si el raster est? o no georreferenciado
450
         * @return true si est? georreferenciado y false si no lo est?.
451
         */
452
        public boolean isGeoreferenced();
453

    
454
        /**
455
         * Returns true if the provider has several files and all of them has the same extension
456
         * @return
457
         */
458
        public boolean isMultiFile();
459

    
460
        /**
461
         * Returns true if the source of data is a mosaic of images
462
         * @return
463
         */
464
        public boolean isMosaic();
465

    
466
        /**
467
         * Deletes the cache of this layer composed by the files in the provider list
468
         */
469
        public void deleteLayerFromCache();
470

    
471
        /**
472
         * Clone this RasterProvider
473
         * @return
474
         */
475
        public RasterProvider cloneProvider() throws CloneException;
476

    
477
        /**
478
         * Returs the DataParameters
479
         * @return
480
         */
481
        public RasterDataParameters getDataParameters();
482

    
483
        /**
484
         * Reads a complete block of data and returns an tridimensional array of the right type. This function is useful
485
         * to read a file very fast without setting a view.
486
         * @deprecated This method is only used to generate statistics. The statistics have to change the way in
487
         * which are calculated. Then this function will be eliminated.
488
         */
489
        public Object readBlock(int pos, int blockHeight, double scale)
490
                throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException;
491

    
492

    
493
        /**
494
         * Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
495
         * Usa value para iniciar dicho serializador
496
         * @param class1
497
         * @param value
498
         * @return
499
         * @throws RmfSerializerException
500
         */
501
        public Object loadObjectFromRmf(Class<?> class1, Object value) throws RmfSerializerException;
502

    
503
        /**
504
         * Guarda en el RMF el objecto actual en caso de que exista un serializador para el.
505
         * El tipo del objeto se especifica en el parametro class1.
506
         * Esto nos puede permitir poder poner a null un valor y encontrar su serializador.
507
         * @param class1
508
         * @param value
509
         * @throws RmfSerializerException
510
         */
511
        public void saveObjectToRmf(Class<?> class1, Object value) throws RmfSerializerException;
512

    
513
        /**
514
         * Sets the status information using other provider of the same type. The first action
515
         * of this method should be to check the type of the parameter.
516
         * @param provider
517
         */
518
        public void setStatus(RasterProvider provider);
519

    
520
        /**
521
         * Gets the information in a real point
522
         * @param x
523
         * @param y
524
         * @return
525
         * @throws RemoteServiceException
526
         */
527
        public String getInfoByPoint(double x, double y, ICancellable cancellable) throws InfoByPointException;
528

    
529
        /**
530
         * Gets the information in a pixel point. Some services need additional
531
         * information as the window where the request is done
532
         * @param x
533
         *        X Pixel position
534
         * @param y
535
         *        Y pixel position
536
         * @param bbox
537
         *        Bounding box of the window
538
         * @param w
539
         *        Width in pixels of the window
540
         * @param h
541
         *        Height in pixels of the window
542
         * @param cancellable
543
         * @return
544
         * @throws RemoteServiceException
545
         */
546
        public String getInfoByPoint(int x, int y, Extent bbox, int w, int h, ICancellable cancellable) throws InfoByPointException;
547

    
548
        /**
549
         * Gets the tile cache data server
550
         * @return
551
         */
552
        public TileServer getTileServer();
553

    
554
        /**
555
         * Some services neither has limits nor pixel size. For instance, WebMapService
556
         * is a service of this type if the size is not fixed. Other services, like
557
         * WMTS are enclosed too but in this case it will have resolution by level.
558
         * This method returns true if the data source is enclosed.
559
         * @return
560
         */
561
        public boolean isRasterEnclosed();
562

    
563
        /**
564
         * Gets the rmf file path. This method will have to be redefined by providers
565
         * with a different path
566
         * @return
567
         */
568
        public File getRMFFile();
569

    
570
        /**
571
         * Selects the subdataset.
572
         */
573
        public void selectSubdataset();
574

    
575
        /**
576
         * Gets the list of supported formats
577
         * @return
578
         */
579
        public String[] getFormatList();
580

    
581
        /**
582
         * Returns the source type (FILE, POSTGIS, REMOTE,...)
583
         * @return
584
         */
585
        public int getSourceType();
586

    
587
        /**
588
         * This function returns true if the image to be loaded needs a enhanced filter or
589
         * doesn't. It depends on the format, number of bands, type of data and so on.
590
         * @return The default value is false but each driver can change this value.
591
         */
592
        public boolean needEnhanced();
593

    
594
        /**
595
         * Gets the time serial information
596
         * @return
597
         * @throws RmfSerializerException
598
         */
599
        public TimeSeries getTimeSerials() throws RmfSerializerException;
600

    
601
        /**
602
         * Sets the time serial information
603
         * @throws RmfSerializerException
604
         */
605
        public void setTimeSerials(TimeSeries serialInfo) throws RmfSerializerException;
606

    
607
        /**
608
         * Gets the set of data selected in the {@link RasterQuery}
609
         * @param q
610
         * @return
611
         * @throws RasterDriverException
612
         * @throws ProcessInterruptedException
613
         */
614
        public Buffer getDataSet(SpiRasterQuery query) throws ProcessInterruptedException, RasterDriverException;
615

    
616
        /**
617
         * Gets the list of geo points associated to this provider
618
         * @return
619
         */
620
        public GeoPointList getGeoPointList();
621

    
622
        /**
623
         * Sets the list of geo points associated to this provider
624
         */
625
        public void setGeoPointList(GeoPointList geoPointList);
626

    
627
}