Revision 11207 trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/EcwDriver.java
EcwDriver.java | ||
---|---|---|
573 | 573 |
} |
574 | 574 |
|
575 | 575 |
/* |
576 |
* (non-Javadoc) |
|
577 |
* @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int, int) |
|
578 |
*/ |
|
579 |
public Object readBlock(int pos, int blockHeight) throws InvalidSetViewException, FileNotOpenException, RasterDriverException { |
|
580 |
if(pos < 0) |
|
581 |
throw new InvalidSetViewException("Request out of grid"); |
|
582 |
|
|
583 |
if((pos + blockHeight) > file.height) |
|
584 |
blockHeight = Math.abs(file.height - pos); |
|
585 |
|
|
586 |
Point2D begin = rasterToWorld(new Point2D.Double(0, pos)); |
|
587 |
Point2D end = rasterToWorld(new Point2D.Double(file.width, pos + blockHeight)); |
|
588 |
int[] readBandsFromECW = new int[file.numBands]; |
|
589 |
|
|
590 |
for(int i = 0; i < file.numBands; i++) |
|
591 |
readBandsFromECW[i] = i; |
|
592 |
|
|
593 |
byte[][][] buf = new byte[file.numBands][blockHeight][file.width]; |
|
594 |
Extent e = new Extent(begin.getX(), begin.getY(), end.getX(), end.getY()); |
|
595 |
|
|
596 |
try { |
|
597 |
int[] value = new int[file.width]; |
|
598 |
file.setView(file.numBands, readBandsFromECW, e.minX(), e.maxY(), e.maxX(), e.minY(), file.width, 1); |
|
599 |
|
|
600 |
if(file.numBands <= 3) { |
|
601 |
for (int row = 0; row < blockHeight; row++) { |
|
602 |
file.readLineRGBA(value); |
|
603 |
switch(getDataType()) { |
|
604 |
case IBuffer.TYPE_BYTE: |
|
605 |
for(int col = 0; col < file.width; col ++) { |
|
606 |
buf[0][row][col] = (byte)(((value[col] & 0x00ff0000) >> 16) & 0xff); |
|
607 |
buf[1][row][col] = (byte)(((value[col] & 0x0000ff00) >> 8) & 0xff); |
|
608 |
buf[2][row][col] = (byte)((value[col] & 0x000000ff) & 0xff); |
|
609 |
} |
|
610 |
break; |
|
611 |
} |
|
612 |
} |
|
613 |
} else { |
|
614 |
//TODO: FUNCIONALIDAD: file.numBands > 3 |
|
615 |
} |
|
616 |
|
|
617 |
//TODO: FUNCIONALIDAD: Ecw con otro tipo de dato != Byte |
|
618 |
} catch (JNCSFileNotOpenException e1) { |
|
619 |
throw new FileNotOpenException("Error en jecw: JNCSFileNotOpenException"); |
|
620 |
} catch (JNCSInvalidSetViewException e1) { |
|
621 |
throw new FileNotOpenException("Error en jecw: JNCSInvalidSetViewException"); |
|
622 |
} catch (JNCSException e1) { |
|
623 |
throw new RasterDriverException("Error la lectura de datos ecw"); |
|
624 |
} |
|
625 |
|
|
626 |
return buf; |
|
627 |
} |
|
628 |
|
|
629 |
/* |
|
576 | 630 |
* (non-Javadoc) |
577 | 631 |
* @see org.gvsig.raster.driver.RasterDataset#getData(int, int, int) |
578 | 632 |
*/ |
Also available in: Unified diff