Revision 22012 trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/mosaic/process/FeatherProcess.java
FeatherProcess.java | ||
---|---|---|
87 | 87 |
|
88 | 88 |
private Grid resultGrid = null; |
89 | 89 |
private GridExtent resultGridExtent = null; |
90 |
private int resultPxWidth, resultPxHeight= 0; |
|
90 | 91 |
private int resultbandCount = 0; |
92 |
private int resultNodataValue = 0; |
|
91 | 93 |
|
92 | 94 |
private WriterBufferServer writerBufferServer = null; |
93 | 95 |
private String fileName = null; |
... | ... | |
100 | 102 |
private double cellValue = 0; |
101 | 103 |
private double totalDistance = 0; |
102 | 104 |
private double resultCellVale[] =null; |
105 |
private GeoRasterWriter grw = null;; |
|
106 |
|
|
103 | 107 |
|
104 | 108 |
public void init() { |
105 |
|
|
109 |
|
|
106 | 110 |
// Obtener las capas que intervienen en el mosaico. |
107 | 111 |
inputRasterLayers = (FLyrRasterSE[]) getParam("inputRasterLayers"); |
108 | 112 |
view = (View) getParam("view"); |
... | ... | |
124 | 128 |
|
125 | 129 |
resultGridExtent = new GridExtent(new Extent(resultExtent), cellSizeX, |
126 | 130 |
cellSizeY); |
131 |
resultPxWidth = resultGridExtent.getNX(); |
|
132 |
resultPxHeight = resultGridExtent.getNY(); |
|
127 | 133 |
|
128 | 134 |
// Grid Resultante |
129 | 135 |
try { |
... | ... | |
131 | 137 |
resultGrid = new Grid(resultGridExtent, resultGridExtent, |
132 | 138 |
IBuffer.TYPE_BYTE, new int[] { 0, 1, 2 }); |
133 | 139 |
resultGrid.setNoDataValue(0); |
140 |
|
|
134 | 141 |
resultbandCount = resultGrid.getBandCount(); |
135 | 142 |
resultCellVale = new double[resultbandCount]; |
136 | 143 |
} catch (RasterBufferInvalidException e) { |
... | ... | |
155 | 162 |
// TODO Auto-generated catch block |
156 | 163 |
e.printStackTrace(); |
157 | 164 |
} |
158 |
//inputGrids[l] = new Grid(inputRasterLayers[l].getDataSource(), new int[] { 0, 1, 2 }, null); |
|
159 | 165 |
} |
160 | 166 |
|
161 | 167 |
// Recorrido del grid resultante |
162 |
//for (int band = 0; band < resultGrid.getBandCount(); band++){ |
|
163 |
//resultGrid.setBandToOperate(band); |
|
164 |
for (int col = 0; col < resultGrid.getNX(); col++){ |
|
165 |
//percent = col*resultGrid.getBandCount()*100/resultGrid.getNX()*resultGrid.getBandCount(); |
|
166 |
for (int row = 0; row < resultGrid.getNY(); row++) { |
|
167 |
try { |
|
168 |
setValue(col, row); |
|
169 |
//resultGrid.setCellValue(col, row, getValue(col, row, band)); |
|
170 |
} catch (OutOfGridException e) { |
|
171 |
RasterToolsUtil.messageBoxError(PluginServices.getText( |
|
172 |
this, "bad_access_grid"), this, e); |
|
173 |
} |
|
168 |
for (int col = 0; col < resultPxWidth; col++){ |
|
169 |
percent = col*100/resultPxWidth; |
|
170 |
System.out.println("------------- "+percent+" %"); /////////DEBUG*********** |
|
171 |
for (int row = 0; row < resultPxHeight;row++) { |
|
172 |
try { |
|
173 |
setValue(col, row); |
|
174 |
} catch (OutOfGridException e) { |
|
175 |
RasterToolsUtil.messageBoxError(PluginServices.getText( |
|
176 |
this, "bad_access_grid"), this, e); |
|
174 | 177 |
} |
175 | 178 |
} |
176 |
//}
|
|
179 |
} |
|
177 | 180 |
createLayer(); |
178 | 181 |
if (externalActions != null) |
179 | 182 |
externalActions.end(outputRasterLayer); |
... | ... | |
185 | 188 |
.getCellSizeX(), 0.0, 0.0, resultGridExtent.getCellSizeY(), |
186 | 189 |
resultGridExtent.getMin().getX(), resultGridExtent.getMax() |
187 | 190 |
.getY()); |
188 |
GeoRasterWriter grw; |
|
189 | 191 |
try { |
190 | 192 |
grw = GeoRasterWriter.getWriter(writerBufferServer, fileName, |
191 | 193 |
resultGrid.getBandCount(), aTransform, resultGridExtent |
... | ... | |
193 | 195 |
.getDataType(), GeoRasterWriter.getWriter(fileName) |
194 | 196 |
.getParams(), null); |
195 | 197 |
grw.dataWrite(); |
198 |
grw.getPercent(); |
|
196 | 199 |
grw.writeClose(); |
197 | 200 |
|
198 | 201 |
int endIndex = fileName.lastIndexOf("."); |
... | ... | |
223 | 226 |
private void setValue(int col, int row) throws OutOfGridException { |
224 | 227 |
//?Est? el punto en la intersecci?n? |
225 | 228 |
Point2D worldCoords = rasterToWorld(col, row); |
226 |
if (intersection.contains(worldCoords)){ |
|
229 |
if (intersection.contains(worldCoords)){ //////**************************************************
|
|
227 | 230 |
setFeatherValue(col, row); |
228 |
/*for (int band = 0; band<resultbandCount; band++){ |
|
229 |
resultGrid.setBandToOperate(band); |
|
230 |
resultGrid.setCellValue(col, row, (byte)255); |
|
231 |
} |
|
232 |
*/ |
|
233 | 231 |
return; |
234 | 232 |
} |
235 | 233 |
|
236 | 234 |
for (int g = 0; g < inputGrids.length; g++) { |
237 |
if (inputExtents[g].contains(worldCoords)){ |
|
235 |
if (inputExtents[g].contains(worldCoords)){ //////**************************************************
|
|
238 | 236 |
try { |
239 | 237 |
|
240 |
for (int band = 0; band<resultbandCount; band++){
|
|
238 |
for (int band = 0; band < resultbandCount; band++){
|
|
241 | 239 |
inputGrids[g].setBandToOperate(band); |
242 | 240 |
resultGrid.setBandToOperate(band); |
243 | 241 |
cellValue = inputGrids[g].getCellValueAsByte(col, row) & 0xff; |
... | ... | |
245 | 243 |
resultGrid.setCellValue(col, row, (byte)cellValue); |
246 | 244 |
} |
247 | 245 |
else{ |
248 |
resultGrid.setCellValue(col, row,(byte) resultGrid.getNoDataValue());
|
|
246 |
resultGrid.setCellValue(col, row,(byte) resultNodataValue);
|
|
249 | 247 |
} |
250 |
|
|
251 | 248 |
} |
252 | 249 |
} catch (GridException e) { |
253 | 250 |
// TODO Auto-generated catch block |
... | ... | |
262 | 259 |
Point2D worldPoint = rasterToWorld(col, row); |
263 | 260 |
|
264 | 261 |
totalDistance = 0; |
262 |
double newDistance = 0; |
|
265 | 263 |
|
266 | 264 |
try { |
267 | 265 |
for (int i = 0; i<borders.length;i++){ |
... | ... | |
270 | 268 |
distances[i]= Double.POSITIVE_INFINITY; |
271 | 269 |
for(int j = 0; j<borders[0].length;j++) |
272 | 270 |
if (borders[i][j] != null){ |
273 |
double newDistance = borders[i][j].ptLineDist(worldPoint);
|
|
271 |
newDistance = borders[i][j].ptLineDist(worldPoint); ///////*****************************
|
|
274 | 272 |
if(distances[i]>newDistance) |
275 | 273 |
distances[i]=newDistance; |
276 | 274 |
} |
... | ... | |
297 | 295 |
} |
298 | 296 |
|
299 | 297 |
public int getPercent() { |
300 |
// TODO Auto-generated method stub |
|
301 |
return 0; |
|
298 |
if (grw != null) |
|
299 |
return grw.getPercent(); |
|
300 |
|
|
301 |
return percent; |
|
302 | 302 |
} |
303 | 303 |
|
304 | 304 |
public String getTitle() { |
305 |
if (percent == 0) |
|
306 |
return PluginServices.getText(this, "iniciando_proceso"); |
|
307 |
|
|
308 |
if (grw != null) |
|
309 |
return PluginServices.getText(this, "escribiendo_resultado"); |
|
310 |
|
|
305 | 311 |
return PluginServices.getText(this, "calculando_feather"); |
306 | 312 |
} |
307 | 313 |
|
Also available in: Unified diff