gvsig-raster / org.gvsig.raster.lizardtech / trunk / org.gvsig.raster.lizardtech / org.gvsig.raster.lizardtech.io / src / main / java / org / gvsig / raster / lizardtech / io / LizardTechProvider.java @ 4181
History | View | Annotate | Download (20.5 KB)
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 |
import java.io.File; |
7 |
import java.net.URI; |
8 |
import java.net.URISyntaxException; |
9 |
|
10 |
import es.gva.cit.jmrsid.MrSIDException; |
11 |
|
12 |
import org.slf4j.Logger; |
13 |
import org.slf4j.LoggerFactory; |
14 |
|
15 |
import org.gvsig.fmap.dal.DALFileLocator; |
16 |
import org.gvsig.fmap.dal.DALLocator; |
17 |
import org.gvsig.fmap.dal.DataStore; |
18 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
19 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
20 |
import org.gvsig.fmap.dal.coverage.datastruct.BandList; |
21 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
22 |
import org.gvsig.fmap.dal.coverage.exception.BandAccessException; |
23 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
24 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
25 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
26 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
27 |
import org.gvsig.fmap.dal.coverage.exception.ParsingException; |
28 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
29 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
30 |
import org.gvsig.fmap.dal.exception.OpenException; |
31 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
32 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
33 |
import org.gvsig.metadata.MetadataLocator; |
34 |
import org.gvsig.raster.cache.tile.provider.TileServer; |
35 |
import org.gvsig.raster.impl.buffer.SpiRasterQuery; |
36 |
import org.gvsig.raster.impl.datastruct.ExtentImpl; |
37 |
import org.gvsig.raster.impl.process.RasterTask; |
38 |
import org.gvsig.raster.impl.process.RasterTaskQueue; |
39 |
import org.gvsig.raster.impl.provider.AbstractRasterProvider; |
40 |
import org.gvsig.raster.impl.provider.RasterProvider; |
41 |
import org.gvsig.raster.impl.provider.tile.FileTileServer; |
42 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
43 |
import org.gvsig.raster.impl.store.DefaultRasterStore; |
44 |
import org.gvsig.raster.impl.store.DefaultStoreFactory; |
45 |
import org.gvsig.raster.impl.store.properties.DataStoreColorInterpretation; |
46 |
import org.gvsig.raster.impl.store.properties.DataStoreTransparency; |
47 |
import org.gvsig.tools.ToolsLocator; |
48 |
/**
|
49 |
* Clase encargada del acceso a los datos y repintado de imagenes MrSID. Estos
|
50 |
* son registrados con la extensi?n sid
|
51 |
*
|
52 |
* @version 15/05/2008
|
53 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
54 |
*/
|
55 |
public class LizardTechProvider extends AbstractRasterProvider { |
56 |
private static final Logger logger = LoggerFactory.getLogger(LizardTechProvider.class); |
57 |
|
58 |
public static String NAME = "LizardTech Store"; |
59 |
public static String DESCRIPTION = "LizardTech Raster file"; |
60 |
public static final String METADATA_DEFINITION_NAME = "LizardTechStore"; |
61 |
protected LizardTechNative lztNative = null; |
62 |
private Extent viewRequest = null; |
63 |
private DataStoreColorInterpretation colorInterpr = null; |
64 |
protected DataStoreTransparency fileTransparency = null; |
65 |
private boolean open = false; |
66 |
protected static String[] formatList = null; |
67 |
|
68 |
public static void register() { |
69 |
RasterLocator.getManager().getProviderServices().registerFileProvidersTiled(LizardTechProvider.class); |
70 |
registerFormats(); |
71 |
|
72 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager(); |
73 |
if (dataman != null && !dataman.getStoreProviders().contains(NAME)) { |
74 |
dataman.registerStoreProvider(NAME, |
75 |
LizardTechProvider.class, LizardTechDataParameters.class); |
76 |
} |
77 |
|
78 |
if(DALFileLocator.getFilesystemServerExplorerManager() != null) |
79 |
DALFileLocator.getFilesystemServerExplorerManager().registerProvider( |
80 |
NAME, DESCRIPTION, |
81 |
LizardTechFilesystemServerExplorer.class); |
82 |
|
83 |
dataman.registerStoreFactory(NAME, DefaultStoreFactory.class); |
84 |
} |
85 |
|
86 |
private static void registerFormats() { |
87 |
formatList = new String[] {"sid"}; |
88 |
for (int i = 0; i < formatList.length; i++) |
89 |
RasterLocator.getManager().getProviderServices().addFormat(formatList[i], LizardTechProvider.class); |
90 |
} |
91 |
|
92 |
public String[] getFormatList() { |
93 |
return formatList;
|
94 |
} |
95 |
|
96 |
/**
|
97 |
* Returns true if the extension is supported and false if doesn't
|
98 |
* @param ext
|
99 |
* @return
|
100 |
*/
|
101 |
public boolean isExtensionSupported(String ext) { |
102 |
if(ext.indexOf(".") != -1) |
103 |
ext = ext.substring(ext.lastIndexOf(".") + 1, ext.length()); |
104 |
for (int i = 0; i < formatList.length; i++) { |
105 |
if(formatList[i].compareTo(ext) == 0) |
106 |
return true; |
107 |
} |
108 |
return false; |
109 |
} |
110 |
|
111 |
/**
|
112 |
* Mandatory constructor to instantiate an empty provider
|
113 |
*/
|
114 |
public LizardTechProvider() {
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* Constructor. Abre el dataset.
|
119 |
* @param proj Proyecci?n
|
120 |
* @param fName Nombre del fichero ecw
|
121 |
* @throws NotSupportedExtensionException
|
122 |
* @throws OpenException
|
123 |
* @deprecated use {@link #LizardTechProvider(URI)}, this constructor will be removed in gvSIG 2.5
|
124 |
*/
|
125 |
public LizardTechProvider(String params) throws NotSupportedExtensionException, OpenException { |
126 |
super(params);
|
127 |
logger.info("Deprecated use of LizardTechProvider constructor");
|
128 |
if(params instanceof String) { |
129 |
LizardTechDataParameters p = new LizardTechDataParameters();
|
130 |
URI uriObj;
|
131 |
try {
|
132 |
uriObj = new URI((String)params); |
133 |
} catch (URISyntaxException e) { |
134 |
throw new OpenException("Can't create uri from "+(String)params, e); |
135 |
} |
136 |
p.setURI(uriObj); |
137 |
super.init(p, null, ToolsLocator.getDynObjectManager() |
138 |
.createDynObject( |
139 |
MetadataLocator.getMetadataManager().getDefinition( |
140 |
DataStore.METADATA_DEFINITION_NAME))); |
141 |
init(p, null);
|
142 |
} |
143 |
} |
144 |
|
145 |
/**
|
146 |
* Constructor. Abre el dataset.
|
147 |
* @param proj Proyecci?n
|
148 |
* @param fName Nombre del fichero ecw
|
149 |
* @throws NotSupportedExtensionException
|
150 |
*/
|
151 |
public LizardTechProvider(URI uri) throws NotSupportedExtensionException { |
152 |
super(uri);
|
153 |
LizardTechDataParameters p = new LizardTechDataParameters();
|
154 |
p.setURI(uri); |
155 |
super.init(
|
156 |
p, |
157 |
null,
|
158 |
ToolsLocator.getDynObjectManager().createDynObject( |
159 |
MetadataLocator.getMetadataManager().getDefinition(DataStore.METADATA_DEFINITION_NAME))); |
160 |
init(p, null);
|
161 |
} |
162 |
|
163 |
public LizardTechProvider(LizardTechDataParameters params,
|
164 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
|
165 |
super(params, storeServices, ToolsLocator.getDynObjectManager()
|
166 |
.createDynObject( |
167 |
MetadataLocator.getMetadataManager().getDefinition( |
168 |
DataStore.METADATA_DEFINITION_NAME))); |
169 |
init(params, storeServices); |
170 |
} |
171 |
|
172 |
/**
|
173 |
* Contructor. Abre el fichero mrsid
|
174 |
* @param proj Proyecci?n
|
175 |
* @param fName Nombre del fichero mrsid
|
176 |
*/
|
177 |
public void init(AbstractRasterDataParameters params, |
178 |
DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
|
179 |
setParam(storeServices, params); |
180 |
try {
|
181 |
lztNative = new LizardTechNative(params.getURI().getPath());
|
182 |
load(); |
183 |
bandCount = lztNative.nbands; |
184 |
int[] dt = new int[bandCount]; |
185 |
for (int i = 0; i < dt.length; i++) |
186 |
dt[i] = Buffer.TYPE_BYTE;
|
187 |
setDataType(dt); |
188 |
super.init();
|
189 |
|
190 |
try {
|
191 |
loadFromRmf(getRmfBlocksManager()); |
192 |
} catch (ParsingException e) {
|
193 |
// No lee desde rmf
|
194 |
} |
195 |
} catch (Exception e) { |
196 |
System.out.println("Error en constructor de MrSID"); |
197 |
e.printStackTrace(); |
198 |
lztNative = null;
|
199 |
} |
200 |
open = true;
|
201 |
} |
202 |
|
203 |
public RasterProvider load() {
|
204 |
ownTransformation = lztNative.getOwnTransformation(); |
205 |
externalTransformation = (AffineTransform) ownTransformation.clone();
|
206 |
return this; |
207 |
} |
208 |
|
209 |
public boolean isOpen() { |
210 |
return open;
|
211 |
} |
212 |
|
213 |
public void close() { |
214 |
if (lztNative != null) { |
215 |
lztNative.close(); |
216 |
lztNative = null;
|
217 |
} |
218 |
open = false;
|
219 |
} |
220 |
|
221 |
public void setView(Extent e) { |
222 |
viewRequest = new ExtentImpl(e);
|
223 |
} |
224 |
|
225 |
public Extent getView() {
|
226 |
return viewRequest;
|
227 |
} |
228 |
|
229 |
public double getWidth() { |
230 |
return lztNative.width;
|
231 |
} |
232 |
|
233 |
public double getHeight() { |
234 |
return lztNative.height;
|
235 |
} |
236 |
|
237 |
/**
|
238 |
* Asigna al objeto Image los valores con los dato de la imagen contenidos en
|
239 |
* el vector de enteros.
|
240 |
* @param image imagen con los datos actuales
|
241 |
* @param startX inicio de la posici?n en X dentro de la imagen
|
242 |
* @param startY inicio de la posici?n en X dentro de la imagen
|
243 |
* @param w Ancho de la imagen
|
244 |
* @param h Alto de la imagen
|
245 |
* @param rgbArray vector que contiene la banda que se va a sustituir
|
246 |
* @param offset desplazamiento
|
247 |
* @param scansize tama?o de imagen recorrida por cada p
|
248 |
*/
|
249 |
protected void setRGBLine(BufferedImage image, int startX, int startY, int w, int h, |
250 |
int[] rgbArray, int offset, int scansize) { |
251 |
image.setRGB(startX, startY, w, h, rgbArray, offset, scansize); |
252 |
} |
253 |
|
254 |
public Object getData(int x, int y, int band) throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
255 |
if (lztNative != null) { |
256 |
if (x < 0 || y < 0 || x >= lztNative.width || y >= lztNative.height) |
257 |
throw new InvalidSetViewException("Request out of grid"); |
258 |
Object[] data = lztNative.getData(x, y); |
259 |
return data[band];
|
260 |
} |
261 |
throw new FileNotOpenException("MrSIDNative not exist"); |
262 |
} |
263 |
|
264 |
public int getBlockSize() { |
265 |
return lztNative.blocksize;
|
266 |
} |
267 |
|
268 |
/**
|
269 |
* Informa de si el driver ha supersampleado en el ?ltimo dibujado. Es el
|
270 |
* driver el que colocar? el valor de esta variable cada vez que dibuja.
|
271 |
* @return true si se ha supersampleado y false si no se ha hecho.
|
272 |
*/
|
273 |
public boolean isSupersampling() { |
274 |
return lztNative.isSupersampling;
|
275 |
} |
276 |
|
277 |
@Override
|
278 |
public void loadBuffer(SpiRasterQuery query) |
279 |
throws ProcessInterruptedException, RasterDriverException {
|
280 |
setView(query.getAdjustedRequestBoundingBox()); |
281 |
int width = query.getAdjustedBufWidth();
|
282 |
int height = query.getAdjustedBufHeight();
|
283 |
lztNative.setView(viewRequest.getULX(), viewRequest.getULY(), viewRequest.getLRX(), viewRequest.getLRY(), width, height); |
284 |
|
285 |
int[] pRGBArray = new int[width * height]; |
286 |
|
287 |
try {
|
288 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
289 |
lztNative.readScene(pRGBArray, task); |
290 |
loadBuffer(height, |
291 |
width, |
292 |
query.getBandList(), |
293 |
query.getBufferForProviders(), |
294 |
pRGBArray); |
295 |
} catch (MrSIDException e) {
|
296 |
throw new RasterDriverException("Error reading data"); |
297 |
} |
298 |
} |
299 |
|
300 |
// private void loadCachedBuffer( Buffer buf,
|
301 |
// Extent inputWindow,
|
302 |
// RasterTask task,
|
303 |
// int[] pRGBArray,
|
304 |
// BandList bandList) throws ProcessInterruptedException, MrSIDException {
|
305 |
// if(buf.isCached()) {
|
306 |
// Point2D blockHeightWC = rasterToWorld(new Point2D.Double(buf.getBlockHeight(), buf.getBlockHeight()));
|
307 |
// int nBlocks = (int)(inputWindow.height() / blockHeightWC.getX());
|
308 |
// double lastblockWC = inputWindow.height() - (nBlocks * blockHeightWC.getX());
|
309 |
// int lastBlock = buf.getHeight() - (nBlocks * buf.getBlockHeight());
|
310 |
// if(lastblockWC > 0)
|
311 |
// nBlocks ++;
|
312 |
// double init = inputWindow.getULY();
|
313 |
// Extent ext = null;
|
314 |
// for (int i = 0; i < nBlocks; i++) {
|
315 |
// if(lastblockWC > 0 && i == (nBlocks - 1)) {
|
316 |
// ext = RasterLocator.getManager().getDataStructFactory().createExtent(
|
317 |
// inputWindow.getULX(),
|
318 |
// init,
|
319 |
// inputWindow.getLRX(),
|
320 |
// lastblockWC);
|
321 |
// file.setView(ext.getULX(), ext.getULY(), ext.getLRX(), ext.getLRY(), buf.getWidth(), buf.getBlockHeight());
|
322 |
// file.readScene(pRGBArray, task);
|
323 |
// loadPartialBuffer(new int[]{0, i * buf.getBlockHeight(), buf.getWidth(), buf.getHeight() },
|
324 |
// bandList,
|
325 |
// buf,
|
326 |
// pRGBArray,
|
327 |
// buf.getWidth());
|
328 |
// } else {
|
329 |
// ext = RasterLocator.getManager().getDataStructFactory().createExtent(
|
330 |
// inputWindow.getULX(),
|
331 |
// init,
|
332 |
// inputWindow.getLRX(),
|
333 |
// init - blockHeightWC.getX());
|
334 |
// file.setView(ext.getULX(), ext.getULY(), ext.getLRX(), ext.getLRY(), buf.getWidth(), lastBlock);
|
335 |
// file.readScene(pRGBArray, task);
|
336 |
// loadPartialBuffer(new int[]{0, i * buf.getBlockHeight(), buf.getWidth(), i * buf.getBlockHeight() + buf.getBlockHeight() },
|
337 |
// bandList,
|
338 |
// buf,
|
339 |
// pRGBArray,
|
340 |
// buf.getWidth());
|
341 |
// init += buf.getBlockHeight();
|
342 |
// }
|
343 |
// }
|
344 |
// } else {
|
345 |
// file.setView(inputWindow.getULX(), inputWindow.getULY(), inputWindow.getLRX(), inputWindow.getLRY(), buf.getWidth(), buf.getHeight());
|
346 |
// file.readScene(pRGBArray, task);
|
347 |
// loadBuffer(buf.getWidth(), buf.getHeight(), bandList, buf, pRGBArray);
|
348 |
// }
|
349 |
// }
|
350 |
//
|
351 |
// private void loadPartialBuffer(int[] stepBuffer,
|
352 |
// BandList bandList,
|
353 |
// Buffer rasterBuf,
|
354 |
// int[] pRGBArray,
|
355 |
// int bufWidth) throws ProcessInterruptedException {
|
356 |
// RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + "");
|
357 |
// int[] drawableBandsR = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 0);
|
358 |
// int[] drawableBandsG = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 1);
|
359 |
// int[] drawableBandsB = bandList.getBufferBandToDraw(getURIOfFirstProvider(), 2);
|
360 |
// int element = 0;
|
361 |
// int rowSrc = 0;
|
362 |
//
|
363 |
// for (int row = stepBuffer[1]; row < stepBuffer[3]; row++) {
|
364 |
// int colSrc = 0;
|
365 |
// for (int col = stepBuffer[0]; col < stepBuffer[2]; col++) {
|
366 |
// element = pRGBArray[(rowSrc * bufWidth) + colSrc];
|
367 |
// if(drawableBandsR != null) {
|
368 |
// for (int i = 0; i < drawableBandsR.length; i++) {
|
369 |
// if(drawableBandsR[i] >= 0 && drawableBandsR[i] < rasterBuf.getBandCount())
|
370 |
// rasterBuf.setElem(row, col, drawableBandsR[i], (byte) ((element & 0x00ff0000) >> 16));
|
371 |
// }
|
372 |
// }
|
373 |
// if(drawableBandsG != null) {
|
374 |
// for (int i = 0; i < drawableBandsG.length; i++) {
|
375 |
// if(drawableBandsG[i] >= 0 && drawableBandsG[i] < rasterBuf.getBandCount())
|
376 |
// rasterBuf.setElem(row, col, drawableBandsG[i], (byte) ((element & 0x0000ff00) >> 8));
|
377 |
// }
|
378 |
// }
|
379 |
// if(drawableBandsB != null) {
|
380 |
// for (int i = 0; i < drawableBandsB.length; i++) {
|
381 |
// if(drawableBandsB[i] >= 0 && drawableBandsB[i] < rasterBuf.getBandCount())
|
382 |
// rasterBuf.setElem(row, col, drawableBandsB[i], (byte) (element & 0x000000ff));
|
383 |
// }
|
384 |
// }
|
385 |
// colSrc ++;
|
386 |
// }
|
387 |
// if (task.getEvent() != null)
|
388 |
// task.manageEvent(task.getEvent());
|
389 |
// rowSrc ++;
|
390 |
// }
|
391 |
// }
|
392 |
|
393 |
private void loadBuffer(int h, int w, BandList bandList, Buffer rasterBuf, int[] pRGBArray) throws ProcessInterruptedException { |
394 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
395 |
int[] drawableBandsR = bandList.getBufferBandToDraw(getURIOfFirstProvider().getPath(), 0); |
396 |
int[] drawableBandsG = bandList.getBufferBandToDraw(getURIOfFirstProvider().getPath(), 1); |
397 |
int[] drawableBandsB = bandList.getBufferBandToDraw(getURIOfFirstProvider().getPath(), 2); |
398 |
int element = 0; |
399 |
|
400 |
for (int row = 0; row < h; row++) { |
401 |
for (int col = 0; col < w; col++) { |
402 |
element = pRGBArray[(row * w) + col]; |
403 |
if(drawableBandsR != null) { |
404 |
for (int i = 0; i < drawableBandsR.length; i++) { |
405 |
if(drawableBandsR[i] >= 0 && drawableBandsR[i] < rasterBuf.getBandCount()) |
406 |
rasterBuf.setElem(row, col, drawableBandsR[i], (byte) ((element & 0x00ff0000) >> 16)); |
407 |
} |
408 |
} |
409 |
if(drawableBandsG != null) { |
410 |
for (int i = 0; i < drawableBandsG.length; i++) { |
411 |
if(drawableBandsG[i] >= 0 && drawableBandsG[i] < rasterBuf.getBandCount()) |
412 |
rasterBuf.setElem(row, col, drawableBandsG[i], (byte) ((element & 0x0000ff00) >> 8)); |
413 |
} |
414 |
} |
415 |
if(drawableBandsB != null) { |
416 |
for (int i = 0; i < drawableBandsB.length; i++) { |
417 |
if(drawableBandsB[i] >= 0 && drawableBandsB[i] < rasterBuf.getBandCount()) |
418 |
rasterBuf.setElem(row, col, drawableBandsB[i], (byte) (element & 0x000000ff)); |
419 |
} |
420 |
} |
421 |
} |
422 |
if (task.getEvent() != null) |
423 |
task.manageEvent(task.getEvent()); |
424 |
} |
425 |
} |
426 |
|
427 |
public Object readBlock(int pos, int blockHeight, double scale) throws InvalidSetViewException, FileNotOpenException, RasterDriverException, ProcessInterruptedException { |
428 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
429 |
|
430 |
if (pos < 0) |
431 |
throw new InvalidSetViewException("Request out of grid"); |
432 |
|
433 |
if ((pos + blockHeight) > lztNative.height)
|
434 |
blockHeight = Math.abs(lztNative.height - pos);
|
435 |
|
436 |
Point2D begin = rasterToWorld(new Point2D.Double(0, pos)); |
437 |
Point2D end = rasterToWorld(new Point2D.Double(lztNative.width, pos + blockHeight)); |
438 |
|
439 |
int w = lztNative.width;
|
440 |
|
441 |
lztNative.setView(begin.getX(), begin.getY(), end.getX(), end.getY(), w, blockHeight); |
442 |
|
443 |
int[] pRGBArray = new int[lztNative.width * blockHeight]; |
444 |
try {
|
445 |
lztNative.readScene(pRGBArray, task); |
446 |
byte[][][] buf = new byte[3][blockHeight][w]; |
447 |
for (int row = 0; row < blockHeight; row++) { |
448 |
for (int col = 0; col < w; col++) { |
449 |
buf[0][row][col] = (byte) ((pRGBArray[(row * w) + col] & 0x00ff0000) >> 16); |
450 |
buf[1][row][col] = (byte) ((pRGBArray[(row * w) + col] & 0x0000ff00) >> 8); |
451 |
buf[2][row][col] = (byte) (pRGBArray[(row * w) + col] & 0x000000ff); |
452 |
} |
453 |
if (task.getEvent() != null) |
454 |
task.manageEvent(task.getEvent()); |
455 |
} |
456 |
return buf;
|
457 |
} catch (MrSIDException e) {
|
458 |
throw new RasterDriverException("Error reading data"); |
459 |
} |
460 |
} |
461 |
|
462 |
/**
|
463 |
* Read a line from the file
|
464 |
* @param line
|
465 |
* @param band
|
466 |
* @return
|
467 |
* @throws InvalidSetViewException
|
468 |
* @throws FileNotOpenException
|
469 |
* @throws RasterDriverException
|
470 |
* @Deprecated This operation is deprecated because is not useful and in the future
|
471 |
* it will not be maintained. The abstract operation has dissapear
|
472 |
*/
|
473 |
public Object readCompleteLine(int line, int band) |
474 |
throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
|
475 |
RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + ""); |
476 |
|
477 |
if (line > this.getHeight() || band > this.getBandCount()) |
478 |
throw new InvalidSetViewException("Request out of grid"); |
479 |
|
480 |
try {
|
481 |
Extent extent = getExtent(); |
482 |
Point2D pt = rasterToWorld(new Point2D.Double(extent.minX(), line)); |
483 |
lztNative.setView(extent.minX(), pt.getY(), extent.maxX(), pt.getY(), (int)getWidth(), 1); |
484 |
int[] pRGBArray = new int[(int)getWidth()]; |
485 |
lztNative.readScene(pRGBArray, task); |
486 |
return pRGBArray;
|
487 |
} catch (MrSIDException e) {
|
488 |
throw new RasterDriverException("Error reading data from MrSID library"); |
489 |
} catch (ProcessInterruptedException e) {
|
490 |
// El proceso que debe ser interrumpido es el que llama a readLine.
|
491 |
} |
492 |
return null; |
493 |
} |
494 |
|
495 |
public DataStoreTransparency getTransparency() {
|
496 |
if (fileTransparency == null) |
497 |
fileTransparency = new DataStoreTransparency(getColorInterpretation());
|
498 |
return fileTransparency;
|
499 |
} |
500 |
|
501 |
public DataStoreColorInterpretation getColorInterpretation() {
|
502 |
if(colorInterpr == null) { |
503 |
colorInterpr = new DataStoreColorInterpretation();
|
504 |
colorInterpr.initColorInterpretation(getBandCount()); |
505 |
if(getBandCount() == 1) |
506 |
colorInterpr = DataStoreColorInterpretation.createGrayInterpretation(); |
507 |
if(getBandCount() == 3) { |
508 |
colorInterpr = DataStoreColorInterpretation.createRGBInterpretation(); |
509 |
} |
510 |
if(getBandCount() >= 4) { |
511 |
colorInterpr = DataStoreColorInterpretation.createRGBAInterpretation(); |
512 |
} |
513 |
} |
514 |
return colorInterpr;
|
515 |
} |
516 |
|
517 |
public String getWktProjection() { |
518 |
// System.err.println("======>" + file);
|
519 |
return null; |
520 |
} |
521 |
|
522 |
public void setAffineTransform(AffineTransform t) { |
523 |
super.setAffineTransform(t);
|
524 |
lztNative.setExternalTransform(t); |
525 |
} |
526 |
|
527 |
public int getOverviewCount(int band) throws BandAccessException, RasterDriverException { |
528 |
if (band >= getBandCount())
|
529 |
throw new BandAccessException("Wrong band"); |
530 |
try {
|
531 |
return lztNative.getNumLevels();
|
532 |
} catch (MrSIDException e) {
|
533 |
throw new RasterDriverException(""); |
534 |
} |
535 |
} |
536 |
|
537 |
public int getOverviewWidth(int band, int overview) throws BandAccessException, RasterDriverException { |
538 |
if (band >= getBandCount())
|
539 |
throw new BandAccessException("Wrong band"); |
540 |
return 0; |
541 |
} |
542 |
|
543 |
public int getOverviewHeight(int band, int overview) throws BandAccessException, RasterDriverException { |
544 |
if (band >= getBandCount())
|
545 |
throw new BandAccessException("Wrong band"); |
546 |
return 0; |
547 |
} |
548 |
|
549 |
public boolean isOverviewsSupported() { |
550 |
// No podemos escribir por lo que no podemos informar de que soporta overviews aunque el formato si lo haga.
|
551 |
return false; |
552 |
} |
553 |
|
554 |
public String getProviderName() { |
555 |
return NAME;
|
556 |
} |
557 |
|
558 |
public void setStatus(RasterProvider provider) { |
559 |
if(provider instanceof LizardTechProvider) { |
560 |
//Not implemented yet
|
561 |
} |
562 |
} |
563 |
|
564 |
public TileServer getTileServer() {
|
565 |
if(tileServer == null) { |
566 |
DefaultRasterStore store = new DefaultRasterStore();
|
567 |
store.setProvider(this);
|
568 |
tileServer = new FileTileServer(store);
|
569 |
} |
570 |
return tileServer;
|
571 |
} |
572 |
|
573 |
public void addFile(File file) throws InvalidSourceException { |
574 |
// Do nothing
|
575 |
} |
576 |
|
577 |
public void removeFile(File file) { |
578 |
// Do nothing
|
579 |
} |
580 |
|
581 |
|
582 |
} |