Revision 16167 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/clipping/ClippingProcess.java
ClippingProcess.java | ||
---|---|---|
37 | 37 |
import org.gvsig.raster.dataset.InvalidSetViewException; |
38 | 38 |
import org.gvsig.raster.dataset.NotSupportedExtensionException; |
39 | 39 |
import org.gvsig.raster.dataset.Params; |
40 |
import org.gvsig.raster.dataset.RasterDataset; |
|
40 | 41 |
import org.gvsig.raster.dataset.RasterDriverException; |
41 | 42 |
import org.gvsig.raster.dataset.io.rmf.RmfBlocksManager; |
42 | 43 |
import org.gvsig.raster.datastruct.ColorTable; |
... | ... | |
127 | 128 |
*/ |
128 | 129 |
private void saveToRmf(String fileName) { |
129 | 130 |
fileName = RasterUtilities.getNameWithoutExtension(fileName) + ".rmf"; |
131 |
|
|
132 |
RasterDataset rds = null; |
|
133 |
int limitNumberOfRequests = 20; |
|
134 |
while(rds == null && limitNumberOfRequests > 0) { |
|
135 |
try { |
|
136 |
rds = rasterSE.getDataSource().getDataset(0)[0]; |
|
137 |
} catch(IndexOutOfBoundsException e) { |
|
138 |
//En ocasiones, sobre todo con servicios remotos al pedir un datasource da una excepci?n de este tipo |
|
139 |
//se supone que es porque hay un refresco en el mismo momento de la petici?n por lo que como es m?s lento de |
|
140 |
//gestionar pilla a la capa sin datasources asociados ya que est? reasignandolo. Si volvemos a pedirlo debe |
|
141 |
//haberlo cargado ya. |
|
142 |
try { |
|
143 |
Thread.sleep(200); |
|
144 |
} catch (InterruptedException e1) { |
|
145 |
} |
|
146 |
} |
|
147 |
limitNumberOfRequests --; |
|
148 |
} |
|
149 |
|
|
150 |
if(rds == null) { |
|
151 |
//RasterToolsUtil.messageBoxError("error_load_layer", this, new Exception("Error writing RMF. limitNumberOfRequests=" + limitNumberOfRequests)); |
|
152 |
return; |
|
153 |
} |
|
154 |
|
|
155 |
RmfBlocksManager manager = rds.getRmfBlocksManager(); |
|
130 | 156 |
|
131 |
RmfBlocksManager manager = rasterSE.getDataSource().getDataset(0)[0].getRmfBlocksManager(); |
|
132 |
|
|
133 | 157 |
RasterFilterList rasterFilterList = rasterSE.getRenderFilterList(); |
134 | 158 |
|
135 | 159 |
ColorTableFilter colorTableFilter = (ColorTableFilter) rasterFilterList.getByName(ColorTableFilter.names[0]); |
... | ... | |
224 | 248 |
grw.writeClose(); |
225 | 249 |
saveToRmf(finalFileName); |
226 | 250 |
t2 = new java.util.Date().getTime(); |
251 |
if (incrementableTask != null) { |
|
252 |
incrementableTask.processFinalize(); |
|
253 |
incrementableTask = null; |
|
254 |
} |
|
255 |
//Damos tiempo a parar el Thread del incrementable para que no se cuelgue la ventana |
|
256 |
//El tiempo es como m?nimo el de un bucle de del run de la tarea incrementable |
|
257 |
Thread.sleep(600); |
|
227 | 258 |
cutFinalize(finalFileName, (t2 - t1)); |
228 | 259 |
} |
229 | 260 |
|
... | ... | |
267 | 298 |
* Este m?todo es llamado por el thread TailRasterProcess al finalizar. |
268 | 299 |
*/ |
269 | 300 |
private void cutFinalize(String fileName, long milis) { |
270 |
if (!isLoadedInToc()) { |
|
301 |
/*if (!isLoadedInToc()) {
|
|
271 | 302 |
externalActions.end(new Object[]{fileName, new Long(milis)}); |
272 | 303 |
return; |
273 |
} |
|
304 |
}*/ |
|
305 |
|
|
274 | 306 |
if (!new File(fileName).exists()) |
275 | 307 |
return; |
276 |
try { |
|
277 |
RasterToolsUtil.loadLayer(viewName, fileName, null); |
|
278 |
} catch (RasterNotLoadException e) { |
|
279 |
RasterToolsUtil.messageBoxError("error_cargar_capa", this, e); |
|
308 |
|
|
309 |
if(RasterToolsUtil.messageBoxYesOrNot("cargar_toc", this)) { |
|
310 |
try { |
|
311 |
RasterToolsUtil.loadLayer(viewName, fileName, null); |
|
312 |
} catch (RasterNotLoadException e) { |
|
313 |
RasterToolsUtil.messageBoxError("error_load_layer", this, e); |
|
314 |
} |
|
280 | 315 |
} |
281 |
|
|
316 |
|
|
282 | 317 |
if (externalActions != null) { |
283 | 318 |
RasterModule.layerCount++; |
284 | 319 |
externalActions.end(new Object[]{fileName, new Long(milis)}); |
Also available in: Unified diff