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 @ 162
History | View | Annotate | Download (13.2 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.geom.AffineTransform; |
25 |
import java.awt.geom.Point2D; |
26 |
|
27 |
import org.cresques.cts.IProjection; |
28 |
import org.gvsig.fmap.dal.DataParameters; |
29 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
30 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
31 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
32 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
33 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
34 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
35 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
36 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
37 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
38 |
import org.gvsig.fmap.dal.coverage.store.props.Histogram; |
39 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
40 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
41 |
import org.gvsig.raster.impl.store.properties.DataStoreMetadata; |
42 |
import org.gvsig.raster.impl.store.properties.DataStoreStatistics; |
43 |
|
44 |
/**
|
45 |
* Interfaz que deben implementar cualquier fuente de datos raster. Estas pueden estar
|
46 |
* compuestas por N datasets. B?sicamente hay dos fuentes que deben implementar este interfaz,
|
47 |
* MultiRasterDataset y CompositeDataset. La primera es un dataset compuesto por varios ficheros
|
48 |
* con el mismo Extent de N bandas cada uno. MultiRasterDataset proporciona una encapsulaci?n al acceso
|
49 |
* a datos de todos ellos. CompositeDataset es un dataset compuesto de N MultiRasterDatasets cuya extensi?n
|
50 |
* es continua formando un Grid de datasets con continuidad espacial. IRasterDataSource proporciona
|
51 |
* una visi?n de acceso a datos com?n para ambos.
|
52 |
*
|
53 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
54 |
*
|
55 |
*/
|
56 |
public interface RasterProvider extends CoverageStoreProvider { |
57 |
|
58 |
/**
|
59 |
* Obtiene el n?mero de bandas del raster
|
60 |
* @return N?mero de bandas
|
61 |
*/
|
62 |
public int getBandCount(); |
63 |
|
64 |
/**
|
65 |
* Obtiene el tipo de dato por banda
|
66 |
* @return tipo de dato por banda
|
67 |
*/
|
68 |
public int[] getDataType(); |
69 |
|
70 |
/**
|
71 |
* Obtiene la altura del raster en p?xeles.
|
72 |
* @return altura
|
73 |
*/
|
74 |
public double getHeight(); |
75 |
|
76 |
/**
|
77 |
* Obtiene la anchura del raster en p?xeles.
|
78 |
* @return anchura
|
79 |
*/
|
80 |
public double getWidth(); |
81 |
|
82 |
/**
|
83 |
* Obtiene si esta activo el valor NoData asociado al raster.
|
84 |
* @return
|
85 |
*/
|
86 |
public boolean isNoDataEnabled(); |
87 |
|
88 |
/**
|
89 |
* Devuelve si el Dataset es reproyectable
|
90 |
* @return
|
91 |
*/
|
92 |
public boolean isReproyectable(); |
93 |
|
94 |
/**
|
95 |
* Returns true if this raster has rotation and false if don't
|
96 |
*/
|
97 |
public boolean isRotated(); |
98 |
|
99 |
/**
|
100 |
* Returns true if this provider is open and false if don't
|
101 |
* @return
|
102 |
*/
|
103 |
public boolean isOpen(); |
104 |
|
105 |
/**
|
106 |
* Informa de si el dataset soporta overviews o no.
|
107 |
* @return true si soporta overviews y false si no las soporta.
|
108 |
*/
|
109 |
public boolean overviewsSupport(); |
110 |
|
111 |
/**
|
112 |
* Obtiene el n?mero de overviews de una banda
|
113 |
* @return
|
114 |
*/
|
115 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException; |
116 |
|
117 |
/**
|
118 |
* Obtiene el ancho de una overview de una banda
|
119 |
* @return
|
120 |
*/
|
121 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException; |
122 |
|
123 |
/**
|
124 |
* Obtiene el alto de una overview de una banda
|
125 |
* @return
|
126 |
*/
|
127 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException; |
128 |
|
129 |
|
130 |
/**
|
131 |
* Informa de si el punto en coordenadas del mundo real pasado por par?metro cae dentro del
|
132 |
* raster o fuera. Para este calculo cogeremos el punto a averiguar si est? dentro del raster
|
133 |
* y le aplicaremos la transformaci?n inversa de la transformaci?n af?n aplicada. Una vez hecho
|
134 |
* esto ya se puede comprobar si est? dentro de los l?mites del extent del raster.
|
135 |
* @param p Punto a comprobar en coordenadas reales
|
136 |
* @return true si el punto est? dentro y false si est? fuera.
|
137 |
*/
|
138 |
public boolean isInside(Point2D p); |
139 |
|
140 |
/**
|
141 |
* Obtiene el valor NoData asociado al raster.
|
142 |
* @return
|
143 |
*/
|
144 |
public double getNoDataValue(); |
145 |
|
146 |
/**
|
147 |
* Obtiene el objeto con las estadisticas
|
148 |
* @return MultiFileStatistics
|
149 |
*/
|
150 |
public DataStoreStatistics getStatistics();
|
151 |
|
152 |
/**
|
153 |
* Obtiene el extent del raster.
|
154 |
* @return Extent
|
155 |
*/
|
156 |
public Extent getExtent();
|
157 |
|
158 |
/**
|
159 |
* Obtiene el nombre del fichero
|
160 |
* @return String
|
161 |
* nombre del fichero
|
162 |
*/
|
163 |
public String getFName(); |
164 |
|
165 |
/**
|
166 |
* Este es el extent sobre el que se ajusta una petici?n para que esta no
|
167 |
* exceda el extent m?ximo del raster. Para un raster sin rotar ser? igual al
|
168 |
* extent pero para un raster rotado ser? igual al extent del raster como si
|
169 |
* no tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace
|
170 |
* sobre la vista y las peticiones han de hacerse en coordenadas de la imagen
|
171 |
* sin shearing aplicado.
|
172 |
* @return Extent
|
173 |
*/
|
174 |
public Extent getExtentWithoutRot();
|
175 |
|
176 |
/**
|
177 |
* Obtiene la matriz de transformaci?n del propio raster. Esta matriz es la
|
178 |
* encargada de convertir las coordenadas de la petici?n en coordenadas a las
|
179 |
* que se pide a la libreria. En gdal, por ejemplo, se piden las coordenadas a
|
180 |
* la libreria en coordenadas pixel por lo que esta matriz tendr? la
|
181 |
* georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias
|
182 |
* como ermapper la petici?n a la libreria se hace en coordenadas geograficas
|
183 |
* que son las mismas en las que pide el usuario de gvSIG por lo que esta
|
184 |
* matriz en este caso se inicializa con la identidad.
|
185 |
* @return
|
186 |
*/
|
187 |
public AffineTransform getOwnAffineTransform(); |
188 |
|
189 |
/**
|
190 |
* Obtiene la transformaci?n afin aplicada en las peticiones con coordenadas
|
191 |
* reales. Esta corresponde al producto matricial entre la transformaci?n de
|
192 |
* la propia georreferenciaci?n del raster (ownTransformation) y la
|
193 |
* transformaci?n que se le aplique de forma externa. Si esta ?ltima no existe
|
194 |
* ser? la matriz identidad.
|
195 |
* @return Matriz de la transformaci?n af?n.
|
196 |
*/
|
197 |
public AffineTransform getAffineTransform(); |
198 |
|
199 |
/**
|
200 |
* Obtiene la proyecci?n del dataset
|
201 |
* @return IProjection
|
202 |
*/
|
203 |
public IProjection getProjection();
|
204 |
|
205 |
/**
|
206 |
* Obtiene el extent asignado
|
207 |
* @return Extent
|
208 |
*/
|
209 |
public Extent getView();
|
210 |
|
211 |
/**
|
212 |
* Gets a DatasetMetadata object
|
213 |
* @return
|
214 |
*/
|
215 |
public DataStoreMetadata getMetadata();
|
216 |
|
217 |
/**
|
218 |
* Obtiene el objeto que contiene que contiene la interpretaci?n de
|
219 |
* color por banda para el dataset seleccionado
|
220 |
* @param dataset Dataset del que se necesesita la informaci?n de color dentro del RasterMultiDataset
|
221 |
* @return DatasetColorInterpretation
|
222 |
*/
|
223 |
public ColorInterpretation getColorInterpretation();
|
224 |
|
225 |
/**
|
226 |
* Obtiene la paleta correspondiente al dataset.
|
227 |
* @return Paleta asociada a este o null si no tiene
|
228 |
*/
|
229 |
public ColorTable getColorTable();
|
230 |
|
231 |
/**
|
232 |
* Obtiene el estado de transparencia a partir de los estados de transparencia de todos
|
233 |
* los ficheros que lo componen. Si varios de los ficheros que lo componen tienen banda de
|
234 |
* transparencia estas tendr?n que ser mezcladas sobre una banda de transparencia ?nica.
|
235 |
* @return Objeto FileTransparency con el estado de transparencia
|
236 |
*/
|
237 |
public Transparency getTransparency(); |
238 |
|
239 |
/**
|
240 |
* Obtiene el histograma asociado al dataset. Este puede ser obtenido
|
241 |
* completo o seg?n una lista de clases pasada.
|
242 |
*
|
243 |
* @return Histograma asociado al dataset.
|
244 |
*/
|
245 |
public Histogram getHistogram();
|
246 |
|
247 |
/**
|
248 |
* Cierra los raster asociados.
|
249 |
*/
|
250 |
public void close(); |
251 |
|
252 |
/**
|
253 |
* Convierte un punto desde coordenadas pixel a coordenadas del mundo.
|
254 |
* @param pt Punto a transformar
|
255 |
* @return punto transformado en coordenadas del mundo
|
256 |
*/
|
257 |
public Point2D rasterToWorld(Point2D pt); |
258 |
|
259 |
/**
|
260 |
* Convierte un punto desde del mundo a coordenadas pixel.
|
261 |
* @param pt Punto a transformar
|
262 |
* @return punto transformado en coordenadas pixel
|
263 |
*/
|
264 |
public Point2D worldToRaster(Point2D pt); |
265 |
|
266 |
/**
|
267 |
* Asigna una transformaci?n al raster para que se tenga en cuenta en la
|
268 |
* asignaci?n del setView. Esta asignaci?n recalcula el extent, el
|
269 |
* requestExtent y asigna el AffineTransform que se usar? para la
|
270 |
* transformaci?n. Esta transformaci?n ser? considerada como si la imagen
|
271 |
* tuviera asociado un rmf.
|
272 |
* @param t Transformaci?n af?n a aplicar
|
273 |
*/
|
274 |
public void setAffineTransform(AffineTransform t); |
275 |
|
276 |
/**
|
277 |
* Define si se activa el valor NoData asociado al raster.
|
278 |
* @return
|
279 |
*/
|
280 |
public void setNoDataEnabled(boolean enabled); |
281 |
|
282 |
/**
|
283 |
* Obtiene el tama?o de pixel en X
|
284 |
* @return tama?o de pixel en X
|
285 |
*/
|
286 |
public double getPixelSizeX(); |
287 |
|
288 |
/**
|
289 |
* Obtiene el tama?o de pixel en Y
|
290 |
* @return tama?o de pixel en Y
|
291 |
*/
|
292 |
public double getPixelSizeY(); |
293 |
|
294 |
/**
|
295 |
* Obtiene el valor del raster en la coordenada que se le pasa.
|
296 |
* El valor ser? Double, Int, Byte, etc. dependiendo del tipo de
|
297 |
* raster.
|
298 |
* @param x coordenada X
|
299 |
* @param y coordenada Y
|
300 |
* @return
|
301 |
*/
|
302 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException; |
303 |
|
304 |
/**
|
305 |
* Obtiene la proyecci?n asociada al raster. Como todos los dataset del
|
306 |
* multiDataset deben tener la misma proyecci?n obtenemos esta del primer
|
307 |
* dataset.
|
308 |
* @return Proyecci?n en formato cadena
|
309 |
* @throws RasterDriverException
|
310 |
*/
|
311 |
public String getWktProjection() throws RasterDriverException; |
312 |
|
313 |
/**
|
314 |
* Dado unas coordenadas reales, un tama?o de buffer y un tama?o de raster.
|
315 |
* Si el buffer es de mayor tama?o que el raster (supersampleo) quiere decir que
|
316 |
* por cada pixel de buffer se repiten varios del raster. Esta funci?n calcula el
|
317 |
* n?mero de pixels de desplazamiento en X e Y que corresponden al primer pixel del
|
318 |
* buffer en la esquina superior izquierda. Esto es necesario porque la coordenada
|
319 |
* solicitada es real y puede no caer sobre un pixel completo. Este calculo es
|
320 |
* util cuando un cliente quiere supersamplear sobre un buffer y que no se lo haga
|
321 |
* el driver autom?ticamente.
|
322 |
* @param dWorldTLX Coordenada real X superior izquierda
|
323 |
* @param dWorldTLY Coordenada real Y superior izquierda
|
324 |
* @param nWidth Ancho del raster
|
325 |
* @param nHeight Alto del raster
|
326 |
* @param bufWidth Ancho del buffer
|
327 |
* @param bufHeight Alto del buffer
|
328 |
* @return Array de cuatro. Los dos primeros elementos son el desplazamiento en X e Y y los dos segundos
|
329 |
* el tama?o en pixels de buffer de un pixel de la imagen en ancho y alto.
|
330 |
*/
|
331 |
public double[] calcSteps(double dWorldTLX, double dWorldTLY, double dWorldBRX, double dWorldBRY, |
332 |
double nWidth, double nHeight, int bufWidth, int bufHeight); |
333 |
|
334 |
/**
|
335 |
* Define el valor NoData asociado al raster.
|
336 |
* @return
|
337 |
*/
|
338 |
public void setNoDataValue(double value); |
339 |
|
340 |
/**
|
341 |
* Vuelve a poner el valor noData como estaba inicialmente
|
342 |
*/
|
343 |
public void resetNoDataValue(); |
344 |
|
345 |
/**
|
346 |
* Obtiene el flag que dice si el raster est? o no georreferenciado
|
347 |
* @return true si est? georreferenciado y false si no lo est?.
|
348 |
*/
|
349 |
public boolean isGeoreferenced(); |
350 |
|
351 |
/**
|
352 |
* Clone this RasterProvider
|
353 |
* @return
|
354 |
*/
|
355 |
public RasterProvider cloneProvider();
|
356 |
|
357 |
/**
|
358 |
* Returs the DataParameters
|
359 |
* @return
|
360 |
*/
|
361 |
public DataParameters getDataParameters();
|
362 |
|
363 |
/**
|
364 |
* Lee un bloque completo de datos del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util
|
365 |
* para una lectura rapida de todo el fichero sin necesidad de asignar vista.
|
366 |
* @param pos Posici?n donde se empieza a leer
|
367 |
* @param blockHeight Altura m?xima del bloque leido
|
368 |
* @return Object que es un array tridimendional del tipo de datos del raster. (Bandas X Filas X Columnas)
|
369 |
* @throws InvalidSetViewException
|
370 |
* @throws FileNotOpenException
|
371 |
* @throws RasterDriverException
|
372 |
*/
|
373 |
public Object readBlock(int pos, int blockHeight) |
374 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException;
|
375 |
|
376 |
|
377 |
/**
|
378 |
* Carga un objecto desde un serializador usando el tipo del mismo objeto pasado por parametro.
|
379 |
* Usa value para iniciar dicho serializador
|
380 |
* @param class1
|
381 |
* @param value
|
382 |
* @return
|
383 |
* @throws RmfSerializerException
|
384 |
*/
|
385 |
@SuppressWarnings("unchecked") |
386 |
public Object loadObjectFromRmf(Class class1, Object value) throws RmfSerializerException; |
387 |
|
388 |
/**
|
389 |
* Guarda en el RMF el objecto actual en caso de que exista un serializador para el.
|
390 |
* El tipo del objeto se especifica en el parametro class1.
|
391 |
* Esto nos puede permitir poder poner a null un valor y encontrar su serializador.
|
392 |
* @param class1
|
393 |
* @param value
|
394 |
* @throws RmfSerializerException
|
395 |
*/
|
396 |
@SuppressWarnings("unchecked") |
397 |
public void saveObjectToRmf(Class class1, Object value) throws RmfSerializerException; |
398 |
|
399 |
|
400 |
} |