Revision 30184 trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/util/process/ClippingProcess.java
ClippingProcess.java | ||
---|---|---|
19 | 19 |
package org.gvsig.raster.util.process; |
20 | 20 |
|
21 | 21 |
import java.awt.geom.AffineTransform; |
22 |
import java.awt.geom.Point2D; |
|
22 | 23 |
import java.io.File; |
23 | 24 |
import java.io.IOException; |
25 |
import java.util.ArrayList; |
|
24 | 26 |
|
27 |
import org.gvsig.fmap.raster.grid.roi.VectorialROI; |
|
25 | 28 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
26 | 29 |
import org.gvsig.raster.Configuration; |
27 | 30 |
import org.gvsig.raster.RasterProcess; |
... | ... | |
70 | 73 |
private String viewName = ""; |
71 | 74 |
private Params params = null; |
72 | 75 |
private DatasetColorInterpretation colorInterp = null; |
76 |
private ArrayList selectedRois = null; |
|
73 | 77 |
|
74 | 78 |
private double[] wcValues = null; |
75 | 79 |
|
... | ... | |
110 | 114 |
interpolationMethod = getIntParam("interpolationmethod"); |
111 | 115 |
affineTransform = (AffineTransform)getParam("affinetransform"); |
112 | 116 |
colorInterp = (DatasetColorInterpretation)getParam("colorInterpretation"); |
117 |
selectedRois = (ArrayList)getParam("selectedrois"); |
|
113 | 118 |
if(getIntArrayParam("resolution") != null) { |
114 | 119 |
resolutionWidth = getIntArrayParam("resolution")[0]; |
115 | 120 |
resolutionHeight = getIntArrayParam("resolution")[1]; |
... | ... | |
225 | 230 |
} |
226 | 231 |
//TODO: FUNCIONALIDAD: Poner los getWriter con la proyecci?n del fichero fuente |
227 | 232 |
|
233 |
|
|
234 |
if ((selectedRois != null) && (!bufferFactory.isReadOnly())){ |
|
235 |
int despX = 0; |
|
236 |
int despY = 0; |
|
237 |
if (pValues != null){ |
|
238 |
despX = pValues[0]; |
|
239 |
despY = pValues[1]; |
|
240 |
} else if (wcValues != null){ |
|
241 |
despX = (int)dsetCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getX(); |
|
242 |
despY = (int)dsetCopy.worldToRaster(new Point2D.Double(wcValues[0], wcValues[1])).getY(); |
|
243 |
} |
|
244 |
drawOnlyROIs(buffer, selectedRois, despX, despY); |
|
245 |
} |
|
246 |
|
|
228 | 247 |
insertLineLog(RasterToolsUtil.getText(this, "salvando_imagen")); |
229 | 248 |
|
230 | 249 |
String finalFileName = ""; |
... | ... | |
317 | 336 |
} |
318 | 337 |
|
319 | 338 |
/** |
339 |
* Acciones para poner a NoData los pixels que est?n fuera de las |
|
340 |
* regiones de inter?s seleccionadas. |
|
341 |
* @param buffer |
|
342 |
*/ |
|
343 |
private void drawOnlyROIs(IBuffer buffer, ArrayList rois, int despX, int despY){ |
|
344 |
for (int i = 0 ; i<buffer.getWidth() ; i++){ |
|
345 |
for (int j = 0 ; j<buffer.getHeight() ; j++){ |
|
346 |
boolean inside = false; |
|
347 |
for (int k = 0 ; k<rois.size() ; k++){ |
|
348 |
VectorialROI roi = (VectorialROI)rois.get(k); |
|
349 |
//TODO: Hacer la comprobacion por coordenadas del mundo en lugar de coordenadas pixel. |
|
350 |
if (roi.isInGrid(i + despX, j + despY)){ |
|
351 |
inside = true; |
|
352 |
} |
|
353 |
} |
|
354 |
if (!inside){ |
|
355 |
for (int l = 0 ; l<buffer.getBandCount() ; l++){ |
|
356 |
try{ |
|
357 |
if (buffer.getDataType() == RasterBuffer.TYPE_BYTE){ |
|
358 |
buffer.setElem(j, i, l, buffer.getByteNoDataValue()); |
|
359 |
} else if (buffer.getDataType() == RasterBuffer.TYPE_DOUBLE){ |
|
360 |
buffer.setElem(j, i, l, buffer.getFloatNoDataValue()); |
|
361 |
} else if (buffer.getDataType() == RasterBuffer.TYPE_FLOAT){ |
|
362 |
buffer.setElem(j, i, l, buffer.getFloatNoDataValue()); |
|
363 |
} else if (buffer.getDataType() == RasterBuffer.TYPE_INT){ |
|
364 |
buffer.setElem(j, i, l, buffer.getIntNoDataValue()); |
|
365 |
} else if (buffer.getDataType() == RasterBuffer.TYPE_SHORT){ |
|
366 |
buffer.setElem(j, i, l, buffer.getShortNoDataValue()); |
|
367 |
} |
|
368 |
}catch (InterruptedException ex){ |
|
369 |
|
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
375 |
} |
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
/** |
|
320 | 380 |
* Acciones que se realizan al finalizar de crear los recortes de imagen. |
321 | 381 |
* Este m?todo es llamado por el thread TailRasterProcess al finalizar. |
322 | 382 |
*/ |
Also available in: Unified diff