Revision 11207 trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/MemoryRasterDriver.java

View differences:

MemoryRasterDriver.java
599 599
		}
600 600
		return null;
601 601
	}
602

  
603
	/*
604
	 *  (non-Javadoc)
605
	 * @see org.gvsig.raster.dataset.RasterDataset#readBlock(int, int)
606
	 */
607
	public Object readBlock(int pos, int blockHeight) throws InvalidSetViewException, FileNotOpenException, RasterDriverException {
608
		if(pos < 0)
609
			throw new InvalidSetViewException("Request out of grid");
610
		
611
		if((pos + blockHeight) > buffer.getHeight())
612
			blockHeight = Math.abs(buffer.getHeight() - pos);
613
		
614
		switch(buffer.getDataType()){
615
		case IBuffer.TYPE_BYTE:
616
			byte[][][] bufb = new byte[getBandCount()][][];
617
			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
618
				for (int row = 0; row < blockHeight; row++) {
619
					bufb[iBand][row] = buffer.getLineFromBandByte(row, iBand);
620
				}	
621
			}
622
			return bufb;
623
		case IBuffer.TYPE_SHORT:
624
			short[][][] bufs = new short[getBandCount()][][];
625
			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
626
				for (int row = 0; row < blockHeight; row++) {
627
					bufs[iBand][row] = buffer.getLineFromBandShort(row, iBand);
628
				}	
629
			}
630
			return bufs;
631
		case IBuffer.TYPE_INT:
632
			int[][][] bufi = new int[getBandCount()][][];
633
			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
634
				for (int row = 0; row < blockHeight; row++) {
635
					bufi[iBand][row] = buffer.getLineFromBandInt(row, iBand);
636
				}	
637
			}
638
			return bufi;
639
		case IBuffer.TYPE_FLOAT: 
640
			float[][][] buff = new float[getBandCount()][][];
641
			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
642
				for (int row = 0; row < blockHeight; row++) {
643
					buff[iBand][row] = buffer.getLineFromBandFloat(row, iBand);
644
				}	
645
			}
646
			return buff;
647
		case IBuffer.TYPE_DOUBLE: 
648
			double[][][] bufd = new double[getBandCount()][][];
649
			for (int iBand = 0; iBand < buffer.getBandCount(); iBand++) {
650
				for (int row = 0; row < blockHeight; row++) {
651
					bufd[iBand][row] = buffer.getLineFromBandDouble(row, iBand);
652
				}	
653
			}
654
			return bufd;
655
		}
656
		return null;
657
	}
602 658
	
603 659
}
604 660

  

Also available in: Unified diff