Revision 3125
org.gvsig.raster.lizardtech/tags/org.gvsig.raster.lizardtech-2.2.5/org.gvsig.raster.lizardtech.io/src/main/java/org/gvsig/raster/lizardtech/io/LizardTechNative.java | ||
---|---|---|
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.lizardtech.io; |
|
23 |
|
|
24 |
import java.awt.geom.AffineTransform; |
|
25 |
import java.awt.geom.NoninvertibleTransformException; |
|
26 |
import java.awt.geom.Point2D; |
|
27 |
import java.io.IOException; |
|
28 |
|
|
29 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
30 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
|
31 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
32 |
import org.gvsig.raster.impl.process.RasterTask; |
|
33 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
|
34 |
|
|
35 |
import es.gva.cit.jmrsid.LTIDataType; |
|
36 |
import es.gva.cit.jmrsid.LTIGeoCoord; |
|
37 |
import es.gva.cit.jmrsid.LTIImageStage; |
|
38 |
import es.gva.cit.jmrsid.LTIMetadataDatabase; |
|
39 |
import es.gva.cit.jmrsid.LTIMetadataRecord; |
|
40 |
import es.gva.cit.jmrsid.LTISceneBuffer; |
|
41 |
import es.gva.cit.jmrsid.LTIUtils; |
|
42 |
import es.gva.cit.jmrsid.MrSIDException; |
|
43 |
import es.gva.cit.jmrsid.MrSIDImageReader; |
|
44 |
|
|
45 |
public class LizardTechNative extends MrSIDImageReader { |
|
46 |
static boolean WITH_OVERVIEWS = true; |
|
47 |
public int width = 0; |
|
48 |
public int height = 0; |
|
49 |
public double originX = 0D; |
|
50 |
public double originY = 0D; |
|
51 |
public String version = ""; |
|
52 |
public LTIMetadataDatabase metadata; |
|
53 |
private int alpha = 0; |
|
54 |
protected int rBandNr = 1; |
|
55 |
protected int gBandNr = 2; |
|
56 |
protected int bBandNr = 3; |
|
57 |
protected byte[] bandR; |
|
58 |
protected byte[] bandG; |
|
59 |
protected byte[] bandB; |
|
60 |
private int dataType = LTIDataType.LTI_DATATYPE_UINT8; |
|
61 |
//View |
|
62 |
private double zoomoverview = 0.0; |
|
63 |
private int eSampleType; |
|
64 |
private int noverviews; |
|
65 |
public int xini; |
|
66 |
public int yini; |
|
67 |
/** |
|
68 |
* Ancho y alto de la overview |
|
69 |
*/ |
|
70 |
public int anchoOver; |
|
71 |
public int altoOver; |
|
72 |
public int blocksize = 1; |
|
73 |
/** |
|
74 |
* N?mero de bandas de la imagen |
|
75 |
*/ |
|
76 |
public int nbands; |
|
77 |
/** |
|
78 |
* Posici?n de la esquina superior izquierda en coordenadas pixel |
|
79 |
*/ |
|
80 |
private double currentViewY = -1; |
|
81 |
private double currentViewX = 0D; |
|
82 |
/** |
|
83 |
* Ancho y alto de la im�gen (pixeles en pantalla) |
|
84 |
*/ |
|
85 |
private int currentViewWidth = -1; |
|
86 |
private int currentViewHeight = -1; |
|
87 |
/** |
|
88 |
* Ancho y alto de la imagen completa en pixeles |
|
89 |
*/ |
|
90 |
@SuppressWarnings("unused") |
|
91 |
private int currentFullWidth = -1; |
|
92 |
@SuppressWarnings("unused") |
|
93 |
private int currentFullHeight = -1; |
|
94 |
private int overviewFullWidth = -1; |
|
95 |
private int overviewFullHeight = -1; |
|
96 |
/** |
|
97 |
* Escala del viewport en X e Y |
|
98 |
*/ |
|
99 |
private double viewportScaleX = 0D; |
|
100 |
private double viewportScaleY = 0D; |
|
101 |
/** |
|
102 |
* ?ltimo extent de la ventana seleccionada por el usuario. Este extent corresponde al de la |
|
103 |
* imagen, no al del viewport de la vista. |
|
104 |
*/ |
|
105 |
private double[] currentImageView = new double[4]; |
|
106 |
public int[] stepArrayX = null; |
|
107 |
public int[] stepArrayY = null; |
|
108 |
public boolean isSupersampling = false; |
|
109 |
private String fileName = null; |
|
110 |
protected AffineTransform ownTransformation = null; |
|
111 |
protected AffineTransform externalTransformation = new AffineTransform(); |
|
112 |
/** |
|
113 |
*Array de transformaciones afines donde cada elemento es la transformaci�n correspondiente a una overview |
|
114 |
*/ |
|
115 |
protected AffineTransform[] overviewsTransformation = null; |
|
116 |
|
|
117 |
/** |
|
118 |
* Constructor |
|
119 |
* @param fName |
|
120 |
* @throws MrSIDException |
|
121 |
* @throws IOException |
|
122 |
*/ |
|
123 |
public LizardTechNative(String fName) throws MrSIDException, IOException { |
|
124 |
super(fName); |
|
125 |
init(fName); |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* Inicializa las variables de instancia con los valores de la imagen |
|
130 |
* @param fName |
|
131 |
* @throws MrSIDException |
|
132 |
* @throws IOException |
|
133 |
*/ |
|
134 |
private void init(String fName) throws MrSIDException, IOException { |
|
135 |
this.initialize(); |
|
136 |
|
|
137 |
fileName = fName; |
|
138 |
width = this.getWidth(); |
|
139 |
height = this.getHeight(); |
|
140 |
eSampleType = this.getDataType(); |
|
141 |
nbands = this.getNumBands(); |
|
142 |
//eColorSpace = this.getColorSpace(); |
|
143 |
noverviews = this.getNumLevels(); |
|
144 |
overviewsTransformation = new AffineTransform[noverviews]; |
|
145 |
|
|
146 |
//Creamos una matriz de transformaci�n por nivel de overview con el factor de escala de esta overview |
|
147 |
overviewsTransformation[0] = new AffineTransform(); |
|
148 |
int[] dims = this.getDimsAtMag(LTIUtils.levelToMag(0)); |
|
149 |
int dimLastX = dims[0]; |
|
150 |
int dimLastY = dims[1]; |
|
151 |
for (int i = 1; i < noverviews; i++) { |
|
152 |
dims = this.getDimsAtMag(LTIUtils.levelToMag(i)); |
|
153 |
|
|
154 |
double scaleFactorX = (double)dims[0] / (double)dimLastX; |
|
155 |
double scaleFactorY = (double)dims[1] / (double)dimLastY; |
|
156 |
//System.out.println("Over:" + i + " zoom:" + LTIUtils.levelToMag(i) + " dims:" + dims[0] + "X" + dims[1]); |
|
157 |
overviewsTransformation[i] = new AffineTransform(scaleFactorX, 0, 0, scaleFactorY, 0, 0); |
|
158 |
} |
|
159 |
|
|
160 |
metadata = this.getMetadata(); |
|
161 |
|
|
162 |
double ox = 0D; |
|
163 |
double oy = 0D; |
|
164 |
double resx = 0D; |
|
165 |
double resy = 0D; |
|
166 |
|
|
167 |
LTIGeoCoord geoc = this.getGeoCoord(); |
|
168 |
|
|
169 |
ox = geoc.getX(); |
|
170 |
oy = geoc.getY(); |
|
171 |
resx = geoc.getXRes(); |
|
172 |
resy = geoc.getYRes(); |
|
173 |
|
|
174 |
ownTransformation = new AffineTransform(resx, 0, 0, resy, ox, oy); |
|
175 |
externalTransformation = (AffineTransform)ownTransformation.clone(); |
|
176 |
|
|
177 |
currentFullWidth = width; |
|
178 |
currentFullHeight = height; |
|
179 |
|
|
180 |
blocksize = this.getStripHeight(); |
|
181 |
|
|
182 |
if(nbands == 1) { |
|
183 |
rBandNr = gBandNr = bBandNr = 1; |
|
184 |
} |
|
185 |
if(nbands == 2) { |
|
186 |
rBandNr = gBandNr = 1; |
|
187 |
bBandNr = 2; |
|
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* Asigna el valor de Alpha |
|
193 |
* @param a alpha |
|
194 |
*/ |
|
195 |
public void setAlpha(int a) { |
|
196 |
alpha = a; |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* Asigna el tipo de datos |
|
201 |
* @param dt tipo de datos |
|
202 |
*/ |
|
203 |
public void setDataType(int dt) { |
|
204 |
dataType = dt; |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* Obtiene un punto 2D con las coordenadas del raster a partir de uno en coordenadas |
|
209 |
* del punto real. |
|
210 |
* Supone rasters no girados |
|
211 |
* @param pt punto en coordenadas del punto real |
|
212 |
* @return punto en coordenadas del raster |
|
213 |
*/ |
|
214 |
public Point2D worldToRaster(Point2D pt) { |
|
215 |
Point2D p = new Point2D.Double(); |
|
216 |
try { |
|
217 |
externalTransformation.inverseTransform(pt, p); |
|
218 |
} catch (NoninvertibleTransformException e) { |
|
219 |
return pt; |
|
220 |
} |
|
221 |
return p; |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* Obtiene un punto del raster en coordenadas pixel a partir de un punto en coordenadas |
|
226 |
* reales. |
|
227 |
* @param pt Punto en coordenadas reales |
|
228 |
* @return Punto en coordenadas pixel. |
|
229 |
*/ |
|
230 |
public Point2D rasterToWorld(Point2D pt) { |
|
231 |
Point2D p = new Point2D.Double(); |
|
232 |
externalTransformation.transform(pt, p); |
|
233 |
return p; |
|
234 |
} |
|
235 |
|
|
236 |
/** |
|
237 |
* Calcula el overview a usar de la imagen y el viewport a partir del ancho, alto y |
|
238 |
* coordenadas del mundo real |
|
239 |
* @param dWorldTLX Coordenada X superior izquierda |
|
240 |
* @param dWorldTLY Coordenada Y superior izquierda |
|
241 |
* @param dWorldBRX Coordenada X inferior derecha |
|
242 |
* @param dWorldBRY Coordenada Y inferior derecha |
|
243 |
* @param nWidth ancho |
|
244 |
* @param nHeight alto |
|
245 |
*/ |
|
246 |
public void setView(double ulx, double uly, double lrx, double lry, |
|
247 |
int nWidth, int nHeight) { |
|
248 |
currentImageView[0] = ulx; |
|
249 |
currentImageView[1] = uly; |
|
250 |
currentImageView[2] = lrx; |
|
251 |
currentImageView[3] = lry; |
|
252 |
|
|
253 |
//Ancho y alto de la im�gen en pixeles (pixeles de la overview) |
|
254 |
overviewFullWidth = currentFullWidth = width; |
|
255 |
overviewFullHeight = currentFullHeight = height; |
|
256 |
|
|
257 |
//Ventana de la imagen. (en tama�o completo) |
|
258 |
//tl->esq sup izda en pixeles |
|
259 |
//br->esq inf der en pixeles |
|
260 |
Point2D a = worldToRaster(new Point2D.Double(ulx, uly)); |
|
261 |
Point2D b = worldToRaster(new Point2D.Double(lrx, lry)); |
|
262 |
Point2D tl = new Point2D.Double(Math.min(a.getX(), b.getX()), Math.min(a.getY(), b.getY())); |
|
263 |
Point2D br = new Point2D.Double(Math.max(a.getX(), b.getX()), Math.max(a.getY(), b.getY())); |
|
264 |
|
|
265 |
//Ancho y alto de la im�gen (pixeles en pantalla) |
|
266 |
currentViewWidth = nWidth; |
|
267 |
currentViewHeight = nHeight; |
|
268 |
|
|
269 |
//Posici�n de la esquina superior izquierda en coordenadas pixel |
|
270 |
currentViewX = tl.getX(); |
|
271 |
currentViewY = tl.getY(); |
|
272 |
|
|
273 |
//Escala de la vista en X e Y |
|
274 |
viewportScaleX = (double) currentViewWidth / (br.getX() - tl.getX()); |
|
275 |
viewportScaleY = (double) currentViewHeight / (br.getY() - tl.getY()); |
|
276 |
|
|
277 |
try { |
|
278 |
// calcula el overview a usar |
|
279 |
int[] dims = null; |
|
280 |
double zoom = 1.0; |
|
281 |
zoomoverview = 1.0; |
|
282 |
|
|
283 |
if (WITH_OVERVIEWS && ((noverviews - 1) > 0)) { |
|
284 |
for (int i = (noverviews - 1); i > 0; i--) { |
|
285 |
zoom = LTIUtils.levelToMag(i); |
|
286 |
dims = this.getDimsAtMag(zoom); |
|
287 |
|
|
288 |
if (dims[0] > (this.getWidth() * viewportScaleX)) { |
|
289 |
zoomoverview = zoom; |
|
290 |
viewportScaleX /= zoomoverview; |
|
291 |
viewportScaleY /= zoomoverview; |
|
292 |
overviewFullWidth = currentFullWidth = dims[0]; |
|
293 |
overviewFullHeight = currentFullHeight = dims[1]; |
|
294 |
tl = worldToRaster(new Point2D.Double(ulx, uly)); |
|
295 |
br = worldToRaster(new Point2D.Double(lrx, lry)); |
|
296 |
tl.setLocation(Math.min(tl.getX(), br.getX()), Math.min(tl.getY(), br.getY())); |
|
297 |
overviewsTransformation[i].transform(tl, tl); |
|
298 |
//Hemos asignado currentFull solo para calcular tl en relaci�n al tama�o de la overview |
|
299 |
currentFullWidth = width; |
|
300 |
currentFullHeight = height; |
|
301 |
currentViewX = tl.getX(); |
|
302 |
currentViewY = tl.getY(); |
|
303 |
break; |
|
304 |
} |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
setDataType(eSampleType); |
|
309 |
} catch (MrSIDException e) { |
|
310 |
e.printStackTrace(); |
|
311 |
} |
|
312 |
} |
|
313 |
|
|
314 |
/** |
|
315 |
* Muestra alguna informaci�n para la depuraci�n |
|
316 |
*/ |
|
317 |
void pintaInfo() { |
|
318 |
try { |
|
319 |
System.out.println("GeoTransform:"); |
|
320 |
|
|
321 |
LTIGeoCoord geoc = this.getGeoCoord(); |
|
322 |
|
|
323 |
System.out.println(" param[0]=" + geoc.getX()); |
|
324 |
System.out.println(" param[0]=" + geoc.getY()); |
|
325 |
System.out.println(" param[0]=" + geoc.getXRes()); |
|
326 |
System.out.println(" param[0]=" + geoc.getYRes()); |
|
327 |
System.out.println(" param[0]=" + geoc.getXRot()); |
|
328 |
System.out.println(" param[0]=" + geoc.getYRot()); |
|
329 |
System.out.println("Metadata:"); |
|
330 |
|
|
331 |
LTIMetadataDatabase metadata = this.getMetadata(); |
|
332 |
|
|
333 |
for (int i = 0; i < metadata.getIndexCount(); i++) { |
|
334 |
LTIMetadataRecord rec = null; |
|
335 |
rec = metadata.getDataByIndex(i); |
|
336 |
System.out.println(rec.getTagName()); |
|
337 |
|
|
338 |
if (rec.isScalar()) { |
|
339 |
System.out.println(rec.getScalarData()); |
|
340 |
} else if (rec.isVector()) { |
|
341 |
String[] s = rec.getVectorData(); |
|
342 |
|
|
343 |
for (int j = 0; j < s.length; j++) |
|
344 |
System.out.println("V" + j + "->" + s[j]); |
|
345 |
} else if (rec.isArray()) { |
|
346 |
String[] s = rec.getArrayData(); |
|
347 |
|
|
348 |
for (int j = 0; j < s.length; j++) |
|
349 |
System.out.println("A" + j + "->" + s[j]); |
|
350 |
} else { |
|
351 |
System.out.println(""); |
|
352 |
} |
|
353 |
} |
|
354 |
} catch (MrSIDException e) { |
|
355 |
// TODO Auto-generated catch block |
|
356 |
e.printStackTrace(); |
|
357 |
} |
|
358 |
} |
|
359 |
|
|
360 |
|
|
361 |
public LTISceneBuffer readBuffer(int x, int y, int SceneWidth, int SceneHeight)throws MrSIDException{ |
|
362 |
LTISceneBuffer buffer = ((LTIImageStage) this).readScene((double)x, (double)y, (double)SceneWidth, (double)SceneHeight, zoomoverview, (MrSIDImageReader)this, SceneWidth, SceneHeight, true); |
|
363 |
return buffer; |
|
364 |
} |
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
/** |
|
369 |
* Lee la escena de la imagen correspondiente a la vista seleccionada con |
|
370 |
* currentView a trav�s de la libreria de MrSid. Esta escena es cargada sobre |
|
371 |
* un buffer y asignada al par�metro de salida. |
|
372 |
* @param line Escena leida |
|
373 |
* @throws MrSIDException Lanzada si ocurre un error en la lectura de la escena |
|
374 |
*/ |
|
375 |
public void readScene(int[] line, RasterTask task) throws MrSIDException, ProcessInterruptedException { |
|
376 |
//Posici�n de inicio de la escena en entero para la petici�n a la libreria |
|
377 |
int x = (int) Math.floor(currentViewX); |
|
378 |
int y = (int) Math.floor(currentViewY); |
|
379 |
|
|
380 |
//Ancho y alto de la escena en pixeles |
|
381 |
int SceneWidth = 0; |
|
382 |
int SceneHeight = 0; |
|
383 |
|
|
384 |
SceneWidth = (int) Math.ceil((((double) currentViewWidth) / viewportScaleX) + 1); |
|
385 |
SceneHeight = (int) Math.ceil((((double) currentViewHeight) / viewportScaleY) + 1); |
|
386 |
|
|
387 |
while((x + SceneWidth) > overviewFullWidth) |
|
388 |
SceneWidth --; |
|
389 |
while((y + SceneHeight) > overviewFullHeight) |
|
390 |
SceneHeight --; |
|
391 |
|
|
392 |
if (SceneWidth == 0) |
|
393 |
SceneWidth = 1; |
|
394 |
|
|
395 |
if (SceneHeight == 0) |
|
396 |
SceneHeight = 1; |
|
397 |
|
|
398 |
LTISceneBuffer buffer = null; |
|
399 |
buffer = ((LTIImageStage) this).readScene((double)x, (double)y, (double)SceneWidth, (double)SceneHeight, zoomoverview, (MrSIDImageReader)this, SceneWidth, SceneHeight, true); |
|
400 |
|
|
401 |
/*boolean sizeOk = false; |
|
402 |
while (!sizeOk) { |
|
403 |
sizeOk = true; |
|
404 |
try { |
|
405 |
buffer = readBuffer(x, y, SceneWidth, SceneHeight); |
|
406 |
} catch (MrSIDException ex) { |
|
407 |
SceneWidth-- ; |
|
408 |
try{ |
|
409 |
buffer = readBuffer(x, y, SceneWidth, SceneHeight); |
|
410 |
} catch (MrSIDException ex1) { |
|
411 |
SceneWidth++; |
|
412 |
SceneHeight--; |
|
413 |
try{ |
|
414 |
buffer = readBuffer(x, y, SceneWidth, SceneHeight); |
|
415 |
} catch (MrSIDException ex2) { |
|
416 |
SceneWidth-- ; |
|
417 |
try{ |
|
418 |
buffer = readBuffer(x, y, SceneWidth, SceneHeight); |
|
419 |
} catch (MrSIDException ex3) { |
|
420 |
sizeOk = false; |
|
421 |
} |
|
422 |
} |
|
423 |
} |
|
424 |
} |
|
425 |
}*/ |
|
426 |
|
|
427 |
if(task.getEvent() != null) |
|
428 |
task.manageEvent(task.getEvent()); |
|
429 |
|
|
430 |
if ((dataType == LTIDataType.LTI_DATATYPE_UINT8) || |
|
431 |
(dataType == LTIDataType.LTI_DATATYPE_SINT8) || |
|
432 |
(dataType == LTIDataType.LTI_DATATYPE_SINT16) || |
|
433 |
(dataType == LTIDataType.LTI_DATATYPE_SINT32) || |
|
434 |
(dataType == LTIDataType.LTI_DATATYPE_UINT16) || |
|
435 |
(dataType == LTIDataType.LTI_DATATYPE_UINT32)) { |
|
436 |
int kd; |
|
437 |
int k; |
|
438 |
double scaleX = 1 / viewportScaleX; |
|
439 |
double scaleY = 1 / viewportScaleY; |
|
440 |
|
|
441 |
int alpha = (this.alpha & 0xff) << 24; |
|
442 |
|
|
443 |
if (rBandNr == 1) { |
|
444 |
bandR = buffer.buf1; |
|
445 |
} else if (rBandNr == 2) { |
|
446 |
bandR = buffer.buf2; |
|
447 |
} else if (rBandNr == 3) { |
|
448 |
bandR = buffer.buf3; |
|
449 |
} |
|
450 |
|
|
451 |
if (gBandNr == 1) { |
|
452 |
bandG = buffer.buf1; |
|
453 |
} else if (gBandNr == 2) { |
|
454 |
bandG = buffer.buf2; |
|
455 |
} else if (gBandNr == 3) { |
|
456 |
bandG = buffer.buf3; |
|
457 |
} |
|
458 |
|
|
459 |
if (bBandNr == 1) { |
|
460 |
bandB = buffer.buf1; |
|
461 |
} else if (bBandNr == 2) { |
|
462 |
bandB = buffer.buf2; |
|
463 |
} else if (bBandNr == 3) { |
|
464 |
bandB = buffer.buf3; |
|
465 |
} |
|
466 |
|
|
467 |
//Desplazamiento para la X y la Y leidas. Estas tienen efecto cuando un pixel no empieza a visualizarse |
|
468 |
//justo en su esquina superior izquierda y tiene que ser cortado en la visualizaci�n. |
|
469 |
double offsetX = Math.abs(currentViewX - ((int)currentViewX)); |
|
470 |
double offsetY = Math.abs(currentViewY - ((int)currentViewY)); |
|
471 |
|
|
472 |
for (int y1 = 0; y1 < currentViewHeight; y1++) { |
|
473 |
for (int x1 = 0; x1 < currentViewWidth; x1++) { |
|
474 |
kd = (y1 * currentViewWidth) + x1; |
|
475 |
k = (((int) ((y1 * scaleY) + offsetY)) * SceneWidth) + (int) ((x1 * scaleX) + offsetX); |
|
476 |
try { |
|
477 |
line[kd] = alpha + ((0xff & bandR[k]) << 16) + ((0xff & bandG[k]) << 8) + (0xff & bandB[k]); |
|
478 |
} catch (java.lang.ArrayIndexOutOfBoundsException e) { |
|
479 |
} |
|
480 |
} |
|
481 |
if(task.getEvent() != null) |
|
482 |
task.manageEvent(task.getEvent()); |
|
483 |
} |
|
484 |
} |
|
485 |
|
|
486 |
buffer = null; |
|
487 |
} |
|
488 |
|
|
489 |
/** |
|
490 |
* Reads a window of data. The size of the input window may not coincide |
|
491 |
* with the size of the buffer. In that case would have to resize |
|
492 |
* @param buf |
|
493 |
* @param bandList |
|
494 |
* @param x |
|
495 |
* Initial X position in input buffer |
|
496 |
* @param y |
|
497 |
* Initial Y position in input buffer |
|
498 |
* @throws MrSIDException |
|
499 |
* @throws ProcessInterruptedException |
|
500 |
*/ |
|
501 |
public void readWindow(Buffer buf, |
|
502 |
BandList bandList, |
|
503 |
int x, int y, int w, int h, |
|
504 |
int bufWidth, int bufHeight) throws MrSIDException, ProcessInterruptedException { |
|
505 |
if(bufWidth > buf.getWidth()) |
|
506 |
bufWidth = buf.getWidth(); |
|
507 |
|
|
508 |
if(bufHeight > buf.getHeight()) |
|
509 |
bufHeight = buf.getHeight(); |
|
510 |
|
|
511 |
if(buf.isCached()) { |
|
512 |
int nBlocks = (int)(bufHeight / buf.getBlockHeight()); |
|
513 |
int lastBlock = bufHeight - (nBlocks * buf.getBlockHeight()); |
|
514 |
int lastBlockSrc = (lastBlock * h) / bufHeight; |
|
515 |
int sizeBlockSrc = (buf.getBlockHeight() * h) / bufHeight; |
|
516 |
if(lastBlock > 0) |
|
517 |
nBlocks ++; |
|
518 |
int initSrc = y; |
|
519 |
int init = 0; |
|
520 |
for (int i = 0; i < nBlocks; i++) { |
|
521 |
if(lastBlock > 0 && i == (nBlocks - 1)) { |
|
522 |
double[] stepSrc = new double[]{x, initSrc, w, lastBlockSrc}; |
|
523 |
int[] stepDst = new int[]{0, init, bufWidth, init + lastBlock}; |
|
524 |
readWindowInMemory(buf, bandList, stepSrc, stepDst, w, lastBlock); |
|
525 |
} else { |
|
526 |
double[] stepSrc = new double[]{x, initSrc, w, sizeBlockSrc}; |
|
527 |
int[] stepDst = new int[]{0, init, bufWidth, init + buf.getBlockHeight()}; |
|
528 |
readWindowInMemory(buf, bandList, stepSrc, stepDst, w, buf.getBlockHeight()); |
|
529 |
init += buf.getBlockHeight(); |
|
530 |
initSrc += sizeBlockSrc; |
|
531 |
} |
|
532 |
} |
|
533 |
} else { |
|
534 |
readWindowInMemory(buf, bandList, x, y, w, h); |
|
535 |
} |
|
536 |
} |
|
537 |
|
|
538 |
/** |
|
539 |
* Reads a window of data. The width and height is indicated by the size of the buffer |
|
540 |
* @param buf |
|
541 |
* @param bandList |
|
542 |
* @param x |
|
543 |
* Initial X position in input buffer |
|
544 |
* @param y |
|
545 |
* Initial Y position in input buffer |
|
546 |
* @throws MrSIDException |
|
547 |
* @throws ProcessInterruptedException |
|
548 |
*/ |
|
549 |
public void readWindow(Buffer buf, BandList bandList, int x, int y) throws MrSIDException, ProcessInterruptedException { |
|
550 |
int w = (x + buf.getWidth()) > getWidth() ? getWidth() - x : buf.getWidth(); |
|
551 |
int h = (y + buf.getHeight()) > getHeight() ? getHeight() - y : buf.getHeight(); |
|
552 |
|
|
553 |
if(buf.isCached()) { |
|
554 |
int nBlocks = (int)(buf.getHeight() / buf.getBlockHeight()); |
|
555 |
int lastBlock = buf.getHeight() - (nBlocks * buf.getBlockHeight()); |
|
556 |
if(lastBlock > 0) |
|
557 |
nBlocks ++; |
|
558 |
int initYSrc = y; |
|
559 |
int initYBuffer = 0; |
|
560 |
for (int i = 0; i < nBlocks; i++) { |
|
561 |
if(lastBlock > 0 && i == (nBlocks - 1)) { |
|
562 |
double[] stepSrc = new double[]{x, initYSrc, w, lastBlock}; |
|
563 |
int[] stepDst = new int[]{0, initYBuffer, w, initYBuffer + lastBlock}; |
|
564 |
readWindowInMemory(buf, bandList, stepSrc, stepDst, w, lastBlock); |
|
565 |
} else { |
|
566 |
double[] stepSrc = new double[]{x, initYSrc, w, buf.getBlockHeight()}; |
|
567 |
int[] stepDst = new int[]{0, initYBuffer, w, initYBuffer + buf.getBlockHeight()}; |
|
568 |
readWindowInMemory(buf, bandList, stepSrc, stepDst, w, buf.getBlockHeight()); |
|
569 |
initYSrc += buf.getBlockHeight(); |
|
570 |
initYBuffer += buf.getBlockHeight(); |
|
571 |
} |
|
572 |
} |
|
573 |
} else { |
|
574 |
readWindowInMemory(buf, bandList, x, y, w, h); |
|
575 |
} |
|
576 |
} |
|
577 |
|
|
578 |
|
|
579 |
private void readWindowInMemory(Buffer buf, BandList bandList, double[] srcPxPos, int[] stepDst, int sizeSrcX, int sizeSrcY) throws MrSIDException, ProcessInterruptedException { |
|
580 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
|
581 |
|
|
582 |
isSupersampling = false; |
|
583 |
|
|
584 |
LTISceneBuffer buffer = ((LTIImageStage) this).readScene( |
|
585 |
srcPxPos[0], srcPxPos[1], srcPxPos[2], srcPxPos[3], |
|
586 |
1.0, |
|
587 |
(MrSIDImageReader)this, |
|
588 |
sizeSrcX, sizeSrcY, |
|
589 |
true); |
|
590 |
|
|
591 |
byte[] bandBuf = null; |
|
592 |
for(int iBand = 0; iBand < getNumBands(); iBand++) { |
|
593 |
int[] drawableBands = bandList.getBufferBandToDraw(fileName, iBand); |
|
594 |
if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
595 |
continue; |
|
596 |
switch(iBand) { |
|
597 |
case 0: bandBuf = buffer.buf1; break; |
|
598 |
case 1: bandBuf = buffer.buf2; break; |
|
599 |
case 2: bandBuf = buffer.buf3; break; |
|
600 |
} |
|
601 |
|
|
602 |
int lineSrc = 0; |
|
603 |
for (int line = stepDst[1]; line < stepDst[3]; line++) { |
|
604 |
int colSrc = 0; |
|
605 |
for (int col = stepDst[0]; col < stepDst[2]; col++) { |
|
606 |
int kd = (int)((lineSrc * srcPxPos[2]) + colSrc); |
|
607 |
buf.setElem(line, col, iBand, (byte)bandBuf[kd]); |
|
608 |
colSrc ++; |
|
609 |
} |
|
610 |
lineSrc ++; |
|
611 |
if(task.getEvent() != null) |
|
612 |
task.manageEvent(task.getEvent()); |
|
613 |
} |
|
614 |
} |
|
615 |
} |
|
616 |
|
|
617 |
/** |
|
618 |
* Lee una ventana de datos sin resampleo a partir de coordenadas en pixeles. |
|
619 |
* @param buf Buffer donde se almacenan los datos |
|
620 |
* @param bandList Lista de bandas que queremos leer y sobre que bandas del buffer de destino queremos escribirlas |
|
621 |
* @param x Posici�n X en pixeles |
|
622 |
* @param y Posici�n Y en pixeles |
|
623 |
* @param w Ancho en pixeles |
|
624 |
* @param h Alto en pixeles |
|
625 |
*/ |
|
626 |
private void readWindowInMemory(Buffer buf, BandList bandList, int x, int y, int w, int h) throws MrSIDException, ProcessInterruptedException { |
|
627 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
|
628 |
|
|
629 |
isSupersampling = false; |
|
630 |
|
|
631 |
LTISceneBuffer buffer = ((LTIImageStage) this).readScene((double)x, (double)y, (double)w, (double)h, 1.0, (MrSIDImageReader)this, w, h, true); |
|
632 |
|
|
633 |
byte[] bandBuf = null; |
|
634 |
for(int iBand = 0; iBand < getNumBands(); iBand++) { |
|
635 |
int[] drawableBands = bandList.getBufferBandToDraw(fileName, iBand); |
|
636 |
if(drawableBands == null || (drawableBands.length == 1 && drawableBands[0] == -1)) |
|
637 |
continue; |
|
638 |
switch(iBand) { |
|
639 |
case 0: bandBuf = buffer.buf1; break; |
|
640 |
case 1: bandBuf = buffer.buf2; break; |
|
641 |
case 2: bandBuf = buffer.buf3; break; |
|
642 |
} |
|
643 |
for (int line = 0; line < h; line++){ |
|
644 |
for (int col = 0; col < w; col++){ |
|
645 |
int kd = (line * w) + col; |
|
646 |
buf.setElem(line, col, iBand, (byte)bandBuf[kd]); |
|
647 |
} |
|
648 |
if(task.getEvent() != null) |
|
649 |
task.manageEvent(task.getEvent()); |
|
650 |
} |
|
651 |
} |
|
652 |
} |
|
653 |
|
|
654 |
/** |
|
655 |
* Lee una ventana de la imagen y devuelve un buffer de bytes |
|
656 |
* @param ulX Coordenada X de la esquina superior izquierda |
|
657 |
* @param ulY Coordenada Y de la esquina superior izquierda |
|
658 |
* @param sizeX Tama�o X de la imagen |
|
659 |
* @param sizeY Tama�o Y de la image |
|
660 |
* @param band N�mero de bandas |
|
661 |
* @return buffer con la ventana leida |
|
662 |
* @throws MrSIDException |
|
663 |
*/ |
|
664 |
public byte[] getWindow(int ulX, int ulY, int sizeX, int sizeY, int band) throws MrSIDException { |
|
665 |
LTISceneBuffer buffer = ((LTIImageStage) this).readScene((double)ulX, (double)ulY, (double)sizeX, (double)sizeY, 1.0, (MrSIDImageReader)this, sizeX, sizeY, true); |
|
666 |
|
|
667 |
if (band == 1) { |
|
668 |
return buffer.buf1; |
|
669 |
} else if (band == 2) { |
|
670 |
return buffer.buf2; |
|
671 |
} else if (band == 3) { |
|
672 |
return buffer.buf3; |
|
673 |
} |
|
674 |
|
|
675 |
return null; |
|
676 |
} |
|
677 |
|
|
678 |
/** |
|
679 |
* Obtiene el valor de un pixel determinado por las coordenadas x e y que se pasan |
|
680 |
* por par�metro |
|
681 |
* @param x Coordenada X del pixel |
|
682 |
* @param y Coordenada Y del pixel |
|
683 |
* @return Array de Object donde cada posici�n representa una banda y el valor ser� Integer |
|
684 |
* en caso de ser byte, shot o int, Float en caso de ser float y Double en caso de ser double. |
|
685 |
*/ |
|
686 |
public Object[] getData(int x, int y) { |
|
687 |
try { |
|
688 |
Object[] data = new Object[nbands]; |
|
689 |
for(int i = 0; i < nbands; i++){ |
|
690 |
byte[] b = getWindow(x, y, 1, 1, nbands); |
|
691 |
switch(dataType){ |
|
692 |
case 0: break; |
|
693 |
case 1: data[i] = new Integer(b[0]); |
|
694 |
break; |
|
695 |
case 2: |
|
696 |
case 3: data[i] = new Integer(b[0]); |
|
697 |
break; |
|
698 |
case 4: |
|
699 |
case 5: data[i] = new Integer(b[0]); |
|
700 |
break; |
|
701 |
case 6: data[i] = new Float(b[0]); |
|
702 |
break; |
|
703 |
case 7: data[i] = new Double(b[0]); |
|
704 |
break; |
|
705 |
} |
|
706 |
} |
|
707 |
return data; |
|
708 |
} catch (MrSIDException e) { |
|
709 |
return null; |
|
710 |
} |
|
711 |
} |
|
712 |
|
|
713 |
/** |
|
714 |
* Asigna una transformaci�n que es aplicada sobre la que ya tiene el propio fichero |
|
715 |
* @param t |
|
716 |
*/ |
|
717 |
public void setExternalTransform(AffineTransform t){ |
|
718 |
externalTransformation = t; |
|
719 |
} |
|
720 |
|
|
721 |
/** |
|
722 |
* Devuelve la transformaci�n del fichero de georreferenciaci�n |
|
723 |
* @return AffineTransform |
|
724 |
*/ |
|
725 |
public AffineTransform getOwnTransformation() { |
|
726 |
return ownTransformation; |
|
727 |
} |
|
728 |
} |
|
0 | 729 |
org.gvsig.raster.lizardtech/tags/org.gvsig.raster.lizardtech-2.2.5/org.gvsig.raster.lizardtech.io/src/main/java/org/gvsig/raster/lizardtech/io/LizardTechProvider.java | ||
---|---|---|
1 |
package org.gvsig.raster.lizardtech.io; |
|
2 |
|
|
3 |
import java.awt.geom.AffineTransform; |
|
4 |
import java.awt.geom.Point2D; |
|
5 |
import java.awt.image.BufferedImage; |
|
6 |
|
|
7 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
8 |
import org.gvsig.fmap.dal.DALLocator; |
|
9 |
import org.gvsig.fmap.dal.DataStore; |
|
10 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
11 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
12 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
|
13 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
14 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
|
15 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
|
16 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
|
17 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
18 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException; |
|
19 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
20 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
21 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
22 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
|
23 |
import org.gvsig.metadata.MetadataLocator; |
|
24 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
|
25 |
import org.gvsig.raster.impl.buffer.SpiRasterQuery; |
|
26 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
|
27 |
import org.gvsig.raster.impl.process.RasterTask; |
|
28 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
|
29 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
|
30 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
31 |
import org.gvsig.raster.impl.provider.tile.FileTileServer; |
|
32 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
|
33 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
|
34 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
|
35 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
|
36 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
|
37 |
import org.gvsig.tools.ToolsLocator; |
|
38 |
|
|
39 |
import es.gva.cit.jmrsid.MrSIDException; |
|
40 |
/** |
|
41 |
* Clase encargada del acceso a los datos y repintado de imagenes MrSID. Estos |
|
42 |
* son registrados con la extensi?n sid |
|
43 |
* |
|
44 |
* @version 15/05/2008 |
|
45 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
46 |
*/ |
|
47 |
public class LizardTechProvider extends AbstractRasterProvider { |
|
48 |
public static String NAME = "LizardTech Store"; |
|
49 |
public static String DESCRIPTION = "LizardTech Raster file"; |
|
50 |
public static final String METADATA_DEFINITION_NAME = "LizardTechStore"; |
|
51 |
protected LizardTechNative file = null; |
|
52 |
private Extent viewRequest = null; |
|
53 |
private DataStoreColorInterpretation colorInterpr = null; |
|
54 |
protected DataStoreTransparency fileTransparency = null; |
|
55 |
private boolean open = false; |
|
56 |
protected static String[] formatList = null; |
|
57 |
|
|
58 |
public static void register() { |
|
59 |
RasterLocator.getManager().getProviderServices().registerFileProvidersTiled(LizardTechProvider.class); |
|
60 |
registerFormats(); |
|
61 |
|
|
62 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
|
63 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
|
64 |
dataman.registerStoreProvider(NAME, |
|
65 |
LizardTechProvider.class, LizardTechDataParameters.class); |
|
66 |
} |
|
67 |
|
|
68 |
if(DALFileLocator.getFilesystemServerExplorerManager() != null) |
|
69 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
|
70 |
NAME, DESCRIPTION, |
|
71 |
LizardTechFilesystemServerExplorer.class); |
|
72 |
|
|
73 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
|
74 |
} |
|
75 |
|
|
76 |
private static void registerFormats() { |
|
77 |
formatList = new String[] {"sid"}; |
|
78 |
for (int i = 0; i < formatList.length; i++) |
|
79 |
RasterLocator.getManager().getProviderServices().addFormat(formatList[i], LizardTechProvider.class); |
|
80 |
} |
|
81 |
|
|
82 |
public String[] getFormatList() { |
|
83 |
return formatList; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Returns true if the extension is supported and false if doesn't |
|
88 |
* @param ext |
|
89 |
* @return |
|
90 |
*/ |
|
91 |
public boolean isExtensionSupported(String ext) { |
|
92 |
if(ext.indexOf(".") != -1) |
|
93 |
ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length()); |
|
94 |
for (int i = 0; i < formatList.length; i++) { |
|
95 |
if(formatList[i].compareTo(ext) == 0) |
|
96 |
return true; |
|
97 |
} |
|
98 |
return false; |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Mandatory constructor to instantiate an empty provider |
|
103 |
*/ |
|
104 |
public LizardTechProvider() { |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Constructor. Abre el dataset. |
|
109 |
* @param proj Proyecci?n |
|
110 |
* @param fName Nombre del fichero ecw |
|
111 |
* @throws NotSupportedExtensionException |
|
112 |
*/ |
|
113 |
public LizardTechProvider(String params) throws NotSupportedExtensionException { |
|
114 |
super(params); |
|
115 |
if(params instanceof String) { |
|
116 |
LizardTechDataParameters p = new LizardTechDataParameters(); |
|
117 |
p.setURI((String)params); |
|
118 |
super.init(p, null, ToolsLocator.getDynObjectManager() |
|
119 |
.createDynObject( |
|
120 |
MetadataLocator.getMetadataManager().getDefinition( |
|
121 |
DataStore.METADATA_DEFINITION_NAME))); |
|
122 |
init(p, null); |
|
123 |
} |
|
124 |
} |
|
125 |
|
|
126 |
public LizardTechProvider(LizardTechDataParameters params, |
|
127 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException { |
|
128 |
super(params, storeServices, ToolsLocator.getDynObjectManager() |
|
129 |
.createDynObject( |
|
130 |
MetadataLocator.getMetadataManager().getDefinition( |
|
131 |
DataStore.METADATA_DEFINITION_NAME))); |
|
132 |
init(params, storeServices); |
|
133 |
} |
|
134 |
|
|
135 |
/** |
|
136 |
* Contructor. Abre el fichero mrsid |
|
137 |
* @param proj Proyecci?n |
|
138 |
* @param fName Nombre del fichero mrsid |
|
139 |
*/ |
|
140 |
public void init(AbstractRasterDataParameters params, |
|
141 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException { |
|
142 |
setParam(storeServices, params); |
|
143 |
try { |
|
144 |
file = new LizardTechNative(params.getURI()); |
|
145 |
load(); |
|
146 |
bandCount = file.nbands; |
|
147 |
int[] dt = new int[bandCount]; |
|
148 |
for (int i = 0; i < dt.length; i++) |
|
149 |
dt[i] = Buffer.TYPE_BYTE; |
|
150 |
setDataType(dt); |
|
151 |
super.init(); |
|
152 |
|
|
153 |
try { |
|
154 |
loadFromRmf(getRmfBlocksManager()); |
|
155 |
} catch (ParsingException e) { |
|
156 |
// No lee desde rmf |
|
157 |
} |
|
158 |
} catch (Exception e) { |
|
159 |
System.out.println("Error en constructor de MrSID"); |
|
160 |
e.printStackTrace(); |
|
161 |
file = null; |
|
162 |
} |
|
163 |
open = true; |
|
164 |
} |
|
165 |
|
|
166 |
public RasterProvider load() { |
|
167 |
ownTransformation = file.getOwnTransformation(); |
|
168 |
externalTransformation = (AffineTransform) ownTransformation.clone(); |
|
169 |
return this; |
|
170 |
} |
|
171 |
|
|
172 |
public boolean isOpen() { |
|
173 |
return open; |
|
174 |
} |
|
175 |
|
|
176 |
public void close() { |
|
177 |
if (file != null) { |
|
178 |
file.close(); |
|
179 |
file = null; |
|
180 |
} |
|
181 |
open = false; |
|
182 |
} |
|
183 |
|
|
184 |
public void setView(Extent e) { |
|
185 |
viewRequest = new ExtentImpl(e); |
|
186 |
} |
|
187 |
|
|
188 |
public Extent getView() { |
|
189 |
return viewRequest; |
|
190 |
} |
|
191 |
|
|
192 |
public double getWidth() { |
|
193 |
return file.width; |
|
194 |
} |
|
195 |
|
|
196 |
public double getHeight() { |
|
197 |
return file.height; |
|
198 |
} |
|
199 |
|
|
200 |
/** |
|
201 |
* Asigna al objeto Image los valores con los dato de la imagen contenidos en |
|
202 |
* el vector de enteros. |
|
203 |
* @param image imagen con los datos actuales |
|
204 |
* @param startX inicio de la posici?n en X dentro de la imagen |
|
205 |
* @param startY inicio de la posici?n en X dentro de la imagen |
|
206 |
* @param w Ancho de la imagen |
|
207 |
* @param h Alto de la imagen |
|
208 |
* @param rgbArray vector que contiene la banda que se va a sustituir |
|
209 |
* @param offset desplazamiento |
|
210 |
* @param scansize tama?o de imagen recorrida por cada p |
|
211 |
*/ |
|
212 |
protected void setRGBLine(BufferedImage image, int startX, int startY, int w, int h, |
|
213 |
int[] rgbArray, int offset, int scansize) { |
|
214 |
image.setRGB(startX, startY, w, h, rgbArray, offset, scansize); |
|
215 |
} |
|
216 |
|
|
217 |
public Object getData(int x, int y, int band) throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
218 |
if (file != null) { |
|
219 |
if (x < 0 || y < 0 || x >= file.width || y >= file.height) |
|
220 |
throw new InvalidSetViewException("Request out of grid"); |
|
221 |
Object[] data = file.getData(x, y); |
|
222 |
return data[band]; |
|
223 |
} |
|
224 |
throw new FileNotOpenException("MrSIDNative not exist"); |
|
225 |
} |
|
226 |
|
|
227 |
public int getBlockSize() { |
|
228 |
return file.blocksize; |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el |
|
233 |
* driver el que colocar? el valor de esta variable cada vez que dibuja. |
|
234 |
* @return true si se ha supersampleado y false si no se ha hecho. |
|
235 |
*/ |
|
236 |
public boolean isSupersampling() { |
|
237 |
return file.isSupersampling; |
|
238 |
} |
|
239 |
|
|
240 |
@Override |
|
241 |
public void loadBuffer(SpiRasterQuery query) |
|
242 |
throws ProcessInterruptedException, RasterDriverException { |
|
243 |
setView(query.getAdjustedRequestBoundingBox()); |
|
244 |
int width = query.getAdjustedBufWidth(); |
|
245 |
int height = query.getAdjustedBufHeight(); |
|
246 |
file.setView(viewRequest.getULX(), viewRequest.getULY(), viewRequest.getLRX(), viewRequest.getLRY(), width, height); |
|
247 |
|
|
248 |
int[] pRGBArray = new int[width * height]; |
|
249 |
|
|
250 |
try { |
|
251 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
|
252 |
file.readScene(pRGBArray, task); |
|
253 |
loadBuffer(height, |
|
254 |
width, |
|
255 |
query.getBandList(), |
|
256 |
query.getBufferForProviders(), |
|
257 |
pRGBArray); |
|
258 |
} catch (MrSIDException e) { |
|
259 |
throw new RasterDriverException("Error reading data"); |
|
260 |
} |
|
261 |
} |
|
262 |
|
|
263 |
// private void loadCachedBuffer( Buffer buf, |
|
264 |
// Extent inputWindow, |
|
265 |
// RasterTask task, |
|
266 |
// int[] pRGBArray, |
|
267 |
// BandList bandList) throws ProcessInterruptedException, MrSIDException { |
|
268 |
// if(buf.isCached()) { |
|
269 |
// Point2D blockHeightWC = rasterToWorld(new Point2D.Double(buf.getBlockHeight(), buf.getBlockHeight())); |
|
270 |
// int nBlocks = (int)(inputWindow.height() / blockHeightWC.getX()); |
|
271 |
// double lastblockWC = inputWindow.height() - (nBlocks * blockHeightWC.getX()); |
|
272 |
// int lastBlock = buf.getHeight() - (nBlocks * buf.getBlockHeight()); |
|
273 |
// if(lastblockWC > 0) |
|
274 |
// nBlocks ++; |
|
275 |
// double init = inputWindow.getULY(); |
|
276 |
// Extent ext = null; |
|
277 |
// for (int i = 0; i < nBlocks; i++) { |
|
278 |
// if(lastblockWC > 0 && i == (nBlocks - 1)) { |
|
279 |
// ext = RasterLocator.getManager().getDataStructFactory().createExtent( |
|
280 |
// inputWindow.getULX(), |
|
281 |
// init, |
|
282 |
// inputWindow.getLRX(), |
|
283 |
// lastblockWC); |
|
284 |
// file.setView(ext.getULX(), ext.getULY(), ext.getLRX(), ext.getLRY(), buf.getWidth(), buf.getBlockHeight()); |
|
285 |
// file.readScene(pRGBArray, task); |
|
286 |
// loadPartialBuffer(new int[]{0, i * buf.getBlockHeight(), buf.getWidth(), buf.getHeight() }, |
|
287 |
// bandList, |
|
288 |
// buf, |
|
289 |
// pRGBArray, |
|
290 |
// buf.getWidth()); |
|
291 |
// } else { |
|
292 |
// ext = RasterLocator.getManager().getDataStructFactory().createExtent( |
|
293 |
// inputWindow.getULX(), |
|
294 |
// init, |
|
295 |
// inputWindow.getLRX(), |
|
296 |
// init - blockHeightWC.getX()); |
|
297 |
// file.setView(ext.getULX(), ext.getULY(), ext.getLRX(), ext.getLRY(), buf.getWidth(), lastBlock); |
|
298 |
// file.readScene(pRGBArray, task); |
|
299 |
// loadPartialBuffer(new int[]{0, i * buf.getBlockHeight(), buf.getWidth(), i * buf.getBlockHeight() + buf.getBlockHeight() }, |
|
300 |
// bandList, |
|
301 |
// buf, |
|
302 |
// pRGBArray, |
|
303 |
// buf.getWidth()); |
|
304 |
// init += buf.getBlockHeight(); |
|
305 |
// } |
|
306 |
// } |
|
307 |
// } else { |
|
308 |
// file.setView(inputWindow.getULX(), inputWindow.getULY(), inputWindow.getLRX(), inputWindow.getLRY(), buf.getWidth(), buf.getHeight()); |
|
309 |
// file.readScene(pRGBArray, task); |
|
310 |
// loadBuffer(buf.getWidth(), buf.getHeight(), bandList, buf, pRGBArray); |
|
311 |
// } |
|
312 |
// } |
|
313 |
// |
|
314 |
// private void loadPartialBuffer(int[] stepBuffer, |
|
315 |
// BandList bandList, |
|
316 |
// Buffer rasterBuf, |
|
317 |
// int[] pRGBArray, |
|
318 |
// int bufWidth) throws ProcessInterruptedException { |
|
319 |
// RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
|
320 |
// int[] drawableBandsR = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 0); |
|
321 |
// int[] drawableBandsG = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 1); |
|
322 |
// int[] drawableBandsB = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 2); |
|
323 |
// int element = 0; |
|
324 |
// int rowSrc = 0; |
|
325 |
// |
|
326 |
// for (int row = stepBuffer[1]; row < stepBuffer[3]; row++) { |
|
327 |
// int colSrc = 0; |
|
328 |
// for (int col = stepBuffer[0]; col < stepBuffer[2]; col++) { |
|
329 |
// element = pRGBArray[(rowSrc * bufWidth) + colSrc]; |
|
330 |
// if(drawableBandsR != null) { |
|
331 |
// for (int i = 0; i < drawableBandsR.length; i++) { |
|
332 |
// if(drawableBandsR[i] >= 0 && drawableBandsR[i] < rasterBuf.getBandCount()) |
|
333 |
// rasterBuf.setElem(row, col, drawableBandsR[i], (byte) ((element & 0x00ff0000) >> 16)); |
|
334 |
// } |
|
335 |
// } |
|
336 |
// if(drawableBandsG != null) { |
|
337 |
// for (int i = 0; i < drawableBandsG.length; i++) { |
|
338 |
// if(drawableBandsG[i] >= 0 && drawableBandsG[i] < rasterBuf.getBandCount()) |
|
339 |
// rasterBuf.setElem(row, col, drawableBandsG[i], (byte) ((element & 0x0000ff00) >> 8)); |
|
340 |
// } |
|
341 |
// } |
|
342 |
// if(drawableBandsB != null) { |
|
343 |
// for (int i = 0; i < drawableBandsB.length; i++) { |
|
344 |
// if(drawableBandsB[i] >= 0 && drawableBandsB[i] < rasterBuf.getBandCount()) |
|
345 |
// rasterBuf.setElem(row, col, drawableBandsB[i], (byte) (element & 0x000000ff)); |
|
346 |
// } |
|
347 |
// } |
|
348 |
// colSrc ++; |
|
349 |
// } |
|
350 |
// if (task.getEvent() != null) |
|
351 |
// task.manageEvent(task.getEvent()); |
|
352 |
// rowSrc ++; |
|
353 |
// } |
|
354 |
// } |
|
355 |
|
|
356 |
private void loadBuffer(int h, int w, BandList bandList, Buffer rasterBuf, int[] pRGBArray) throws ProcessInterruptedException { |
|
357 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
|
358 |
int[] drawableBandsR = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 0); |
|
359 |
int[] drawableBandsG = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 1); |
|
360 |
int[] drawableBandsB = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 2); |
|
361 |
int element = 0; |
|
362 |
|
|
363 |
for (int row = 0; row < h; row++) { |
|
364 |
for (int col = 0; col < w; col++) { |
|
365 |
element = pRGBArray[(row * w) + col]; |
|
366 |
if(drawableBandsR != null) { |
|
367 |
for (int i = 0; i < drawableBandsR.length; i++) { |
|
368 |
if(drawableBandsR[i] >= 0 && drawableBandsR[i] < rasterBuf.getBandCount()) |
|
369 |
rasterBuf.setElem(row, col, drawableBandsR[i], (byte) ((element & 0x00ff0000) >> 16)); |
|
370 |
} |
|
371 |
} |
|
372 |
if(drawableBandsG != null) { |
|
373 |
for (int i = 0; i < drawableBandsG.length; i++) { |
|
374 |
if(drawableBandsG[i] >= 0 && drawableBandsG[i] < rasterBuf.getBandCount()) |
|
375 |
rasterBuf.setElem(row, col, drawableBandsG[i], (byte) ((element & 0x0000ff00) >> 8)); |
|
376 |
} |
|
377 |
} |
|
378 |
if(drawableBandsB != null) { |
|
379 |
for (int i = 0; i < drawableBandsB.length; i++) { |
|
380 |
if(drawableBandsB[i] >= 0 && drawableBandsB[i] < rasterBuf.getBandCount()) |
|
381 |
rasterBuf.setElem(row, col, drawableBandsB[i], (byte) (element & 0x000000ff)); |
|
382 |
} |
|
383 |
} |
|
384 |
} |
|
385 |
if (task.getEvent() != null) |
|
386 |
task.manageEvent(task.getEvent()); |
|
387 |
} |
|
388 |
} |
|
389 |
|
|
390 |
public Object readBlock(int pos, int blockHeight, double scale) throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException { |
|
391 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
|
392 |
|
|
393 |
if (pos < 0) |
|
394 |
throw new InvalidSetViewException("Request out of grid"); |
|
395 |
|
|
396 |
if ((pos + blockHeight) > file.height) |
|
397 |
blockHeight = Math.abs(file.height - pos); |
|
398 |
|
|
399 |
Point2D begin = rasterToWorld(new Point2D.Double(0, pos)); |
|
400 |
Point2D end = rasterToWorld(new Point2D.Double(file.width, pos + blockHeight)); |
|
401 |
|
|
402 |
int w = file.width; |
|
403 |
|
|
404 |
file.setView(begin.getX(), begin.getY(), end.getX(), end.getY(), w, blockHeight); |
|
405 |
|
|
406 |
int[] pRGBArray = new int[file.width * blockHeight]; |
|
407 |
try { |
|
408 |
file.readScene(pRGBArray, task); |
|
409 |
byte[][][] buf = new byte[3][blockHeight][w]; |
|
410 |
for (int row = 0; row < blockHeight; row++) { |
|
411 |
for (int col = 0; col < w; col++) { |
|
412 |
buf[0][row][col] = (byte) ((pRGBArray[(row * w) + col] & 0x00ff0000) >> 16); |
|
413 |
buf[1][row][col] = (byte) ((pRGBArray[(row * w) + col] & 0x0000ff00) >> 8); |
|
414 |
buf[2][row][col] = (byte) (pRGBArray[(row * w) + col] & 0x000000ff); |
|
415 |
} |
|
416 |
if (task.getEvent() != null) |
|
417 |
task.manageEvent(task.getEvent()); |
|
418 |
} |
|
419 |
return buf; |
|
420 |
} catch (MrSIDException e) { |
|
421 |
throw new RasterDriverException("Error reading data"); |
|
422 |
} |
|
423 |
} |
|
424 |
|
|
425 |
/** |
|
426 |
* Read a line from the file |
|
427 |
* @param line |
|
428 |
* @param band |
|
429 |
* @return |
|
430 |
* @throws InvalidSetViewException |
|
431 |
* @throws FileNotOpenException |
|
432 |
* @throws RasterDriverException |
|
433 |
* @Deprecated This operation is deprecated because is not useful and in the future |
|
434 |
* it will not be maintained. The abstract operation has dissapear |
|
435 |
*/ |
|
436 |
public Object readCompleteLine(int line, int band) |
|
437 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
438 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
|
439 |
|
|
440 |
if (line > this.getHeight() || band > this.getBandCount()) |
|
441 |
throw new InvalidSetViewException("Request out of grid"); |
|
442 |
|
|
443 |
try { |
|
444 |
Extent extent = getExtent(); |
|
445 |
Point2D pt = rasterToWorld(new Point2D.Double(extent.minX(), line)); |
|
446 |
file.setView(extent.minX(), pt.getY(), extent.maxX(), pt.getY(), (int)getWidth(), 1); |
|
447 |
int[] pRGBArray = new int[(int)getWidth()]; |
|
448 |
file.readScene(pRGBArray, task); |
|
449 |
return pRGBArray; |
|
450 |
} catch (MrSIDException e) { |
|
451 |
throw new RasterDriverException("Error reading data from MrSID library"); |
|
452 |
} catch (ProcessInterruptedException e) { |
|
453 |
// El proceso que debe ser interrumpido es el que llama a readLine. |
|
454 |
} |
|
455 |
return null; |
|
456 |
} |
|
457 |
|
|
458 |
public DataStoreTransparency getTransparency() { |
|
459 |
if (fileTransparency == null) |
|
460 |
fileTransparency = new DataStoreTransparency(getColorInterpretation()); |
|
461 |
return fileTransparency; |
|
462 |
} |
|
463 |
|
|
464 |
public DataStoreColorInterpretation getColorInterpretation() { |
|
465 |
if(colorInterpr == null) { |
|
466 |
colorInterpr = new DataStoreColorInterpretation(); |
|
467 |
colorInterpr.initColorInterpretation(getBandCount()); |
|
468 |
if(getBandCount() == 1) |
|
469 |
colorInterpr = DataStoreColorInterpretation.createGrayInterpretation(); |
|
470 |
if(getBandCount() == 3) { |
|
471 |
colorInterpr = DataStoreColorInterpretation.createRGBInterpretation(); |
|
472 |
} |
|
473 |
if(getBandCount() >= 4) { |
|
474 |
colorInterpr = DataStoreColorInterpretation.createRGBAInterpretation(); |
|
475 |
} |
|
476 |
} |
|
477 |
return colorInterpr; |
|
478 |
} |
|
479 |
|
|
480 |
public String getWktProjection() { |
|
481 |
// System.err.println("======>" + file); |
|
482 |
return null; |
|
483 |
} |
|
484 |
|
|
485 |
public void setAffineTransform(AffineTransform t) { |
|
486 |
super.setAffineTransform(t); |
|
487 |
file.setExternalTransform(t); |
|
488 |
} |
|
489 |
|
|
490 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
|
491 |
if (band >= getBandCount()) |
|
492 |
throw new BandAccessException("Wrong band"); |
|
493 |
try { |
|
494 |
return file.getNumLevels(); |
|
495 |
} catch (MrSIDException e) { |
|
496 |
throw new RasterDriverException(""); |
|
497 |
} |
|
498 |
} |
|
499 |
|
|
500 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
|
501 |
if (band >= getBandCount()) |
|
502 |
throw new BandAccessException("Wrong band"); |
|
503 |
return 0; |
|
504 |
} |
|
505 |
|
|
506 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
|
507 |
if (band >= getBandCount()) |
|
508 |
throw new BandAccessException("Wrong band"); |
|
509 |
return 0; |
|
510 |
} |
|
511 |
|
|
512 |
public boolean isOverviewsSupported() { |
|
513 |
// No podemos escribir por lo que no podemos informar de que soporta overviews aunque el formato si lo haga. |
|
514 |
return false; |
|
515 |
} |
|
516 |
|
|
517 |
public String getProviderName() { |
|
518 |
return NAME; |
|
519 |
} |
|
520 |
|
|
521 |
public void setStatus(RasterProvider provider) { |
|
522 |
if(provider instanceof LizardTechProvider) { |
|
523 |
//Not implemented yet |
|
524 |
} |
|
525 |
} |
|
526 |
|
|
527 |
public TileServer getTileServer() { |
|
528 |
if(tileServer == null) { |
|
529 |
DefaultRasterStore store = new DefaultRasterStore(); |
|
530 |
store.setProvider(this); |
|
531 |
tileServer = new FileTileServer(store); |
|
532 |
} |
|
533 |
return tileServer; |
|
534 |
} |
|
535 |
|
|
536 |
|
|
537 |
} |
|
0 | 538 |
org.gvsig.raster.lizardtech/tags/org.gvsig.raster.lizardtech-2.2.5/org.gvsig.raster.lizardtech.io/src/main/java/org/gvsig/raster/lizardtech/io/LizardTechFilesystemServerExplorer.java | ||
---|---|---|
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 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.raster.lizardtech.io; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
|
|
32 |
import org.gvsig.fmap.dal.DALLocator; |
|
33 |
import org.gvsig.fmap.dal.DataManager; |
|
34 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
35 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
36 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
38 |
import org.gvsig.fmap.dal.exception.CreateException; |
|
39 |
import org.gvsig.fmap.dal.exception.DataException; |
|
40 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
41 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider; |
|
42 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
|
43 |
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters; |
|
44 |
|
|
45 |
public class LizardTechFilesystemServerExplorer extends AbstractFilesystemServerExplorerProvider { |
|
46 |
|
|
47 |
/* |
|
48 |
* (non-Javadoc) |
|
49 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#canCreate() |
|
50 |
*/ |
|
51 |
public boolean canCreate() { |
|
52 |
return false; |
|
53 |
} |
|
54 |
|
|
55 |
/* |
|
56 |
* (non-Javadoc) |
|
57 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#canCreate(org.gvsig.fmap.dal.NewDataStoreParameters) |
|
58 |
*/ |
|
59 |
public boolean canCreate(NewDataStoreParameters parameters) { |
|
60 |
return false; |
|
61 |
} |
|
62 |
|
|
63 |
/* |
|
64 |
* (non-Javadoc) |
|
65 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#create(org.gvsig.fmap.dal.NewDataStoreParameters, boolean) |
|
66 |
*/ |
|
67 |
public void create(NewDataStoreParameters parameters, boolean overwrite) |
|
68 |
throws CreateException { |
|
69 |
throw new UnsupportedOperationException(); |
|
70 |
} |
|
71 |
|
|
72 |
/* |
|
73 |
* (non-Javadoc) |
|
74 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#getCreateParameters() |
|
75 |
*/ |
|
76 |
public NewDataStoreParameters getCreateParameters() throws DataException { |
|
77 |
return null; |
|
78 |
} |
|
79 |
|
|
80 |
/* |
|
81 |
* (non-Javadoc) |
|
82 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#initialize(org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices) |
|
83 |
*/ |
|
84 |
public void initialize( |
|
85 |
FilesystemServerExplorerProviderServices serverExplorer) { |
|
86 |
} |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider#remove(org.gvsig.fmap.dal.DataStoreParameters) |
|
91 |
*/ |
|
92 |
public void remove(DataStoreParameters parameters) throws RemoveException { |
|
93 |
throw new UnsupportedOperationException(); |
|
94 |
} |
|
95 |
|
|
96 |
/* |
|
97 |
* (non-Javadoc) |
|
98 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter#getDataStoreProviderName() |
|
99 |
*/ |
|
100 |
public String getDataStoreProviderName() { |
|
101 |
return LizardTechProvider.NAME; |
|
102 |
} |
|
103 |
|
|
104 |
/* |
|
105 |
* (non-Javadoc) |
|
106 |
* @see java.io.FileFilter#accept(java.io.File) |
|
107 |
*/ |
|
108 |
public boolean accept(File pathname) { |
|
109 |
return RasterLocator.getManager().getProviderServices().isExtensionSupported( |
|
110 |
pathname.getAbsolutePath(), |
|
111 |
LizardTechProvider.class); |
|
112 |
} |
|
113 |
|
|
114 |
/* |
|
115 |
* (non-Javadoc) |
|
116 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter#getDescription() |
|
117 |
*/ |
|
118 |
public String getDescription() { |
|
119 |
return LizardTechProvider.DESCRIPTION; |
|
120 |
} |
|
121 |
|
|
122 |
public DataStoreParameters getParameters(File file) throws DataException { |
|
123 |
DataManager manager = DALLocator.getDataManager(); |
|
124 |
AbstractRasterFileDataParameters params = (AbstractRasterFileDataParameters) manager |
|
125 |
.createStoreParameters(this.getDataStoreProviderName()); |
|
126 |
params.setFile(file); |
|
127 |
return params; |
|
128 |
} |
|
129 |
|
|
130 |
public int getMode() { |
|
131 |
return DataServerExplorer.MODE_RASTER; |
|
132 |
} |
|
133 |
|
|
134 |
} |
|
0 | 135 |
org.gvsig.raster.lizardtech/tags/org.gvsig.raster.lizardtech-2.2.5/org.gvsig.raster.lizardtech.io/src/main/java/org/gvsig/raster/lizardtech/io/LizardTechDataParameters.java | ||
---|---|---|
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 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.raster.lizardtech.io; |
|
29 |
|
|
30 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
|
31 |
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
34 |
import org.gvsig.tools.dynobject.DynStruct; |
|
35 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
36 |
|
|
37 |
/** |
|
38 |
* Parameters for the Gdal provider |
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
40 |
*/ |
|
41 |
public class LizardTechDataParameters extends AbstractRasterFileDataParameters { |
|
42 |
|
|
43 |
public LizardTechDataParameters() { |
|
44 |
initialize(); |
|
45 |
} |
|
46 |
|
|
47 |
protected void initialize() { |
|
48 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator |
|
49 |
.getDynObjectManager().createDynObject( |
|
50 |
registerDynClass()); |
|
51 |
} |
|
52 |
|
|
53 |
public String getDataStoreName() { |
|
54 |
return LizardTechProvider.NAME; |
|
55 |
} |
|
56 |
|
|
57 |
public String getDescription() { |
|
58 |
return LizardTechProvider.DESCRIPTION; |
|
59 |
} |
|
60 |
|
|
61 |
public static DynStruct registerDynClass() { |
|
62 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
Also available in: Unified diff