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