Revision 22800 trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/mosaic/process/MosaicProcess.java
MosaicProcess.java | ||
---|---|---|
64 | 64 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
65 | 65 |
|
66 | 66 |
/** |
67 |
* Clase que implementa el proceso de construccion de un mosaico. |
|
67 |
* Clase que implementa el proceso de construccion de un mosaico mediante los m?todos b?sicos.
|
|
68 | 68 |
* |
69 |
* @params |
|
70 |
* <LI>FLyrRasterSE[] "inputRasterLayers": Capas raster de entrada</LI> |
|
71 |
* <LI>int "methodCode": M?todo de construcci?n (0:Valor m?ximo, 1:Valor m?nimo, 2: Valor Medio, |
|
72 |
* 3: Valor del pixel de la capa superior, 4:Valor del pixel de la capa inferior)</LI> |
|
73 |
* <LI>String "outputPath": Ruta completa al fichero de salida del proceso</LI> |
|
74 |
* |
|
75 |
* @result |
|
76 |
* <LI>outputRassterLayers[]: Capas raster resultantes</LI> |
|
77 |
* |
|
78 |
* |
|
69 | 79 |
* @author aMu?oz (alejandro.mu?oz@uclm.es) |
70 | 80 |
* @version 30/4/2008 |
71 | 81 |
* */ |
72 | 82 |
|
73 | 83 |
public class MosaicProcess extends RasterProcess { |
84 |
|
|
85 |
public static final int MAX = 0; |
|
86 |
public static final int MIN = 1; |
|
87 |
public static final int AVERAGE = 2; |
|
88 |
public static final int FRONT = 3; |
|
89 |
public static final int BACK = 4; |
|
74 | 90 |
|
75 | 91 |
// Layers que intervienen en el proceso |
76 | 92 |
private FLyrRasterSE inputRasterLayers[] = null; |
... | ... | |
96 | 112 |
// writer para escritura en fichero |
97 | 113 |
private WriterBufferServer writerBufferServer =null; |
98 | 114 |
|
99 |
// Numero de bandas 3 o 1 dependiendo de si es RGB o Nivel de gris |
|
100 |
int numbands=0;
|
|
115 |
// Numero de bandas 3 o 1 dependiendo de si es RGB o Nivel de gris
|
|
116 |
int resultbandCount=0;
|
|
101 | 117 |
|
102 | 118 |
// Fichero de salida |
103 | 119 |
private String fileName=null; |
... | ... | |
112 | 128 |
public void init() { |
113 | 129 |
|
114 | 130 |
inputRasterLayers= (FLyrRasterSE[])getParam("inputRasterLayers"); |
115 |
codOp= getIntParam("codOp");
|
|
116 |
numbands= getIntParam("numbands");
|
|
117 |
fileName = getStringParam("filename");
|
|
131 |
codOp= getIntParam("methodCode");
|
|
132 |
resultbandCount= getIntParam("numbands");
|
|
133 |
fileName = getStringParam("outputPath");
|
|
118 | 134 |
|
119 | 135 |
// Calculo del extend resultante |
120 | 136 |
fullExtend= calculateExtend(inputRasterLayers); |
121 | 137 |
|
122 |
int bands[]= new int[numbands]; |
|
123 |
for(int i=0; i<numbands;i++) |
|
124 |
bands[i]=i; |
|
125 | 138 |
try { |
126 |
mosaicGrid= new Grid(fullExtend,fullExtend,IBuffer.TYPE_BYTE,bands); |
|
139 |
mosaicGrid= new Grid(fullExtend,fullExtend,IBuffer.TYPE_BYTE,new int[] { 0, 1, 2 }); |
|
140 |
resultbandCount = mosaicGrid.getBandCount(); |
|
127 | 141 |
} catch (RasterBufferInvalidException e) { |
128 | 142 |
RasterToolsUtil.messageBoxError("buffer_incorrecto", this, e); |
129 | 143 |
} |
... | ... | |
154 | 168 |
if (!RasterBuffer.loadInMemory(dsetCopy)) |
155 | 169 |
bufferFactory.setReadOnly(true); |
156 | 170 |
// Si pongo solo las renderizadas en algunos casos da problemas |
157 |
bufferFactory.setAllDrawableBands();
|
|
171 |
bufferFactory.setDrawableBands(inputRasterLayers[i].getRenderBands());
|
|
158 | 172 |
bufferFactory.setAreaOfInterest(minX,minY,maxX,maxY,fullExtend.getNX(),fullExtend.getNY()); |
159 | 173 |
buffers[i]= (RasterBuffer) bufferFactory.getRasterBuf(); |
160 | 174 |
percent=(int)((i+1)*100/inputRasterLayers.length); |
... | ... | |
174 | 188 |
// Construccion del mosaico: Operaci?n M?ximo |
175 | 189 |
if(codOp==0){ |
176 | 190 |
int progress = 0; |
177 |
for(int band=0; band<numbands; band++){
|
|
191 |
for(int band=0; band<resultbandCount; band++){
|
|
178 | 192 |
mosaicGrid.setBandToOperate(band); |
179 | 193 |
for(int col=0; col<mosaicGrid.getLayerNY(); col++){ |
180 | 194 |
progress++; |
181 | 195 |
for(int row=0; row<mosaicGrid.getLayerNX();row++){ |
182 | 196 |
setValueMax(row,col,band); |
183 | 197 |
} |
184 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*numbands));
|
|
198 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
|
|
185 | 199 |
} |
186 | 200 |
} |
187 | 201 |
} |
... | ... | |
189 | 203 |
// Construccion del mosaico: Operaci?n M?nimo |
190 | 204 |
if(codOp==1){ |
191 | 205 |
int progress = 0; |
192 |
for(int band=0; band<numbands; band++){
|
|
206 |
for(int band=0; band<resultbandCount; band++){
|
|
193 | 207 |
mosaicGrid.setBandToOperate(band); |
194 | 208 |
for(int col=0; col<mosaicGrid.getLayerNY(); col++){ |
195 | 209 |
progress++; |
196 | 210 |
for(int row=0; row<mosaicGrid.getLayerNX();row++){ |
197 | 211 |
setValueMin(row,col,band); |
198 | 212 |
} |
199 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*numbands));
|
|
213 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
|
|
200 | 214 |
} |
201 | 215 |
} |
202 | 216 |
} |
... | ... | |
204 | 218 |
// Construccion del mosaico: Operaci?n Media |
205 | 219 |
if(codOp==2){ |
206 | 220 |
int progress = 0; |
207 |
for(int band=0; band<numbands; band++){
|
|
221 |
for(int band=0; band<resultbandCount; band++){
|
|
208 | 222 |
mosaicGrid.setBandToOperate(band); |
209 | 223 |
for(int col=0; col<mosaicGrid.getLayerNY(); col++){ |
210 | 224 |
progress++; |
211 | 225 |
for(int row=0; row<mosaicGrid.getLayerNX();row++){ |
212 | 226 |
setValueMean(row,col,band); |
213 | 227 |
} |
214 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*numbands));
|
|
228 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
|
|
215 | 229 |
} |
216 | 230 |
} |
217 | 231 |
} |
... | ... | |
219 | 233 |
// Construccion del mosaico: Operacion valor de capa de delantera |
220 | 234 |
if(codOp==3){ |
221 | 235 |
int progress = 0; |
222 |
for(int band=0; band<numbands; band++){
|
|
236 |
for(int band=0; band<resultbandCount; band++){
|
|
223 | 237 |
mosaicGrid.setBandToOperate(band); |
224 | 238 |
for(int col=0; col<mosaicGrid.getLayerNY(); col++){ |
225 | 239 |
progress++; |
226 | 240 |
for(int row=0; row<mosaicGrid.getLayerNX();row++){ |
227 | 241 |
setValueFront(row,col,band); |
228 | 242 |
} |
229 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*numbands));
|
|
243 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
|
|
230 | 244 |
} |
231 | 245 |
} |
232 | 246 |
} |
... | ... | |
245 | 259 |
k--; |
246 | 260 |
} |
247 | 261 |
int progress = 0; |
248 |
for(int band=0; band<numbands; band++){
|
|
262 |
for(int band=0; band<resultbandCount; band++){
|
|
249 | 263 |
mosaicGrid.setBandToOperate(band); |
250 | 264 |
for(int col=0; col<mosaicGrid.getLayerNY(); col++){ |
251 | 265 |
progress++; |
252 | 266 |
for(int row=0; row<mosaicGrid.getLayerNX();row++){ |
253 | 267 |
setValueBack(row,col,band); |
254 | 268 |
} |
255 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*numbands));
|
|
269 |
percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
|
|
256 | 270 |
} |
257 | 271 |
} |
258 | 272 |
} |
... | ... | |
329 | 343 |
int buffTotales= buffers.length; |
330 | 344 |
for(int buf=0;buf<buffers.length;buf++){ |
331 | 345 |
int data = (int)((byte)(buffers[buf].getElemByte(y,x,band))); |
332 |
// TO DO: TENER EN CUENTA NODATA REAL DEL BUFER
|
|
346 |
//TODO: TENER EN CUENTA NODATA REAL DEL BUFER
|
|
333 | 347 |
if(data==(byte)mosaicGrid.getNoDataValue()){ |
334 | 348 |
buffTotales--; |
335 | 349 |
data =0; |
Also available in: Unified diff