svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libRaster_io / src / org / gvsig / fmap / dal / coverage / dataset / io / GdalDriver.java @ 30008
History | View | Annotate | Download (19.3 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.fmap.dal.coverage.dataset.io; |
20 |
|
21 |
import java.awt.geom.AffineTransform; |
22 |
import java.awt.geom.Point2D; |
23 |
import java.awt.geom.Rectangle2D; |
24 |
import java.io.BufferedReader; |
25 |
import java.io.File; |
26 |
import java.io.FileNotFoundException; |
27 |
import java.io.FileReader; |
28 |
import java.io.IOException; |
29 |
|
30 |
import org.cresques.cts.ICoordTrans; |
31 |
import org.cresques.cts.IProjection; |
32 |
import org.gvsig.raster.dataset.BandAccessException; |
33 |
import org.gvsig.raster.dataset.BandList; |
34 |
import org.gvsig.raster.dataset.FileNotOpenException; |
35 |
import org.gvsig.raster.dataset.GeoInfo; |
36 |
import org.gvsig.raster.dataset.IBuffer; |
37 |
import org.gvsig.raster.dataset.InvalidSetViewException; |
38 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
39 |
import org.gvsig.raster.dataset.RasterDataset; |
40 |
import org.gvsig.raster.dataset.RasterDriverException; |
41 |
import org.gvsig.raster.dataset.properties.DatasetColorInterpretation; |
42 |
import org.gvsig.raster.dataset.properties.DatasetMetadata; |
43 |
import org.gvsig.raster.dataset.rmf.ParsingException; |
44 |
import org.gvsig.raster.datastruct.Extent; |
45 |
import org.gvsig.raster.datastruct.Transparency; |
46 |
import org.gvsig.raster.util.RasterUtilities; |
47 |
import org.gvsig.tools.ToolsLocator; |
48 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
49 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
50 |
|
51 |
import es.gva.cit.jgdal.GdalException; |
52 |
/**
|
53 |
* Clase que representa al driver de acceso a datos de gdal.
|
54 |
*
|
55 |
* @author Luis W. Sevilla
|
56 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
57 |
*/
|
58 |
public class GdalDriver extends RasterDataset { |
59 |
public static final String FORMAT_GTiff = "GTiff"; |
60 |
public static final String FORMAT_VRT = "VRT"; |
61 |
public static final String FORMAT_NITF = "NITF"; |
62 |
public static final String FORMAT_HFA = "HFA"; |
63 |
public static final String FORMAT_ELAS = "ELAS"; |
64 |
public static final String FORMAT_MEM = "MEM"; |
65 |
public static final String FORMAT_BMP = "BMP"; |
66 |
public static final String FORMAT_PCIDSK = "PCIDSK"; |
67 |
public static final String FORMAT_ILWIS = "ILWIS"; |
68 |
public static final String FORMAT_HDF4 = "HDF4Image"; |
69 |
public static final String FORMAT_PNM = "PNM"; |
70 |
public static final String FORMAT_ENVI = "ENVI"; |
71 |
public static final String FORMAT_EHDR = "EHdr"; |
72 |
public static final String FORMAT_PAUX = "PAux"; |
73 |
public static final String FORMAT_MFF = "MFF"; |
74 |
public static final String FORMAT_MFF2 = "MFF2"; |
75 |
public static final String FORMAT_BT = "BT"; |
76 |
public static final String FORMAT_IDA = "IDA"; |
77 |
public static final String FORMAT_RMF = "RMF"; |
78 |
public static final String FORMAT_RST = "RST"; |
79 |
public static final String FORMAT_LEVELLER = "Leveller"; |
80 |
public static final String FORMAT_TERRAGEN = "Terragen"; |
81 |
public static final String FORMAT_ERS = "ERS"; |
82 |
public static final String FORMAT_INGR = "INGR"; |
83 |
public static final String FORMAT_GSAG = "GSAG"; |
84 |
public static final String FORMAT_GSBG = "GSBG"; |
85 |
public static final String FORMAT_ADRG = "ADRG"; |
86 |
public static final int BAND_HEIGHT = 64; |
87 |
protected GdalNative file = null; |
88 |
|
89 |
|
90 |
public GdalDriver(){super(null, null);} |
91 |
|
92 |
private Extent viewRequest = null; |
93 |
|
94 |
public static void register() { |
95 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
96 |
ExtensionPoint point = extensionPoints.get("RasterReader");
|
97 |
|
98 |
point.append("bmp", "", GdalDriver.class); |
99 |
point.append("gif", "", GdalDriver.class); |
100 |
point.append("tif", "", GdalDriver.class); |
101 |
point.append("tiff", "", GdalDriver.class); |
102 |
point.append("jpg", "", GdalDriver.class); |
103 |
point.append("jpeg", "", GdalDriver.class); |
104 |
point.append("png", "", GdalDriver.class); |
105 |
point.append("vrt", "", GdalDriver.class); |
106 |
point.append("dat", "", GdalDriver.class); // Envi |
107 |
point.append("lan", "", GdalDriver.class); // Erdas |
108 |
point.append("gis", "", GdalDriver.class); // Erdas |
109 |
point.append("img", "", GdalDriver.class); // Erdas |
110 |
point.append("pix", "", GdalDriver.class); // PCI Geomatics |
111 |
point.append("aux", "", GdalDriver.class); // PCI Geomatics |
112 |
point.append("adf", "", GdalDriver.class); // ESRI Grids |
113 |
point.append("mpr", "", GdalDriver.class); // Ilwis |
114 |
point.append("mpl", "", GdalDriver.class); // Ilwis |
115 |
point.append("map", "", GdalDriver.class); // PC Raster |
116 |
point.append("asc", "", GdalDriver.class); |
117 |
point.append("pgm", "", GdalDriver.class); //Ficheros PNM en escala de grises |
118 |
point.append("ppm", "", GdalDriver.class); //Ficheros PNM en RGB |
119 |
point.append("rst", "", GdalDriver.class); //IDRISIS |
120 |
point.append("rmf", "", GdalDriver.class); //Raster Matrix Format |
121 |
point.append("nos", "", GdalDriver.class); |
122 |
point.append("kap", "", GdalDriver.class); |
123 |
point.append("hdr", "", GdalDriver.class); |
124 |
point.append("raw", "", GdalDriver.class); |
125 |
point.append("ers", "", GdalDriver.class); |
126 |
|
127 |
point = extensionPoints.get("DefaultDriver");
|
128 |
point.append("reader", "", GdalDriver.class); |
129 |
} |
130 |
|
131 |
/**
|
132 |
* Constructor del driver de Gdal. Crea las referencias al fichero y carga
|
133 |
* las estructuras con la informaci?n y los metadatos.
|
134 |
* @param proj Proyecci?n
|
135 |
* @param param Parametros de carga
|
136 |
* @throws NotSupportedExtensionException
|
137 |
*/
|
138 |
public GdalDriver(IProjection proj, Object param)throws NotSupportedExtensionException { |
139 |
super(proj, param);
|
140 |
try {
|
141 |
if(param instanceof String) { |
142 |
setParam(translateFileName((String)param));
|
143 |
validRmf(((String)param));
|
144 |
file = new GdalNative(translateFileName((String)param)); |
145 |
setColorTable(file.palette); |
146 |
noData = file.getNoDataValue(); |
147 |
wktProjection = file.getProjectionRef(); |
148 |
noDataEnabled = file.existsNoDataValue(); |
149 |
ownTransformation = file.getOwnTransformation(); |
150 |
externalTransformation = (AffineTransform)ownTransformation.clone();
|
151 |
load(); |
152 |
} else
|
153 |
setParam(param); |
154 |
//TODO: FUNCIONALIDAD: Formatos gestionados por gdal que no tienen extensi?n. Estos tendr?n un objeto IRegistrableRasterFormat Por ej: Grass
|
155 |
bandCount = file.getRasterCount(); |
156 |
} catch (GdalException e) {
|
157 |
e.printStackTrace(); |
158 |
throw new NotSupportedExtensionException("Extension not supported"); |
159 |
} catch(Exception e) { |
160 |
System.out.println("Error en GdalOpen"); |
161 |
e.printStackTrace(); |
162 |
file = null;
|
163 |
} |
164 |
|
165 |
//Obtenemos el tipo de dato de gdal y lo convertimos el de RasterBuf
|
166 |
int[] dt = new int[file.getDataType().length]; |
167 |
for (int i = 0; i < dt.length; i++) |
168 |
dt[i] = RasterUtilities.getRasterBufTypeFromGdalType(file.getDataType()[i]); |
169 |
setDataType(dt); |
170 |
|
171 |
super.init();
|
172 |
|
173 |
try {
|
174 |
loadFromRmf(getRmfBlocksManager()); |
175 |
} catch (ParsingException e) {
|
176 |
//No lee desde rmf
|
177 |
} |
178 |
} |
179 |
|
180 |
/**
|
181 |
* Comprueba si el fichero abierto es un RasterMetaFile o una imagen
|
182 |
* raster.
|
183 |
* @throws GdalException
|
184 |
*/
|
185 |
private void validRmf(String file) throws GdalException { |
186 |
if(file.endsWith(".rmf")) { |
187 |
File f = new File(file); |
188 |
FileReader fr;
|
189 |
try {
|
190 |
fr = new FileReader(f); |
191 |
BufferedReader br = new BufferedReader(fr); |
192 |
char[] buffer = new char[5]; |
193 |
br.read(buffer); |
194 |
StringBuffer st = new StringBuffer(new String(buffer)); |
195 |
if(st.toString().equals("<?xml")) |
196 |
throw new GdalException("RasterMetaFile"); |
197 |
} catch (FileNotFoundException e) { |
198 |
throw new GdalException("File Not Found"); |
199 |
} catch (IOException e) { |
200 |
throw new GdalException(""); |
201 |
} |
202 |
} |
203 |
} |
204 |
/**
|
205 |
* Obtenemos o calculamos el extent de la imagen.
|
206 |
*/
|
207 |
public GeoInfo load() {
|
208 |
return this; |
209 |
} |
210 |
|
211 |
/**
|
212 |
* Cierra el fichero de imagen
|
213 |
*/
|
214 |
public void close() { |
215 |
try {
|
216 |
if(file != null){ |
217 |
file.close(); |
218 |
file = null;
|
219 |
} |
220 |
viewRequest = null;
|
221 |
} catch (GdalException e) {
|
222 |
e.printStackTrace(); |
223 |
} |
224 |
} |
225 |
|
226 |
/*
|
227 |
* (non-Javadoc)
|
228 |
* @see org.gvsig.raster.dataset.RasterDataset#translateFileName(java.lang.String)
|
229 |
*/
|
230 |
public String translateFileName(String fileName) { |
231 |
if(fileName.endsWith("hdr")) |
232 |
return fileName.substring(0, fileName.lastIndexOf(".")); |
233 |
return fileName;
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci?n
|
238 |
* de la vista asignada ya que la petici?n viene en coordenadas del fichero .rmf y la vista (v)
|
239 |
* ha de estar en coordenadas del fichero.
|
240 |
*/
|
241 |
public void setView(Extent e) { |
242 |
viewRequest = e; |
243 |
} |
244 |
|
245 |
/**
|
246 |
* Obtiene extent de la vista actual
|
247 |
*/
|
248 |
public Extent getView() {
|
249 |
return viewRequest;
|
250 |
} |
251 |
|
252 |
/**
|
253 |
* Obtiene la anchura del fichero
|
254 |
*/
|
255 |
public int getWidth() { |
256 |
return file.width;
|
257 |
} |
258 |
|
259 |
/**
|
260 |
* Obtiene la altura del fichero
|
261 |
*/
|
262 |
public int getHeight() { |
263 |
return file.height;
|
264 |
} |
265 |
|
266 |
/*
|
267 |
* (non-Javadoc)
|
268 |
* @see org.gvsig.fmap.driver.GeoRasterFile#readCompletetLine(int, int)
|
269 |
*/
|
270 |
public Object readCompleteLine(int line, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
271 |
if(line > this.getHeight() || band > this.getBandCount()) |
272 |
throw new InvalidSetViewException("Request out of grid"); |
273 |
|
274 |
try{
|
275 |
return file.readCompleteLine(line, band);
|
276 |
}catch(GdalException e){
|
277 |
throw new RasterDriverException("Error reading data from Gdal library"); |
278 |
} |
279 |
} |
280 |
|
281 |
/*
|
282 |
* (non-Javadoc)
|
283 |
* @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int)
|
284 |
*/
|
285 |
public Object readBlock(int pos, int blockHeight) |
286 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException, InterruptedException { |
287 |
if(pos < 0) |
288 |
throw new InvalidSetViewException("Request out of grid"); |
289 |
|
290 |
if((pos + blockHeight) > getHeight())
|
291 |
blockHeight = Math.abs(getHeight() - pos);
|
292 |
try{
|
293 |
return file.readBlock(pos, blockHeight);
|
294 |
}catch(GdalException e){
|
295 |
throw new RasterDriverException("Error reading data from Gdal library"); |
296 |
} |
297 |
} |
298 |
|
299 |
/* (non-Javadoc)
|
300 |
* @see org.cresques.io.GeoRasterFile#getData(int, int, int)
|
301 |
*/
|
302 |
public Object getData(int x, int y, int band)throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
303 |
if(file != null){ |
304 |
if(x < 0 || y < 0 || x >= file.width || y >= file.height) |
305 |
throw new InvalidSetViewException("Request out of grid"); |
306 |
Object[] data = file.getData(x, y); |
307 |
return data[band];
|
308 |
} |
309 |
throw new FileNotOpenException("GdalNative not exist"); |
310 |
} |
311 |
|
312 |
/*
|
313 |
* (non-Javadoc)
|
314 |
* @see org.gvsig.raster.dataset.RasterDataset#getWindowRaster(double, double, double, double, org.gvsig.raster.dataset.BandList, org.gvsig.raster.dataset.IBuffer)
|
315 |
*/
|
316 |
public IBuffer getWindowRaster(double ulx, double uly, double lrx, double lry, BandList bandList, IBuffer rasterBuf) throws InterruptedException, RasterDriverException { |
317 |
Extent selectedExtent = new Extent(ulx, uly, lrx, lry);
|
318 |
setView(selectedExtent); |
319 |
|
320 |
try {
|
321 |
file.readWindow(rasterBuf, bandList, viewRequest.getULX(), viewRequest.getULY(), viewRequest.getLRX(), viewRequest.getLRY(), rasterBuf.getWidth(), rasterBuf.getHeight(), true);
|
322 |
} catch (GdalException e) {
|
323 |
throw new RasterDriverException("Error reading data"); |
324 |
} |
325 |
|
326 |
return rasterBuf;
|
327 |
} |
328 |
|
329 |
/*
|
330 |
* (non-Javadoc)
|
331 |
* @see org.gvsig.fmap.driver.GeoRasterFile#getWindowRaster(double, double, double, double, org.gvsig.fmap.driver.BandList, org.gvsig.fmap.driver.IBuffer)
|
332 |
*/
|
333 |
public IBuffer getWindowRaster(double ulx, double uly, double w, double h, BandList bandList, IBuffer rasterBuf, boolean adjustToExtent) throws InterruptedException, RasterDriverException { |
334 |
//El incremento o decremento de las X e Y depende de los signos de rotaci?n y escala en la matriz de transformaci?n. Por esto
|
335 |
//tenemos que averiguar si lrx es x + w o x -w, asi como si lry es y + h o y - h
|
336 |
Extent ext = getExtent(); |
337 |
Point2D pInit = rasterToWorld(new Point2D.Double(0, 0)); |
338 |
Point2D pEnd = rasterToWorld(new Point2D.Double(getWidth(), getHeight())); |
339 |
double wRaster = Math.abs(pEnd.getX() - pInit.getX()); |
340 |
double hRaster = Math.abs(pEnd.getY() - pInit.getY()); |
341 |
double lrx = (((ext.getULX() - wRaster) > ext.maxX()) || ((ext.getULX() - wRaster) < ext.minX())) ? (ulx + w) : (ulx - w);
|
342 |
double lry = (((ext.getULY() - hRaster) > ext.maxY()) || ((ext.getULY() - hRaster) < ext.minY())) ? (uly + h) : (uly - h);
|
343 |
|
344 |
Extent selectedExtent = new Extent(ulx, uly, lrx, lry);
|
345 |
setView(selectedExtent); |
346 |
|
347 |
try {
|
348 |
file.readWindow(rasterBuf, bandList, viewRequest.getULX(), viewRequest.getULY(), viewRequest.getLRX(), viewRequest.getLRY(), rasterBuf.getWidth(), rasterBuf.getHeight(), adjustToExtent); |
349 |
} catch (GdalException e) {
|
350 |
throw new RasterDriverException("Error reading data"); |
351 |
} |
352 |
|
353 |
return rasterBuf;
|
354 |
} |
355 |
|
356 |
/*
|
357 |
* (non-Javadoc)
|
358 |
* @see org.gvsig.fmap.driver.GeoRasterFile#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.driver.BandList, org.gvsig.fmap.driver.IBuffer)
|
359 |
*/
|
360 |
public IBuffer getWindowRaster(double minX, double minY, double maxX, double maxY, int bufWidth, int bufHeight, BandList bandList, IBuffer rasterBuf, boolean adjustToExtent) throws InterruptedException, RasterDriverException { |
361 |
Extent selectedExtent = new Extent(minX, minY, maxX, maxY);
|
362 |
setView(selectedExtent); |
363 |
|
364 |
double width = 0; |
365 |
double height = 0; |
366 |
|
367 |
Point2D ul = new Point2D.Double(viewRequest.getULX(), viewRequest.getULY()); |
368 |
Point2D lr = new Point2D.Double(viewRequest.getLRX(), viewRequest.getLRY()); |
369 |
ul = worldToRaster(ul); |
370 |
lr = worldToRaster(lr); |
371 |
width = Math.abs(lr.getX() - ul.getX());
|
372 |
height = Math.abs(lr.getY() - ul.getY());
|
373 |
|
374 |
try {
|
375 |
file.readWindow(rasterBuf, bandList, viewRequest.getULX(), viewRequest.getULY(), viewRequest.getLRX(), viewRequest.getLRY(), width, height, bufWidth, bufHeight, adjustToExtent); |
376 |
} catch (GdalException e) {
|
377 |
throw new RasterDriverException("Error reading data"); |
378 |
} |
379 |
|
380 |
return rasterBuf;
|
381 |
} |
382 |
|
383 |
/*
|
384 |
* (non-Javadoc)
|
385 |
* @see org.gvsig.fmap.driver.GeoRasterFile#getWindowRaster(int, int, int, int, org.gvsig.fmap.driver.BandList, org.gvsig.fmap.driver.IBuffer)
|
386 |
*/
|
387 |
public IBuffer getWindowRaster(int x, int y, int w, int h, BandList bandList, IBuffer rasterBuf) throws InterruptedException, RasterDriverException { |
388 |
try {
|
389 |
setView( |
390 |
new Extent( RasterUtilities.getMapRectFromPxRect(getExtent().toRectangle2D(),
|
391 |
getWidth(), |
392 |
getHeight(), |
393 |
new Rectangle2D.Double(x, y, w, h))) |
394 |
); |
395 |
file.readWindow(rasterBuf, bandList, x, y, w, h); |
396 |
} catch (GdalException e) {
|
397 |
throw new RasterDriverException("Error reading data"); |
398 |
} |
399 |
return rasterBuf;
|
400 |
} |
401 |
|
402 |
/*
|
403 |
* (non-Javadoc)
|
404 |
* @see org.gvsig.fmap.driver.GeoRasterFile#getWindowRaster(int, int, int, int, int, int, org.gvsig.fmap.driver.BandList, org.gvsig.fmap.driver.IBuffer)
|
405 |
*/
|
406 |
public IBuffer getWindowRaster(int x, int y, int w, int h, int bufWidth, int bufHeight, BandList bandList, IBuffer rasterBuf) throws InterruptedException, RasterDriverException { |
407 |
try {
|
408 |
setView( |
409 |
new Extent( RasterUtilities.getMapRectFromPxRect(getExtent().toRectangle2D(),
|
410 |
getWidth(), |
411 |
getHeight(), |
412 |
new Rectangle2D.Double(x, y, w, h))) |
413 |
); |
414 |
file.readWindow(rasterBuf, bandList, x, y, w, h, bufWidth, bufHeight); |
415 |
} catch (GdalException e) {
|
416 |
throw new RasterDriverException("Error reading data"); |
417 |
} |
418 |
return rasterBuf;
|
419 |
} |
420 |
|
421 |
/**
|
422 |
* Devuelve el tama?o de bloque
|
423 |
* @return Tama?o de bloque
|
424 |
*/
|
425 |
public int getBlockSize(){ |
426 |
if(file != null) |
427 |
return file.getBlockSize();
|
428 |
else
|
429 |
return 0; |
430 |
} |
431 |
|
432 |
/**
|
433 |
* Obtiene el objeto que contiene los metadatos
|
434 |
*/
|
435 |
public DatasetMetadata getMetadata() {
|
436 |
if(file != null) |
437 |
return file.metadata;
|
438 |
else
|
439 |
return null; |
440 |
} |
441 |
|
442 |
/**
|
443 |
* Obtiene el objeto que contiene que contiene la interpretaci?n de
|
444 |
* color por banda
|
445 |
* @return
|
446 |
*/
|
447 |
public DatasetColorInterpretation getColorInterpretation(){
|
448 |
if(file != null) |
449 |
return file.colorInterpr;
|
450 |
return null; |
451 |
} |
452 |
|
453 |
/**
|
454 |
* Asigna el objeto que contiene que contiene la interpretaci?n de
|
455 |
* color por banda
|
456 |
* @param DatasetColorInterpretation
|
457 |
*/
|
458 |
public void setColorInterpretation(DatasetColorInterpretation colorInterpretation){ |
459 |
if(file != null) |
460 |
file.colorInterpr = colorInterpretation; |
461 |
} |
462 |
|
463 |
/**
|
464 |
* Obtiene el objeto que contiene el estado de la transparencia
|
465 |
*/
|
466 |
public Transparency getTransparencyDatasetStatus() { |
467 |
return file.fileTransparency;
|
468 |
} |
469 |
|
470 |
/**
|
471 |
* Obtiene el flag que dice si la imagen est? o no georreferenciada
|
472 |
* @return true si est? georreferenciada y false si no lo est?.
|
473 |
*/
|
474 |
public boolean isGeoreferenced() { |
475 |
if(file != null) |
476 |
return file.georeferenced;
|
477 |
else
|
478 |
return false; |
479 |
} |
480 |
|
481 |
/**
|
482 |
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el driver el que colocar?
|
483 |
* el valor de esta variable cada vez que dibuja.
|
484 |
* @return true si se ha supersampleado y false si no se ha hecho.
|
485 |
*/
|
486 |
public boolean isSupersampling() { |
487 |
if(file != null) |
488 |
return file.isSupersampling;
|
489 |
else
|
490 |
return false; |
491 |
} |
492 |
|
493 |
public GdalNative getNative(){
|
494 |
return file;
|
495 |
} |
496 |
|
497 |
/**
|
498 |
* Obtiene el nombre del driver
|
499 |
*/
|
500 |
public String getName() { |
501 |
return "gvSIG Gdal Raster Driver"; |
502 |
} |
503 |
|
504 |
public void reProject(ICoordTrans rp) { |
505 |
} |
506 |
|
507 |
/*
|
508 |
* (non-Javadoc)
|
509 |
* @see org.gvsig.raster.dataset.RasterDataset#setAffineTransform(java.awt.geom.AffineTransform)
|
510 |
*/
|
511 |
public void setAffineTransform(AffineTransform t){ |
512 |
super.setAffineTransform(t);
|
513 |
file.setExternalTransform(t); |
514 |
} |
515 |
|
516 |
/*
|
517 |
* (non-Javadoc)
|
518 |
* @see org.gvsig.raster.dataset.RasterDataset#getOverviewCount(int)
|
519 |
*/
|
520 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
521 |
if(band >= getBandCount())
|
522 |
throw new BandAccessException("Wrong band"); |
523 |
try {
|
524 |
return file.getRasterBand(band + 1).getOverviewCount(); |
525 |
} catch (GdalException e) {
|
526 |
throw new RasterDriverException(""); |
527 |
} |
528 |
} |
529 |
|
530 |
/*
|
531 |
* (non-Javadoc)
|
532 |
* @see org.gvsig.raster.dataset.RasterDataset#getOverviewWidth(int, int)
|
533 |
*/
|
534 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
535 |
if (band >= getBandCount())
|
536 |
throw new BandAccessException("Wrong band"); |
537 |
try {
|
538 |
if (overview >= file.getRasterBand(band + 1).getOverviewCount()) |
539 |
throw new BandAccessException("Wrong overview count"); |
540 |
return file.getRasterBand(band + 1).getOverview(overview).getRasterBandXSize(); |
541 |
} catch (GdalException e) {
|
542 |
throw new RasterDriverException(""); |
543 |
} |
544 |
} |
545 |
|
546 |
/*
|
547 |
* (non-Javadoc)
|
548 |
* @see org.gvsig.raster.dataset.RasterDataset#getOverviewWidth(int, int)
|
549 |
*/
|
550 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
551 |
if (band >= getBandCount())
|
552 |
throw new BandAccessException("Wrong band"); |
553 |
try {
|
554 |
if (overview >= file.getRasterBand(band + 1).getOverviewCount()) |
555 |
throw new BandAccessException("Wrong overview count"); |
556 |
return file.getRasterBand(band + 1).getOverview(overview).getRasterBandYSize(); |
557 |
} catch (GdalException e) {
|
558 |
throw new RasterDriverException(""); |
559 |
} |
560 |
} |
561 |
|
562 |
/*
|
563 |
* (non-Javadoc)
|
564 |
* @see org.gvsig.raster.dataset.RasterDataset#overviewsSupport()
|
565 |
*/
|
566 |
public boolean overviewsSupport() { |
567 |
return true; |
568 |
} |
569 |
|
570 |
/*
|
571 |
* (non-Javadoc)
|
572 |
* @see org.gvsig.raster.dataset.RasterDataset#isReproyectable()
|
573 |
*/
|
574 |
public boolean isReproyectable() { |
575 |
return true; |
576 |
} |
577 |
} |