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 @ 2127
History | View | Annotate | Download (16.9 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.fmap.dal.coverage.store; |
23 |
|
24 |
import java.awt.geom.AffineTransform; |
25 |
import java.awt.geom.Point2D; |
26 |
import java.io.File; |
27 |
import java.util.List; |
28 |
|
29 |
import org.cresques.cts.ICoordTrans; |
30 |
import org.cresques.cts.IProjection; |
31 |
import org.gvsig.compat.net.ICancellable; |
32 |
import org.gvsig.fmap.dal.DataStore; |
33 |
import org.gvsig.fmap.dal.DataStoreParameters; |
34 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
35 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
36 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
37 |
import org.gvsig.fmap.dal.coverage.datastruct.GeoPointList; |
38 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
39 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
40 |
import org.gvsig.fmap.dal.coverage.exception.CloneException; |
41 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
42 |
import org.gvsig.fmap.dal.coverage.exception.InfoByPointException; |
43 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
44 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
45 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
46 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
47 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
48 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
49 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
50 |
import org.gvsig.fmap.dal.coverage.grid.render.Render; |
51 |
import org.gvsig.fmap.dal.coverage.process.vector.Vectorization; |
52 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
53 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
54 |
import org.gvsig.fmap.dal.coverage.store.props.Histogramable; |
55 |
import org.gvsig.fmap.dal.coverage.store.props.Metadata; |
56 |
import org.gvsig.fmap.dal.exception.CloseException; |
57 |
import org.gvsig.fmap.dal.exception.InitializeException; |
58 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
59 |
import org.gvsig.raster.roi.ROI; |
60 |
|
61 |
/**
|
62 |
* Interfaz que deben implementar los almacenes de datos raster.
|
63 |
*
|
64 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
65 |
*/
|
66 |
public interface RasterDataStore extends DataStore, TRasterStore, |
67 |
PyramidRasterStore, RasterStoreProperties, Histogramable { |
68 |
public static final int RED_BAND = 0x01; |
69 |
public static final int GREEN_BAND = 0x02; |
70 |
public static final int BLUE_BAND = 0x04; |
71 |
public static final int ALPHA_BAND = 0x08; |
72 |
|
73 |
/**
|
74 |
* Tipos de raster dependiendo de su fuente
|
75 |
*/
|
76 |
public static final int FILE = 0; |
77 |
public static final int POSTGIS = 1; |
78 |
public static final int REMOTE = 2; |
79 |
public static final int MOSAIC = 3; |
80 |
|
81 |
/**
|
82 |
* Gets a list of data parameters. If it doesn't have
|
83 |
* internal providers this method will return only one DataParameter
|
84 |
* @return
|
85 |
*/
|
86 |
public RasterDataParameters[] getDataParametersByProvider(); |
87 |
|
88 |
/**
|
89 |
* Gets a list of sizes. If the provider doesn't have files it will return null.
|
90 |
* If the provider has one file it will return an array of one element with the
|
91 |
* size of this file. If the provider contains others with one file each one.
|
92 |
* @return
|
93 |
*/
|
94 |
public long[] getFileSizeByProvider(); |
95 |
|
96 |
/**
|
97 |
* Gets a list of file names or URI. Each element of this array is the name of a
|
98 |
* provider
|
99 |
* @return
|
100 |
*/
|
101 |
public String[] getURIByProvider(); |
102 |
|
103 |
/**
|
104 |
* Gets the number of bands by provider.
|
105 |
* @return
|
106 |
*/
|
107 |
public int[] getBandCountByProvider(); |
108 |
|
109 |
/**
|
110 |
* Gets a list of Metadata
|
111 |
* @return
|
112 |
*/
|
113 |
public Metadata[] getMetadataByProvider(); |
114 |
|
115 |
/**
|
116 |
* Gets the number of overviews by provider
|
117 |
* @param number of band
|
118 |
* @return
|
119 |
*/
|
120 |
public int[] getOverviewCountByProvider(int band) throws BandAccessException; |
121 |
|
122 |
/**
|
123 |
* Gets the size of a overview in one band. The result is a list of strings (WidthXHeight)
|
124 |
*
|
125 |
* @param band
|
126 |
* @return
|
127 |
*/
|
128 |
public String[] getOverviewSizeByProvider(int band, int overview) throws BandAccessException; |
129 |
|
130 |
/**
|
131 |
* Gets a list of affine transforms
|
132 |
* @return
|
133 |
*/
|
134 |
public AffineTransform[] getAffineTransformByProvider(); |
135 |
|
136 |
/**
|
137 |
* Gets the height by provider
|
138 |
* @return
|
139 |
*/
|
140 |
public double[] getHeightByProvider(); |
141 |
|
142 |
/**
|
143 |
* Gets the width by provider
|
144 |
* @return
|
145 |
*/
|
146 |
public double[] getWidthByProvider(); |
147 |
|
148 |
/**
|
149 |
* Gets the URI of the source. If the provider has only one band
|
150 |
* the result will be the URI. If it is multifile will have to choose
|
151 |
* among several sources.
|
152 |
* @param band
|
153 |
* @return
|
154 |
*/
|
155 |
public String getURIByBand(int band); |
156 |
|
157 |
/**
|
158 |
* Returns the number of internal providers that it has
|
159 |
* @return
|
160 |
*/
|
161 |
public int getProviderCount(); |
162 |
|
163 |
/**
|
164 |
* Adds a new file. The behavior of this function depends on
|
165 |
* the kind of provider and its implementation.
|
166 |
* @param file
|
167 |
* @throws InvalidSourceException
|
168 |
*/
|
169 |
public void addFile(String file) throws InvalidSourceException; |
170 |
|
171 |
/**
|
172 |
* Removes a file. The behavior of this function depends on
|
173 |
* the kind of provider and its implementation.
|
174 |
* @param file
|
175 |
*/
|
176 |
public void removeFile(String file); |
177 |
|
178 |
/**
|
179 |
* Define el valor NoData asociado al raster.
|
180 |
* @return
|
181 |
*/
|
182 |
public void setNoDataValue(NoData value); |
183 |
|
184 |
/**
|
185 |
* Obtiene el extent asignado
|
186 |
* @return Extent
|
187 |
*/
|
188 |
public Extent getView();
|
189 |
|
190 |
/**
|
191 |
* Crea un un nuevo dataset que referencia al mismo fichero en disco
|
192 |
* @return IRasterDataSource
|
193 |
*/
|
194 |
public RasterDataStore newDataStore();
|
195 |
|
196 |
/**
|
197 |
* Obtiene el Tama?o de cada fichero de que consta el raster en bytes.
|
198 |
* @return long que representa el tama?o
|
199 |
*/
|
200 |
public long getFileSize(); |
201 |
|
202 |
/**
|
203 |
* Convierte un punto desde coordenadas pixel a coordenadas del mundo.
|
204 |
* @param pt Punto a transformar
|
205 |
* @return punto transformado en coordenadas del mundo
|
206 |
*/
|
207 |
public Point2D rasterToWorld(Point2D pt); |
208 |
|
209 |
/**
|
210 |
* Convierte un punto desde del mundo a coordenadas pixel.
|
211 |
* @param pt Punto a transformar
|
212 |
* @return punto transformado en coordenadas pixel
|
213 |
*/
|
214 |
public Point2D worldToRaster(Point2D pt); |
215 |
|
216 |
/**
|
217 |
* Metodo que obtiene si un punto cae dentro de los l?mites de la extensi?n de la fuente de
|
218 |
* datos raster o fuera de ellos.
|
219 |
* @param p Punto a calcular
|
220 |
* @return true si est? dentro de los l?mites y false si est? fuera
|
221 |
*/
|
222 |
public boolean isInside(Point2D p); |
223 |
|
224 |
/**
|
225 |
* Returns true if the data source is tiled
|
226 |
* @return
|
227 |
*/
|
228 |
public boolean isTiled(); |
229 |
|
230 |
/**
|
231 |
* Returns true if the provider has several files and all of them has the same extension
|
232 |
* @return
|
233 |
*/
|
234 |
public boolean isMultiFile(); |
235 |
|
236 |
/**
|
237 |
* Returns true if the source of data is a mosaic of images
|
238 |
* @return
|
239 |
*/
|
240 |
public boolean isMosaic(); |
241 |
|
242 |
/**
|
243 |
* Obtiene la matriz de transformaci?n del propio raster. Esta matriz es la
|
244 |
* encargada de convertir las coordenadas de la petici?n en coordenadas a las
|
245 |
* que se pide a la libreria. En gdal, por ejemplo, se piden las coordenadas a
|
246 |
* la libreria en coordenadas pixel por lo que esta matriz tendr? la
|
247 |
* georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias
|
248 |
* como ermapper la petici?n a la libreria se hace en coordenadas geograficas
|
249 |
* que son las mismas en las que pide el usuario de gvSIG por lo que esta
|
250 |
* matriz en este caso se inicializa con la identidad.
|
251 |
* @return
|
252 |
*/
|
253 |
public AffineTransform getOwnAffineTransform(); |
254 |
|
255 |
/**
|
256 |
* Obtiene la transformaci?n afin aplicada en las peticiones con coordenadas
|
257 |
* reales. Esta corresponde al producto matricial entre la transformaci?n de
|
258 |
* la propia georreferenciaci?n del raster (ownTransformation) y la
|
259 |
* transformaci?n que se le aplique de forma externa. Si esta ?ltima no existe
|
260 |
* ser? la matriz identidad.
|
261 |
* @return Matriz de la transformaci?n af?n.
|
262 |
*/
|
263 |
public AffineTransform getAffineTransform(); |
264 |
|
265 |
/**
|
266 |
* Asigna una transformaci?n al raster para que se tenga en cuenta en la
|
267 |
* asignaci?n del setView. Esta asignaci?n recalcula el extent, el
|
268 |
* requestExtent y asigna el AffineTransform que se usar? para la
|
269 |
* transformaci?n. Esta transformaci?n ser? considerada como si la imagen
|
270 |
* tuviera asociado un rmf.
|
271 |
* @param t Transformaci?n af?n a aplicar
|
272 |
*/
|
273 |
public void setAffineTransform(AffineTransform transf); |
274 |
|
275 |
/**
|
276 |
* Gets an object which vectorize a raster
|
277 |
* @return
|
278 |
* @throws RasterDriverException
|
279 |
* @throws ProcessInterruptedException
|
280 |
* When the object Vectorization is built the raster data buffer is loaded.
|
281 |
* This operation can be interrupted
|
282 |
*/
|
283 |
public Vectorization createVectorizeObject() throws RasterDriverException, ProcessInterruptedException; |
284 |
|
285 |
/**
|
286 |
* Builds an render object using this RasterDataStore
|
287 |
* @return Render
|
288 |
*/
|
289 |
public Render getRender();
|
290 |
|
291 |
/**
|
292 |
* Assigns a render object
|
293 |
* @param render
|
294 |
*/
|
295 |
public void setRender(Render render); |
296 |
|
297 |
/**
|
298 |
* Saves georeferencing information in the rmf file
|
299 |
* @throws RmfSerializerException
|
300 |
*/
|
301 |
public void saveGeoreferencingToRmf() throws RmfSerializerException; |
302 |
|
303 |
/**
|
304 |
* Saves a color table
|
305 |
* @param table
|
306 |
* @throws RmfSerializerException
|
307 |
*/
|
308 |
public void saveColorTableToRmf(ColorTable table) throws RmfSerializerException; |
309 |
|
310 |
/**
|
311 |
* Saves the geo point list to a RMF file
|
312 |
* @param pointList
|
313 |
* @throws RmfSerializerException
|
314 |
*/
|
315 |
public void saveGeoPointListToRmf(GeoPointList pointList) throws RmfSerializerException; |
316 |
|
317 |
/**
|
318 |
* Saves a list of files in the RMF file
|
319 |
* @param fileList
|
320 |
* @throws RmfSerializerException
|
321 |
*/
|
322 |
public void saveROIFileListToRmf(List<File> fileList) throws RmfSerializerException; |
323 |
|
324 |
/**
|
325 |
* Gets the list of ROI files in the RMF
|
326 |
* @return
|
327 |
* @throws RmfSerializerException
|
328 |
*/
|
329 |
public List<File> getROIFileListFromRmf(); |
330 |
|
331 |
/**
|
332 |
* Tipo de fichero soportado.
|
333 |
* Devuelve true si el tipo de fichero (extension) est? soportado, si no
|
334 |
* devuelve false.
|
335 |
*
|
336 |
* @param fName Fichero raster
|
337 |
* @return true si est? soportado, si no false.
|
338 |
*/
|
339 |
public boolean isFileSupported(String fName); |
340 |
|
341 |
/**
|
342 |
* Returns true if this DataStore is open and false if not
|
343 |
* @return
|
344 |
*/
|
345 |
public boolean isOpen(); |
346 |
|
347 |
/**
|
348 |
* Obtiene el flag que dice si el raster est? o no georreferenciado
|
349 |
* @return true si est? georreferenciado y false si no lo est?.
|
350 |
*/
|
351 |
public boolean isGeoreferenced(); |
352 |
|
353 |
/**
|
354 |
* Returns true if this data store is reproyectable or false if not
|
355 |
* @return
|
356 |
*/
|
357 |
public boolean isReproyectable(); |
358 |
|
359 |
/**
|
360 |
* Consulta de si un raster tiene rotaci?n o no.
|
361 |
* @return true si tiene rotaci?n y false si no la tiene.
|
362 |
*/
|
363 |
public boolean isRotated(); |
364 |
|
365 |
/**
|
366 |
* Obtiene el n?mero de overviews de una banda
|
367 |
* @return N?mero de overviews del raster.
|
368 |
*/
|
369 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException; |
370 |
|
371 |
/**
|
372 |
* Informa de si el dataset soporta overviews o no.
|
373 |
* @return true si soporta overviews y false si no las soporta.
|
374 |
*/
|
375 |
public boolean overviewsSupport(); |
376 |
|
377 |
/**
|
378 |
* Obtiene el ancho de una overview de una banda
|
379 |
* @return
|
380 |
*/
|
381 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException; |
382 |
|
383 |
/**
|
384 |
* Obtiene el alto de una overview de una banda
|
385 |
* @return
|
386 |
*/
|
387 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException; |
388 |
|
389 |
/**
|
390 |
* Returns the band list
|
391 |
* @return
|
392 |
*/
|
393 |
public BandList getBands();
|
394 |
|
395 |
/**
|
396 |
* Clones this object
|
397 |
* @return RasterDataStore
|
398 |
* @throws CloneException
|
399 |
*/
|
400 |
public RasterDataStore cloneDataStore() throws CloneException; |
401 |
|
402 |
/**
|
403 |
* Gets a provider
|
404 |
* @return
|
405 |
*/
|
406 |
public CoverageStoreProvider getProvider();
|
407 |
|
408 |
/**
|
409 |
* Sets a provider
|
410 |
* @return
|
411 |
*/
|
412 |
public void setProvider(CoverageStoreProvider prov); |
413 |
|
414 |
/**
|
415 |
* Deletes the cache of this layer composed by the files in the provider list
|
416 |
*/
|
417 |
public void deleteLayerFromCache(); |
418 |
|
419 |
/**
|
420 |
* Sets the parameters
|
421 |
* @param p
|
422 |
*/
|
423 |
public void setParameters(DataStoreParameters p); |
424 |
|
425 |
/**
|
426 |
* Returns the source type (FILE, POSTGIS, REMOTE,...)
|
427 |
* @return
|
428 |
*/
|
429 |
public int getSourceType(); |
430 |
|
431 |
/**
|
432 |
* This method will return the DataParameters if it has a simple provider behind. If it has
|
433 |
* a TileProvider this method will return the DataParameters used by the TileProvider.
|
434 |
* @return
|
435 |
*/
|
436 |
public RasterDataParameters getInternalParameters();
|
437 |
|
438 |
/**
|
439 |
* Closes this data store
|
440 |
* @throws CloseException
|
441 |
*/
|
442 |
public void close() throws CloseException; |
443 |
|
444 |
|
445 |
//******************************************
|
446 |
//***********Query methods******************
|
447 |
|
448 |
/**
|
449 |
* Returns the last buffer loaded if the flag storeLastBuffer in the query is true
|
450 |
* @return
|
451 |
*/
|
452 |
public Buffer getLastBuffer(); |
453 |
|
454 |
/**
|
455 |
* Gets the step
|
456 |
* @return
|
457 |
*/
|
458 |
public double[] getStep(); |
459 |
|
460 |
/**
|
461 |
* Gets a pixel
|
462 |
* @param x
|
463 |
* @param y
|
464 |
* @param band
|
465 |
* @return
|
466 |
* @throws InvalidSetViewException
|
467 |
* @throws FileNotOpenException
|
468 |
* @throws RasterDriverException
|
469 |
*/
|
470 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException; |
471 |
|
472 |
/**
|
473 |
* Makes a request to load a buffer of data. This call returns an array of results. The first
|
474 |
* element in the array is the buffer and the other elements are the transparency buffer,
|
475 |
* the legend and so on. This funtion is mainly used by the getTile call. This array contains
|
476 |
* all visualization properties.
|
477 |
* @param query
|
478 |
* @return Object[]
|
479 |
*/
|
480 |
public Object[] queryArray(RasterQuery query) throws ProcessInterruptedException, RasterDriverException, InvalidSetViewException; |
481 |
|
482 |
/**
|
483 |
* Makes a request to load a buffer of data. This call returns only a buffer. This call is used
|
484 |
* by most functions because the properties are read from the datastore.
|
485 |
* @param query
|
486 |
* @return Buffer
|
487 |
*/
|
488 |
public Buffer query(RasterQuery query) throws ProcessInterruptedException, RasterDriverException, InvalidSetViewException; |
489 |
|
490 |
/**
|
491 |
* Sets a tile server to create a second level of cache. This second level will be
|
492 |
* created if the cache structure is different to the current.
|
493 |
* @param tileServer
|
494 |
*/
|
495 |
public void setTileServer(Class<?> tileServer) throws InitializeException; |
496 |
|
497 |
/**
|
498 |
* Some sevices has neither limits nor pixel size. For instance, WebMapService
|
499 |
* is a service of this type if the size is not fixed. Other services, like
|
500 |
* WMTS are enclosed too but in this case it will have resolution by level.
|
501 |
* This method returns true if the data source is enclosed.
|
502 |
* @return
|
503 |
*/
|
504 |
public boolean isRasterEnclosed(); |
505 |
|
506 |
/**
|
507 |
* This function returns true if the image to be loaded needs a enhanced filter or
|
508 |
* doesn't. It depends on the format, number of bands, type of data and so on.
|
509 |
* @return The default value is false but each driver can change this value.
|
510 |
*/
|
511 |
public boolean needEnhanced(); |
512 |
|
513 |
/**
|
514 |
* Sets the transformation
|
515 |
* @param t
|
516 |
*/
|
517 |
public void setCoordTrans(ICoordTrans t); |
518 |
|
519 |
/**
|
520 |
* Gets the information in a real point
|
521 |
* @param x
|
522 |
* X Pixel position
|
523 |
* @param y
|
524 |
* Y pixel position
|
525 |
* @return
|
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(double x, double y, Extent extent, int w, int h, ICancellable cancellable) throws InfoByPointException; |
547 |
|
548 |
/**
|
549 |
* Gets the list of geo points associated to this provider
|
550 |
* @return
|
551 |
*/
|
552 |
public GeoPointList getGeoPointList();
|
553 |
|
554 |
/**
|
555 |
* Sets the list of geo points associated to this provider
|
556 |
*/
|
557 |
public void setGeoPointList(GeoPointList geoPointList); |
558 |
|
559 |
/**
|
560 |
* Gets the list of regions of interest
|
561 |
* @param defaultProjection
|
562 |
* @return
|
563 |
* @throws ROIException
|
564 |
*/
|
565 |
public List<ROI> getRois(IProjection defaultProjection) throws ROIException; |
566 |
|
567 |
/**
|
568 |
* Gets the list of regions of interest
|
569 |
* @param defaultProjection
|
570 |
* @return
|
571 |
* @throws ROIException
|
572 |
*/
|
573 |
public List<ROI> getRois(String epsg) throws ROIException; |
574 |
|
575 |
/**
|
576 |
* Sets the list of regions of interest
|
577 |
* @param rois
|
578 |
*/
|
579 |
public void setRois(List<ROI> rois); |
580 |
|
581 |
} |