Revision 10982
branches/v10/libraries/libCq_CMS_praster/src/org/cresques/io/data/Grid.java | ||
---|---|---|
27 | 27 |
import org.cresques.px.Extent; |
28 | 28 |
import org.cresques.px.PxRaster; |
29 | 29 |
import org.cresques.util.Utilities; |
30 |
import org.cresques.filter.IRaster; |
|
30 | 31 |
|
31 | 32 |
public class Grid implements IQueryableRaster, IWritableRaster { |
32 | 33 |
|
... | ... | |
232 | 233 |
double wcXEnd = (maxX > grmf.getExtent().maxX()) ? grmf.getExtent().maxX() : maxX; |
233 | 234 |
double wcYEnd = (minY < grmf.getExtent().minY()) ? grmf.getExtent().minY() : minY; |
234 | 235 |
|
235 |
rasterBuf = grmf.getWindowRaster(wcXInit, wcYInit, wcXEnd, wcYEnd, (int)Math.abs(endPxX - initPxX), (int)Math.abs(endPxY - initPxY)); |
|
236 |
int copyX = (int)Math.abs(endPxX - initPxX); |
|
237 |
int copyY = (int)Math.abs(endPxY - initPxY); |
|
236 | 238 |
|
239 |
rasterBuf = grmf.getWindowRaster(wcXInit, wcYEnd, wcXEnd, wcYInit, copyX, copyY); |
|
237 | 240 |
RasterBuf buf = new RasterBuf(rasterBuf.getDataType(), bufWidth, bufHeight, rasterBuf.getBandCount(), true); |
241 |
buf.setNoDataValue(m_dNoDataValue); |
|
238 | 242 |
buf.setToNoData(); |
239 |
for (int iBand = 0; iBand < rasterBuf.getBandCount(); iBand++) |
|
240 |
for (int row = 0; row < rasterBuf.getHeight(); row++) |
|
241 |
for (int col = 0; col < rasterBuf.getWidth(); col++) |
|
242 |
buf.setElemByte((int)(row + initPxY), (int)(col + initPxX), |
|
243 |
iBand, |
|
244 |
rasterBuf.getElemByte(row, col, iBand)); |
|
243 |
|
|
244 |
switch(rasterBuf.getDataType()) { |
|
245 |
case IRaster.TYPE_BYTE: |
|
246 |
for (int iBand = 0; iBand < rasterBuf.getBandCount(); iBand++) |
|
247 |
for (int row = 0; row < copyY; row++) |
|
248 |
for (int col = 0; col < copyX; col++) |
|
249 |
buf.setElemByte((int)(row + initPxY), (int)(col + initPxX), |
|
250 |
iBand, |
|
251 |
rasterBuf.getElemByte(row, col, iBand)); |
|
252 |
break; |
|
253 |
case IRaster.TYPE_SHORT: |
|
254 |
case IRaster.TYPE_USHORT: |
|
255 |
for (int iBand = 0; iBand < rasterBuf.getBandCount(); iBand++) |
|
256 |
for (int row = 0; row < copyY; row++) |
|
257 |
for (int col = 0; col < copyX; col++) |
|
258 |
buf.setElemShort((int)(row + initPxY), (int)(col + initPxX), |
|
259 |
iBand, |
|
260 |
rasterBuf.getElemShort(row, col, iBand)); |
|
261 |
break; |
|
262 |
case IRaster.TYPE_INT: |
|
263 |
for (int iBand = 0; iBand < rasterBuf.getBandCount(); iBand++) |
|
264 |
for (int row = 0; row < copyY; row++) |
|
265 |
for (int col = 0; col < copyX; col++) |
|
266 |
buf.setElemInt((int)(row + initPxY), (int)(col + initPxX), |
|
267 |
iBand, |
|
268 |
rasterBuf.getElemInt(row, col, iBand)); |
|
269 |
break; |
|
270 |
case IRaster.TYPE_FLOAT: |
|
271 |
for (int iBand = 0; iBand < rasterBuf.getBandCount(); iBand++) |
|
272 |
for (int row = 0; row < copyY; row++) |
|
273 |
for (int col = 0; col < copyX; col++) |
|
274 |
buf.setElemFloat((int)(row + initPxY), (int)(col + initPxX), |
|
275 |
iBand, |
|
276 |
rasterBuf.getElemFloat(row, col, iBand)); |
|
277 |
break; |
|
278 |
case IRaster.TYPE_DOUBLE: |
|
279 |
for (int iBand = 0; iBand < rasterBuf.getBandCount(); iBand++) |
|
280 |
for (int row = 0; row < copyY; row++) |
|
281 |
for (int col = 0; col < copyX; col++) |
|
282 |
buf.setElemDouble((int)(row + initPxY), (int)(col + initPxX), |
|
283 |
iBand, |
|
284 |
rasterBuf.getElemDouble(row, col, iBand)); |
|
285 |
break; |
|
286 |
} |
|
245 | 287 |
rasterBuf = buf; |
246 | 288 |
return null; |
247 | 289 |
|
Also available in: Unified diff