Revision 2215 org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/provider/fusion/FirstFusionMethod.java

View differences:

FirstFusionMethod.java
1 1
package org.gvsig.raster.impl.provider.fusion;
2 2

  
3
import java.awt.geom.Rectangle2D;
4
import java.util.ArrayList;
5
import java.util.List;
6

  
7
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
8
import org.gvsig.raster.impl.datastruct.ExtentImpl;
9
import org.gvsig.raster.impl.provider.fusion.BufferListFusion.PixelSquareStructure;
10

  
3 11
public class FirstFusionMethod extends AbstractFusionMethod {
12
	protected SubSquareList     subSquareList = null;
13
	protected byte[]            dataByte      = null;
14
	protected short[]           dataShort     = null;
15
	protected int[]             dataInt       = null;
16
	protected float[]           dataFloat     = null;
17
	protected double[]          dataDouble    = null;
4 18
	
5
	public FirstFusionMethod() {
19
	public class SubSquareList extends ArrayList<SubSquare> {
20
		private static final long serialVersionUID = 1L;
21
		private int[]             coords           = new int[2];
6 22
		
23
		public void getByteValue(int row, int col, byte[] data) {
24
			for (int i = 0; i < size(); i++) {
25
				if(get(i).isInside(row, col)) {
26
					get(i).loadLocalCoords(row, col, coords);
27
					get(i).getBuffer().getElemByte(coords[0], coords[1], data);
28
					return;
29
				}
30
			}
31
		}
32
		
33
		public void getFloatValue(int row, int col, float[] data) {
34
			for (int i = 0; i < size(); i++) {
35
				if(get(i).isInside(row, col)) {
36
					get(i).loadLocalCoords(row, col, coords);
37
					get(i).getBuffer().getElemFloat(coords[0], coords[1], data);
38
					return;
39
				}
40
			}
41
		}
7 42
	}
8

  
9
	public byte getByteValue(int row, int col, int band) {
10
		// TODO Auto-generated method stub
11
		return 0;
43
	
44
	public FirstFusionMethod(
45
			List<Buffer> bufferList, 
46
			PixelSquareStructure pxSquare) {
47
		super(pxSquare);
48
		switch (pxSquare.dataType) {
49
		case Buffer.TYPE_BYTE:
50
			dataByte = new byte[pxSquare.bandCount];
51
			break;
52
		case Buffer.TYPE_SHORT:
53
			dataShort = new short[pxSquare.bandCount];
54
			break;
55
		case Buffer.TYPE_INT:
56
			dataInt = new int[pxSquare.bandCount];
57
			break;
58
		case Buffer.TYPE_FLOAT:
59
			dataFloat = new float[pxSquare.bandCount];
60
			break;
61
		case Buffer.TYPE_DOUBLE:
62
			dataDouble = new double[pxSquare.bandCount];
63
			break;
64
		}
65
		
66
		subSquareList = new SubSquareList();
67
		for (int i = 0; i < bufferList.size(); i++) {
68
			SubSquare square = new SubSquare(
69
					pxSquare.bbox, 
70
					new Rectangle2D.Double(0, 0, pxSquare.width, pxSquare.height),
71
					new ExtentImpl(bufferList.get(i).getDataExtent()),
72
					new Rectangle2D.Double(0, 0, bufferList.get(i).getWidth(), bufferList.get(i).getHeight()),
73
					bufferList.get(i));
74
			subSquareList.add(square);
75
		}
12 76
	}
77
	
78
	public byte[] getByteValue(int row, int col) {
79
		for (int i = 0; i < dataByte.length; i++) {
80
			dataByte[i] = pxSquare.nodata.getValue().byteValue();
81
		}
82
		subSquareList.getByteValue(row, col, dataByte);
83
		return dataByte;
84
	}
13 85

  
14
	public float getFloatValue(int row, int col, int band) {
15
		// TODO Auto-generated method stub
16
		return 0;
86
	public float[] getFloatValue(int row, int col) {
87
		for (int i = 0; i < dataFloat.length; i++) {
88
			dataFloat[i] = pxSquare.nodata.getValue().byteValue();
89
		}
90
		subSquareList.getFloatValue(row, col, dataFloat);
91
		return dataFloat;
17 92
	}
18 93

  
19 94
}

Also available in: Unified diff