Revision 11207 trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/GdalNative.java
GdalNative.java | ||
---|---|---|
552 | 552 |
return null; |
553 | 553 |
} |
554 | 554 |
|
555 |
/** |
|
556 |
* Lee una bloque completo del raster y devuelve un array tridimensional del tipo correcto. Esta funci?n es util |
|
557 |
* para una lectura rapida de todo el fichero sin necesidad de asignar vista. |
|
558 |
* @param nLine N?mero de l?nea a leer |
|
559 |
* @param band Banda requerida |
|
560 |
* @return Object que es un array unidimendional del tipo de datos del raster |
|
561 |
* @throws GdalException |
|
562 |
*/ |
|
563 |
public Object readBlock(int pos, int blockHeight) throws GdalException { |
|
564 |
bBandNr = super.getRasterCount(); |
|
565 |
int nX = getRasterXSize(); |
|
566 |
|
|
567 |
GdalRasterBand[] gdalBand = new GdalRasterBand[bBandNr]; |
|
568 |
for (int iBand = 0; iBand < gdalBand.length; iBand++) { |
|
569 |
gdalBand[iBand] = super.getRasterBand(iBand + 1); |
|
570 |
} |
|
571 |
|
|
572 |
GdalBuffer[] gdalBuf = new GdalBuffer[bBandNr]; |
|
573 |
|
|
574 |
if (dataType == GDT_Byte) { |
|
575 |
byte[][][] buf = new byte[bBandNr][blockHeight][getRasterXSize()]; |
|
576 |
for (int iBand = 0; iBand < gdalBuf.length; iBand++) { |
|
577 |
gdalBuf[iBand] = gdalBand[iBand].readRaster(0, pos, nX, blockHeight, nX, blockHeight, dataType); |
|
578 |
for (int iRow = 0; iRow < blockHeight; iRow++) |
|
579 |
for (int iCol = 0; iCol < nX; iCol++) |
|
580 |
buf[iBand][iRow][iCol] = gdalBuf[iBand].buffByte[iRow * nX + iCol]; |
|
581 |
} |
|
582 |
return buf; |
|
583 |
} else if (dataType == GDT_CInt16 || dataType == GDT_Int16 || dataType == GDT_UInt16) { |
|
584 |
short[][][] buf = new short[bBandNr][blockHeight][getRasterXSize()]; |
|
585 |
for (int iBand = 0; iBand < gdalBuf.length; iBand++) { |
|
586 |
gdalBuf[iBand] = gdalBand[iBand].readRaster(0, pos, nX, blockHeight, nX, blockHeight, dataType); |
|
587 |
for (int iRow = 0; iRow < blockHeight; iRow++) |
|
588 |
for (int iCol = 0; iCol < nX; iCol++) |
|
589 |
buf[iBand][iRow][iCol] = gdalBuf[iBand].buffShort[iRow * nX + iCol]; |
|
590 |
} |
|
591 |
return buf; |
|
592 |
} else if (dataType == GDT_CInt32 || dataType == GDT_Int32 || dataType == GDT_UInt32) { |
|
593 |
int[][][] buf = new int[bBandNr][blockHeight][getRasterXSize()]; |
|
594 |
for (int iBand = 0; iBand < gdalBuf.length; iBand++) { |
|
595 |
gdalBuf[iBand] = gdalBand[iBand].readRaster(0, pos, nX, blockHeight, nX, blockHeight, dataType); |
|
596 |
for (int iRow = 0; iRow < blockHeight; iRow++) |
|
597 |
for (int iCol = 0; iCol < nX; iCol++) |
|
598 |
buf[iBand][iRow][iCol] = gdalBuf[iBand].buffInt[iRow * nX + iCol];; |
|
599 |
} |
|
600 |
return buf; |
|
601 |
} else if(dataType == GDT_Float32 || dataType == GDT_CFloat32) { |
|
602 |
float[][][] buf = new float[bBandNr][blockHeight][getRasterXSize()]; |
|
603 |
for (int iBand = 0; iBand < gdalBuf.length; iBand++) { |
|
604 |
gdalBuf[iBand] = gdalBand[iBand].readRaster(0, pos, nX, blockHeight, nX, blockHeight, dataType); |
|
605 |
for (int iRow = 0; iRow < blockHeight; iRow++) |
|
606 |
for (int iCol = 0; iCol < nX; iCol++) |
|
607 |
buf[iBand][iRow][iCol] = gdalBuf[iBand].buffFloat[iRow * nX + iCol];; |
|
608 |
} |
|
609 |
return buf; |
|
610 |
} else if(dataType == GDT_Float64 || dataType == GDT_CFloat64) { |
|
611 |
double[][][] buf = new double[bBandNr][blockHeight][getRasterXSize()]; |
|
612 |
for (int iBand = 0; iBand < gdalBuf.length; iBand++) { |
|
613 |
gdalBuf[iBand] = gdalBand[iBand].readRaster(0, pos, nX, blockHeight, nX, blockHeight, dataType); |
|
614 |
for (int iRow = 0; iRow < blockHeight; iRow++) |
|
615 |
for (int iCol = 0; iCol < nX; iCol++) |
|
616 |
buf[iBand][iRow][iCol] = gdalBuf[iBand].buffDouble[iRow * nX + iCol];; |
|
617 |
} |
|
618 |
return buf; |
|
619 |
} |
|
620 |
|
|
621 |
return null; |
|
622 |
} |
|
623 |
|
|
555 | 624 |
public void readLine(Object line) throws GdalException { |
556 | 625 |
int w = (int) (Math.ceil(((double)currentViewWidth)*stepX) + 1); |
557 | 626 |
int x = (int) (currentViewX); |
Also available in: Unified diff