Revision 27445 trunk/extensions/extSextanteGvsigBindings/src/es/unex/sextante/gvsig/core/RasterMemoryDriver.java
RasterMemoryDriver.java | ||
---|---|---|
32 | 32 |
private GridExtent m_GridExtent; |
33 | 33 |
private IBuffer buf = null; |
34 | 34 |
private String name = null; |
35 |
|
|
35 |
|
|
36 | 36 |
public RasterMemoryDriver(GridExtent ge, int iDataType, int iNumBands) { |
37 | 37 |
|
38 | 38 |
super(); |
... | ... | |
86 | 86 |
|
87 | 87 |
public void setCellValue(int x, int y, int iBand, double dValue){ |
88 | 88 |
|
89 |
if (isInGrid(x,y) && iBand < buf.getBandCount()){ |
|
90 |
if(buf.getDataType() == RasterBuffer.TYPE_BYTE){ |
|
91 |
buf.setElem(y, x, iBand, (byte)dValue); |
|
92 |
}else if(buf.getDataType() == RasterBuffer.TYPE_SHORT){ |
|
93 |
buf.setElem(y, x, iBand, (short)dValue); |
|
94 |
}else if(buf.getDataType() == RasterBuffer.TYPE_INT){ |
|
95 |
buf.setElem(y, x, iBand, (int)dValue); |
|
96 |
}else if(buf.getDataType() == RasterBuffer.TYPE_FLOAT){ |
|
97 |
buf.setElem(y, x, iBand, (float)dValue); |
|
98 |
}else if(buf.getDataType() == RasterBuffer.TYPE_DOUBLE){ |
|
99 |
buf.setElem(y, x, iBand, (double)dValue); |
|
89 |
try{ |
|
90 |
if (isInGrid(x,y) && iBand < buf.getBandCount()){ |
|
91 |
if(buf.getDataType() == RasterBuffer.TYPE_BYTE){ |
|
92 |
buf.setElem(y, x, iBand, (byte)dValue); |
|
93 |
}else if(buf.getDataType() == RasterBuffer.TYPE_SHORT){ |
|
94 |
buf.setElem(y, x, iBand, (short)dValue); |
|
95 |
}else if(buf.getDataType() == RasterBuffer.TYPE_INT){ |
|
96 |
buf.setElem(y, x, iBand, (int)dValue); |
|
97 |
}else if(buf.getDataType() == RasterBuffer.TYPE_FLOAT){ |
|
98 |
buf.setElem(y, x, iBand, (float)dValue); |
|
99 |
}else if(buf.getDataType() == RasterBuffer.TYPE_DOUBLE){ |
|
100 |
buf.setElem(y, x, iBand, (double)dValue); |
|
101 |
} |
|
100 | 102 |
} |
103 |
} catch (InterruptedException e) { |
|
104 |
// FIXME hablar con Nacho!!! |
|
105 |
e.printStackTrace(); |
|
101 | 106 |
} |
102 | 107 |
|
108 |
|
|
103 | 109 |
} |
104 | 110 |
|
105 | 111 |
public double getNoDataValue(){ |
... | ... | |
123 | 129 |
|
124 | 130 |
public double getCellValue(int x, int y, int iBand){ |
125 | 131 |
|
126 |
if (isInGrid(x,y)){ |
|
127 |
int iDataType = buf.getDataType(); |
|
128 |
if (iDataType == RasterBuffer.TYPE_DOUBLE) { |
|
129 |
return buf.getElemDouble(y, x, iBand); |
|
130 |
} else if (iDataType == RasterBuffer.TYPE_INT) { |
|
131 |
return (double) buf.getElemInt(y, x, iBand); |
|
132 |
} else if (iDataType == RasterBuffer.TYPE_FLOAT) { |
|
133 |
return (double) buf.getElemFloat(y, x, iBand); |
|
134 |
} else if (iDataType == RasterBuffer.TYPE_BYTE) { |
|
135 |
return (double) buf.getElemByte(y, x, iBand); |
|
136 |
} else if ((iDataType == RasterBuffer.TYPE_SHORT) | (iDataType == RasterBuffer.TYPE_USHORT)) { |
|
137 |
return (double) buf.getElemShort(y, x, iBand); |
|
138 |
} |
|
132 |
try { |
|
133 |
if (isInGrid(x,y)){ |
|
134 |
int iDataType = buf.getDataType(); |
|
135 |
if (iDataType == RasterBuffer.TYPE_DOUBLE) { |
|
136 |
return buf.getElemDouble(y, x, iBand); |
|
137 |
} else if (iDataType == RasterBuffer.TYPE_INT) { |
|
138 |
return (double) buf.getElemInt(y, x, iBand); |
|
139 |
} else if (iDataType == RasterBuffer.TYPE_FLOAT) { |
|
140 |
return (double) buf.getElemFloat(y, x, iBand); |
|
141 |
} else if (iDataType == RasterBuffer.TYPE_BYTE) { |
|
142 |
return (double) buf.getElemByte(y, x, iBand); |
|
143 |
} else if ((iDataType == RasterBuffer.TYPE_SHORT) | (iDataType == RasterBuffer.TYPE_USHORT)) { |
|
144 |
return (double) buf.getElemShort(y, x, iBand); |
|
145 |
} |
|
146 |
} |
|
147 |
} catch (InterruptedException e) { |
|
148 |
// FIXME hablar con Nacho!!! |
|
149 |
e.printStackTrace(); |
|
139 | 150 |
} |
140 | 151 |
|
152 |
|
|
141 | 153 |
return getNoDataValue(); |
142 | 154 |
|
143 | 155 |
} |
... | ... | |
265 | 277 |
new Dimension(m_GridExtent.getNX(),m_GridExtent.getNY()));*/ |
266 | 278 |
Params params = GeoRasterWriter.getWriter(sFilename).getParams(); |
267 | 279 |
AffineTransform affineTransform = new AffineTransform(m_GridExtent.getCellSize(), 0, 0, -m_GridExtent.getCellSize(), m_GridExtent.getXMin(), m_GridExtent.getYMax()); |
268 |
GeoRasterWriter writer = GeoRasterWriter.getWriter(writerBufferServer,
|
|
269 |
sFilename,
|
|
280 |
GeoRasterWriter writer = GeoRasterWriter.getWriter(writerBufferServer, |
|
281 |
sFilename, |
|
270 | 282 |
buf.getBandCount(), |
271 | 283 |
affineTransform, |
272 | 284 |
m_GridExtent.getNX(), |
... | ... | |
288 | 300 |
public void setName(String name) { |
289 | 301 |
this.name = name; |
290 | 302 |
} |
291 |
|
|
303 |
|
|
292 | 304 |
public String getName() { |
293 | 305 |
return this.name; |
294 | 306 |
} |
Also available in: Unified diff