Revision 28299 branches/v2_0_0_prep/extensions/extRemoteSensing/src/org/gvsig/remotesensing/gridmath/GridMathProcess.java
GridMathProcess.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana. |
4 | 4 |
* |
... | ... | |
20 | 20 |
* |
21 | 21 |
* Generalitat Valenciana |
22 | 22 |
* Conselleria d'Infraestructures i Transport |
23 |
* Av. Blasco Iba?ez, 50
|
|
23 |
* Av. Blasco Iba�ez, 50
|
|
24 | 24 |
* 46010 VALENCIA |
25 | 25 |
* SPAIN |
26 | 26 |
* |
... | ... | |
72 | 72 |
import com.iver.andami.PluginServices; |
73 | 73 |
|
74 | 74 |
/** |
75 |
* GridMathProcess implenta la funcionalidad para el c?lculo de operaciones entre grids.
|
|
76 |
* El proceso permite hacer operaciones matem?ticas entre los valores de las bandas de la misma imagen o entre
|
|
77 |
* diferentes im?genes bajo ciertas restricciones espaciales (siempre sobre los datos originales).
|
|
75 |
* GridMathProcess implenta la funcionalidad para el c�lculo de operaciones entre grids.
|
|
76 |
* El proceso permite hacer operaciones matem�ticas entre los valores de las bandas de la misma imagen o entre
|
|
77 |
* diferentes im�genes bajo ciertas restricciones espaciales (siempre sobre los datos originales).
|
|
78 | 78 |
* |
79 |
* @author Alejandro Mu?oz Sanchez (alejandro.munoz@uclm.es)
|
|
79 |
* @author Alejandro Mu�oz Sanchez (alejandro.munoz@uclm.es)
|
|
80 | 80 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
81 | 81 |
* @version 19/10/2007 |
82 | 82 |
* |
... | ... | |
127 | 127 |
|
128 | 128 |
|
129 | 129 |
/** |
130 |
* Establece la expresi?n en el parser
|
|
130 |
* Establece la expresi�n en el parser
|
|
131 | 131 |
* @param expression expresion |
132 | 132 |
*/ |
133 | 133 |
public void setExpression(String expression){ |
... | ... | |
137 | 137 |
} |
138 | 138 |
|
139 | 139 |
/** |
140 |
* @return expresi?n a evaluar
|
|
140 |
* @return expresi�n a evaluar
|
|
141 | 141 |
*/ |
142 | 142 |
public String getExpression() { |
143 | 143 |
return expression; |
... | ... | |
209 | 209 |
} |
210 | 210 |
|
211 | 211 |
/** |
212 |
* Asignaci?n del extent
|
|
212 |
* Asignaci�n del extent
|
|
213 | 213 |
* @param resultExtent |
214 | 214 |
*/ |
215 | 215 |
public void setResultExtent(GridExtent resultExtent) { |
... | ... | |
258 | 258 |
|
259 | 259 |
public void process() throws InterruptedException { |
260 | 260 |
RasterBuffer inputBuffer=null; |
261 |
|
|
262 |
// Construccion del rasterbuffer que recoge el resultado del calculo |
|
261 |
|
|
262 |
// Construccion del rasterbuffer que recoge el resultado del calculo
|
|
263 | 263 |
rasterResult = RasterBuffer.getBuffer(RasterBuffer.TYPE_DOUBLE, resultExtent.getNX() ,resultExtent.getNY(), 1, true); |
264 | 264 |
|
265 |
|
|
265 |
|
|
266 | 266 |
// Calculo de grid resultante |
267 | 267 |
int iNX = resultExtent.getNX(); |
268 | 268 |
int iNY = resultExtent.getNY(); |
269 |
|
|
269 |
|
|
270 | 270 |
// Calculo de grid resultante |
271 | 271 |
for (int x=0;x<iNX;x++){ |
272 |
if (cancel) return; //Proceso cancelado |
|
272 |
if (cancel) return; //Proceso cancelado
|
|
273 | 273 |
for(int y=0;y<iNY;y++){ |
274 | 274 |
int i=0; |
275 | 275 |
for (Iterator iter = params.keySet().iterator(); iter.hasNext();) { |
276 | 276 |
String varName = (String)iter.next(); |
277 | 277 |
Object data[]= (Object[])params.get(varName); |
278 | 278 |
inputBuffer= (RasterBuffer)data[0]; |
279 |
|
|
279 |
|
|
280 | 280 |
int dataType= ((Integer)data[1]).intValue(); |
281 | 281 |
double value=0; |
282 |
|
|
283 |
value = RemoteSensingUtils.getCellValueInLayerCoords(inputBuffer, x, y, 0); |
|
284 |
if(value!=inputBuffer.getNoDataValue()){ |
|
285 |
parser.setVarValue(varName,new Double(value)); |
|
286 |
i++; |
|
282 |
|
|
283 |
if(dataType==IBuffer.TYPE_BYTE){ |
|
284 |
value =(byte) RemoteSensingUtils.getCellValueInLayerCoords(inputBuffer, x, y, 0); |
|
285 |
if(value!=inputBuffer.getNoDataValue()){ |
|
286 |
parser.setVarValue(varName,new Double(value)); |
|
287 |
i++; |
|
288 |
}else{ |
|
289 |
rasterResult.setElem(y, x, 0, rasterResult.noDataValue); |
|
290 |
break; |
|
291 |
} |
|
287 | 292 |
}else{ |
288 |
rasterResult.setElem(x, y, 0, rasterResult.noDataValue); |
|
289 |
break; |
|
293 |
value =RemoteSensingUtils.getCellValueInLayerCoords(inputBuffer, x, y, 0); |
|
294 |
if(value!=inputBuffer.getNoDataValue()){ |
|
295 |
parser.setVarValue(varName,new Double(value)); |
|
296 |
i++; |
|
297 |
}else{ |
|
298 |
rasterResult.setElem(y, x, 0, rasterResult.noDataValue); |
|
299 |
break; |
|
300 |
} |
|
290 | 301 |
} |
291 | 302 |
} |
292 |
// Evaluacion de la exprsion en el x,y. |
|
303 |
// Evaluacion de la expresion en el x,y.
|
|
293 | 304 |
if (i == params.size()){ |
294 | 305 |
rasterResult.setElem(y, x, 0, (double)parser.getValue()); |
295 |
percent = x*100/rasterResult.getHeight();
|
|
296 |
} |
|
297 |
} |
|
298 |
|
|
306 |
percent = x*100/rasterResult.getWidth();
|
|
307 |
}
|
|
308 |
}
|
|
309 |
|
|
299 | 310 |
} |
300 | 311 |
// Escritura de los datos a disco |
301 | 312 |
writeToFile(); |
302 |
|
|
313 |
|
|
303 | 314 |
} |
304 | 315 |
|
305 |
|
|
306 | 316 |
void loadBuffers(){ |
307 | 317 |
|
308 | 318 |
int nBand; |
Also available in: Unified diff