Revision 20829
trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/mosaic/process/MosaicProcess.java | ||
---|---|---|
92 | 92 |
int codOp= 0; |
93 | 93 |
|
94 | 94 |
// indicador de proceso |
95 |
int percent=0; |
|
95 |
int percent=0, proceso=0;
|
|
96 | 96 |
|
97 | 97 |
// PROVISIONAL -para cargar capa en vista- |
98 | 98 |
private View view = null; |
... | ... | |
120 | 120 |
numbands= getIntParam("numbands"); |
121 | 121 |
fileName = getStringParam("filename"); |
122 | 122 |
|
123 |
// PROVISIONAL |
|
124 | 123 |
view = (View)getParam("vista"); |
125 | 124 |
// Calculo del extend resultante |
126 | 125 |
fullExtend= calculateExtend(layers); |
... | ... | |
159 | 158 |
bufferFactory.setAdjustToExtent(false); |
160 | 159 |
if (!RasterBuffer.loadInMemory(dsetCopy)) |
161 | 160 |
bufferFactory.setReadOnly(true); |
162 |
bufferFactory.setDrawableBands(((FLyrRasterSE)layers.getLayer(i)).getRenderBands()); |
|
161 |
// Si pongo solo las renderizadas en algunos casos da problemas |
|
162 |
bufferFactory.setAllDrawableBands(); |
|
163 | 163 |
bufferFactory.setAreaOfInterest(minX,minY,maxX,maxY,fullExtend.getNX(),fullExtend.getNY()); |
164 | 164 |
buffers[i]= (RasterBuffer) bufferFactory.getRasterBuf(); |
165 | 165 |
percent=(int)((i+1)*100/layers.getLayersCount()); |
166 |
|
|
166 | 167 |
|
167 | 168 |
} |
168 | 169 |
}catch (RasterDriverException e) { |
... | ... | |
173 | 174 |
Thread.currentThread().interrupt(); |
174 | 175 |
} |
175 | 176 |
|
177 |
proceso=1; |
|
176 | 178 |
|
177 | 179 |
// Construccion del mosaico: Operaci?n M?ximo |
178 | 180 |
if(codOp==0){ |
... | ... | |
260 | 262 |
} |
261 | 263 |
} |
262 | 264 |
|
265 |
// Se liberan los buffers |
|
266 |
for(int i=0; i<layers.getLayersCount();i++) |
|
267 |
buffers[i].free(); |
|
268 |
|
|
263 | 269 |
// Escritura en fichero |
270 |
proceso=2; |
|
264 | 271 |
writeToFile(); |
265 |
// writeToFile((RasterBuffer)buffers[0],1); |
|
266 |
// writeToFile((RasterBuffer)buffers[1],2); |
|
272 |
|
|
267 | 273 |
} |
268 | 274 |
|
269 | 275 |
|
... | ... | |
277 | 283 |
public void setValueMax(int x, int y, int band){ |
278 | 284 |
byte result=-128; |
279 | 285 |
for(int buf=0;buf<buffers.length;buf++){ |
280 |
byte data = (byte)(buffers[buf].getElemByte(y,x,band)); |
|
286 |
byte data = (byte)(buffers[buf].getElemByte(y,x,band)&0xff);
|
|
281 | 287 |
// TO DO: TENER EN CUENTA NODATA REAL DEL BUFER |
282 |
if(data==97)
|
|
288 |
if(data==(byte)mosaicGrid.getNoDataValue())
|
|
283 | 289 |
data=-128; |
284 | 290 |
result=(byte) Math.max((byte)result,(byte)data); |
285 | 291 |
} |
286 | 292 |
try { |
287 | 293 |
mosaicGrid.setCellValue(x,y,(byte)result); |
288 |
result=-128; |
|
289 | 294 |
} catch (OutOfGridException e) { |
290 | 295 |
e.printStackTrace(); |
291 | 296 |
} |
... | ... | |
303 | 308 |
for(int buf=0;buf<buffers.length;buf++){ |
304 | 309 |
byte data = (byte)(buffers[buf].getElemByte(y,x,band)&0xff); |
305 | 310 |
// TO DO: TENER EN CUENTA NO DATA |
306 |
if(data==97)
|
|
311 |
if(data==(byte)mosaicGrid.getNoDataValue())
|
|
307 | 312 |
data=127; |
308 | 313 |
result=(byte) Math.min((byte)result,(byte)data); |
309 | 314 |
} |
... | ... | |
329 | 334 |
for(int buf=0;buf<buffers.length;buf++){ |
330 | 335 |
int data = (int)((byte)(buffers[buf].getElemByte(y,x,band))); |
331 | 336 |
// TO DO: TENER EN CUENTA NODATA REAL DEL BUFER |
332 |
if(data==97){
|
|
337 |
if(data==(byte)mosaicGrid.getNoDataValue()){
|
|
333 | 338 |
buffTotales--; |
334 | 339 |
data =0; |
335 | 340 |
} |
... | ... | |
360 | 365 |
for(int buf=0;buf<buffers.length;buf++){ |
361 | 366 |
result = (byte)(buffers[buf].getElemByte(y,x,band)); |
362 | 367 |
// TO DO : Valor no data del buffer |
363 |
if(result!=97)
|
|
368 |
if(result!=(byte)mosaicGrid.getNoDataValue())
|
|
364 | 369 |
break; |
365 | 370 |
} |
366 | 371 |
|
... | ... | |
386 | 391 |
for(int buf=0;buf<buffers.length;buf++){ |
387 | 392 |
result = (byte)(buffers[buf].getElemByte(y,x,band)); |
388 | 393 |
// TO DO : Valor no data del buffer |
389 |
if(result!=97)
|
|
394 |
if(result!=(byte)mosaicGrid.getNoDataValue())
|
|
390 | 395 |
break; |
391 | 396 |
} |
392 | 397 |
|
... | ... | |
406 | 411 |
* */ |
407 | 412 |
|
408 | 413 |
private GridExtent calculateExtend (FLayers layers){ |
414 |
|
|
409 | 415 |
GridExtent result= null; |
416 |
IRasterDataSource dsetCopy = null; |
|
417 |
double cellSize=0; |
|
418 |
double minX=0,maxX=0,minY=0,maxY=0; |
|
419 |
try { |
|
410 | 420 |
|
411 |
double minX=0,maxX=0,minY=0,maxY=0, cellSize=25; |
|
412 |
try { |
|
421 |
// Se obtiene el tama?o de celda mayor |
|
422 |
for(int i=0; i< layers.getLayersCount();i++) |
|
423 |
{ |
|
424 |
dsetCopy = ((FLyrRasterSE)layers.getLayer(i)).getDataSource().newDataset(); |
|
425 |
BufferFactory bufferFactory = new BufferFactory(dsetCopy); |
|
426 |
bufferFactory.setAdjustToExtent(false); |
|
427 |
if (!RasterBuffer.loadInMemory(dsetCopy)) |
|
428 |
bufferFactory.setReadOnly(true); |
|
429 |
Grid grid= new Grid(bufferFactory); |
|
430 |
cellSize= Math.max(cellSize,grid.getCellSize()); |
|
431 |
} |
|
413 | 432 |
|
414 | 433 |
minX = layers.getLayer(0).getFullExtent().getMinX(); |
415 | 434 |
minY = layers.getLayer(0).getFullExtent().getMinY(); |
... | ... | |
417 | 436 |
maxY = layers.getLayer(0).getFullExtent().getMaxY(); |
418 | 437 |
|
419 | 438 |
for(int i=1; i<layers.getLayersCount();i++){ |
439 |
|
|
420 | 440 |
minX= Math.min(minX,layers.getLayer(i).getFullExtent().getMinX()); |
421 | 441 |
minY= Math.min(minY,layers.getLayer(i).getFullExtent().getMinY()); |
422 | 442 |
maxX= Math.max(maxX,layers.getLayer(i).getFullExtent().getMaxX()); |
... | ... | |
427 | 447 |
e.printStackTrace(); |
428 | 448 |
} catch (ReadDriverException e) { |
429 | 449 |
e.printStackTrace(); |
450 |
} catch (RasterBufferInvalidException e) { |
|
451 |
// TODO Auto-generated catch block |
|
452 |
e.printStackTrace(); |
|
430 | 453 |
} |
431 | 454 |
|
432 | 455 |
result = new GridExtent(minX,minY,maxX,maxY,cellSize); |
... | ... | |
449 | 472 |
grw.dataWrite(); |
450 | 473 |
grw.setWkt((String)((FLyrRasterSE)layers.getLayer(0)).getWktProjection()); |
451 | 474 |
grw.writeClose(); |
452 |
|
|
475 |
mosaicGrid.getRasterBuf().free(); |
|
453 | 476 |
RasterToolsUtil.loadLayer(PluginServices.getMDIManager().getWindowInfo(view).getTitle(), fileName, null); |
454 | 477 |
|
455 | 478 |
} catch (NotSupportedExtensionException e) { |
... | ... | |
475 | 498 |
|
476 | 499 |
|
477 | 500 |
/** |
501 |
* @return String con el log en cada parte del proceso |
|
502 |
* */ |
|
503 |
public String getLog() |
|
504 |
{ |
|
505 |
if(proceso==0) |
|
506 |
return PluginServices.getText(this,"load_buffer_data"); |
|
507 |
else if (proceso==1) |
|
508 |
return PluginServices.getText(this,"generate_mosaic"); |
|
509 |
else |
|
510 |
return PluginServices.getText(this,"write_to_file"); |
|
511 |
} |
|
512 |
|
|
513 |
/** |
|
478 | 514 |
* @return indicador de progreso |
479 | 515 |
* */ |
480 | 516 |
public int getPercent() { |
Also available in: Unified diff