Revision 10626 trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/union/fmap/UnionGeoprocess.java

View differences:

UnionGeoprocess.java
45 45
*
46 46
* $Id$
47 47
* $Log$
48
* Revision 1.2  2006-06-29 07:33:57  fjp
48
* Revision 1.3  2007-03-06 16:47:58  caballero
49
* Exceptions
50
*
51
* Revision 1.2  2006/06/29 07:33:57  fjp
49 52
* Cambios ISchemaManager y IFieldManager por terminar
50 53
*
51 54
* Revision 1.1  2006/06/20 18:20:45  azabala
......
99 102

  
100 103
import java.util.Map;
101 104

  
105
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
106
import com.hardcode.gdbms.driver.exceptions.SchemaEditionException;
102 107
import com.iver.andami.PluginServices;
103
import com.iver.cit.gvsig.fmap.DriverException;
104
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
108
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
109
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException;
110
import com.iver.cit.gvsig.exceptions.visitors.VisitorException;
105 111
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition;
106
import com.iver.cit.gvsig.fmap.edition.EditionException;
107 112
import com.iver.cit.gvsig.fmap.layers.FBitSet;
108 113
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
109 114
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy;
110 115
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager;
111
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException;
112 116
import com.iver.cit.gvsig.geoprocess.core.fmap.AbstractGeoprocess;
113 117
import com.iver.cit.gvsig.geoprocess.core.fmap.DeferredFeaturePersisterProcessor;
114 118
import com.iver.cit.gvsig.geoprocess.core.fmap.DefinitionUtils;
......
136 140
 *
137 141
 *
138 142
 */
139
public class UnionGeoprocess extends AbstractGeoprocess 
143
public class UnionGeoprocess extends AbstractGeoprocess
140 144
							implements IOverlayGeoprocess {
141
	
145

  
142 146
	/**
143 147
	 * overlay layer
144 148
	 */
145 149
	private FLyrVect overlayLayer;
146
	
150

  
147 151
	/**
148 152
	 * Schema of the result layer
149 153
	 */
......
156 160
	 * flag to only clip with selection of clipping layer
157 161
	 */
158 162
	private boolean onlyClipLayerSelection = false;
159
	
163

  
160 164
	/**
161
	 * Constructor 
165
	 * Constructor
162 166
	 *
163 167
	 */
164 168
	public UnionGeoprocess(FLyrVect inputLayer){
165 169
		setFirstOperand(inputLayer);
166 170
	}
167
	
171

  
168 172
	public void setSecondOperand(FLyrVect secondLayer) {
169 173
		this.overlayLayer = secondLayer;
170 174
	}
......
178 182
		Boolean firstLayerSelection = (Boolean) params.get("firstlayerselection");
179 183
		if(firstLayerSelection != null)
180 184
			this.onlyFirstLayerSelection = firstLayerSelection.booleanValue();
181
		
185

  
182 186
		Boolean secondLayerSelection = (Boolean) params.get("secondlayerselection");
183 187
		if(secondLayerSelection != null)
184 188
			this.onlyClipLayerSelection = secondLayerSelection.booleanValue();
......
190 194
			throw new GeoprocessException("Union: capa de entrada a null");
191 195
		if (overlayLayer == null)
192 196
			throw new GeoprocessException("Union: capa de union a null");
193
		if(this.writer == null || 
197
		if(this.writer == null ||
194 198
		   this.schemaManager == null){
195 199
			throw new GeoprocessException("Operacion de union sin especificar capa de resultados");
196 200
		}
......
203 207
					&& overlayLayer.getShapeType() != XTypes.MULTI){
204 208
				throw new GeoprocessException("Segunda capa de union no es de pol?gonos");
205 209
			}
206
		} catch (com.iver.cit.gvsig.fmap.DriverException e) {
210
		} catch (ReadDriverException e) {
207 211
			throw new GeoprocessException("Error al tratar de chequear si las capas a unir son de pol?gonos");
208 212
		}
209 213

  
210 214
	}
211
	
215

  
212 216
	/**
213 217
	 * Runs execution of this geoprocess.
214 218
	 */
......
219 223
		 * guardando en el fichero del usuario.
220 224
		 * b) diferencias de first con overlay, guardando en el
221 225
		 * mismo fichero
222
		 * c) diferencias de overlay con first, guardando en el 
226
		 * c) diferencias de overlay con first, guardando en el
223 227
		 * mismo fichero
224 228
		 */
225 229
		try {
226 230
			this.schemaManager.createSchema(createLayerDefinition());
227 231
			writer.preProcess();
228
			
232

  
229 233
			Strategy strategy = StrategyManager.getStrategy(firstLayer);
230 234
			Strategy strategy2 = StrategyManager.getStrategy(overlayLayer);
231 235
			FeaturePersisterProcessor2 featureProcessor =
232 236
				new FeaturePersisterProcessor2(writer);
233
			
234
			IntersectVisitor visitor = new IntersectVisitor(overlayLayer, 
237

  
238
			IntersectVisitor visitor = new IntersectVisitor(overlayLayer,
235 239
														featureProcessor,
236
														strategy2, 
240
														strategy2,
237 241
														onlyClipLayerSelection);
238 242
			strategy.process(visitor);
239
			
243

  
240 244
			//diferencias entre input y overlay
241 245
			writer.preProcess();
242 246
			DifferenceVisitor visitor2 = new DifferenceVisitor(overlayLayer,
243 247
					featureProcessor, strategy2, onlyClipLayerSelection);
244 248
			visitor2.setLayerDefinition(resultLayerDefinition);
245 249
			strategy.process(visitor2);
246
			
250

  
247 251
			writer.preProcess();
248 252
			DifferenceVisitor visitor3 = new DifferenceVisitor(this.firstLayer,
249 253
					featureProcessor, strategy, onlyFirstLayerSelection);
250 254
			visitor3.setLayerDefinition(resultLayerDefinition);
251 255
			strategy2.process(visitor3);
252
			
253
		} catch (EditionException e) {
256

  
257
		} catch (ReadDriverException e) {
258
			throw new GeoprocessException("Error al procesar el feature de una capa durante el geoproceso interseccion");
259
		} catch (ProcessVisitorException e) {
260
			throw new GeoprocessException("Error al procesar el feature de una capa durante el geoproceso interseccion");
261
		} catch (VisitorException e) {
262
			throw new GeoprocessException("Error al procesar el feature de una capa durante el geoproceso interseccion");
263
		} catch (SchemaEditionException e) {
254 264
			throw new GeoprocessException("Error al crear el esquema/fichero de la nueva capa");
255
		} catch (DriverException e) {
256
			throw new GeoprocessException("Error de driver al calcular el geoproceso interseccion");
257
		} catch (VisitException e) {
258
			throw new GeoprocessException("Error al procesar el feature de una capa durante el geoproceso interseccion");
259
		} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
260
			// TODO Auto-generated catch block
261
			e.printStackTrace();
262 265
		}
263
		
266

  
264 267
	}
265 268

  
266 269
	public void cancel() {
......
289 292
			return null;
290 293
		}
291 294
	}
292
	
295

  
293 296
	/**
294 297
	 * IMonitorableTask that allows to run diff geoprocess in background,
295 298
	 * with cancelation requests.
296
	 * 
299
	 *
297 300
	 * @author azabala
298
	 * 
301
	 *
299 302
	 * FIXME INTERNACIONALIZAR TODOS LOS TEXTOS
300
	 * 
303
	 *
301 304
	 */
302 305
	class UnionMonitorableTask implements IMonitorableTask {
303 306
		private CancellableMonitorable cancelMonitor = null;
......
309 312
//		String FIRST_PASS_MESSAGE = "Computing intersections: ";
310 313
//		String SECOND_PASS_MESSAGE = "Computing A-B difference:";
311 314
//		String THIRD_PASS_MESSAGE = "Computing B-A difference:";
312
		
315

  
313 316
		String currentMessage = "";
314 317
		private boolean finished = false;
315 318

  
316
		UnionMonitorableTask() throws DriverIOException, DriverException {
319
		UnionMonitorableTask() throws ReadDriverException {
317 320
			initialize();
318 321
		}
319
		void initialize() throws DriverIOException, DriverException {
322
		void initialize() throws ReadDriverException {
320 323
			cancelMonitor = createCancelMonitor();
321 324
			currentMessage = "Initializing...";
322 325
		}
323 326

  
324
		private CancellableMonitorable createCancelMonitor()
325
				throws DriverIOException, DriverException {
326
			DefaultCancellableMonitorable monitor = new 
327
		private CancellableMonitorable createCancelMonitor() throws ReadDriverException {
328
			DefaultCancellableMonitorable monitor = new
327 329
							DefaultCancellableMonitorable();
328 330
			monitor.setInitialStep(0);
329 331
			monitor.setDeterminatedProcess(true);
......
378 380
			try {
379 381
				schemaManager.createSchema(createLayerDefinition());
380 382
				writer.preProcess();
381
				
383

  
382 384
				Strategy strategy = StrategyManager.getStrategy(firstLayer);
383 385
				Strategy strategy2 = StrategyManager.getStrategy(overlayLayer);
384 386
				DeferredFeaturePersisterProcessor featureProcessor =
385 387
					new DeferredFeaturePersisterProcessor(writer);
386
				
387
				IntersectVisitor visitor = new IntersectVisitor(overlayLayer, 
388

  
389
				IntersectVisitor visitor = new IntersectVisitor(overlayLayer,
388 390
															featureProcessor,
389
															strategy2, 
391
															strategy2,
390 392
															onlyClipLayerSelection);
391 393
				//FIXME Meter las selecciones
392 394
				currentMessage = FIRST_PASS_NOTE;
......
396 398
				}else{
397 399
					strategy.process(visitor, cancelMonitor);
398 400
				}
399
				
401

  
400 402
				currentMessage = SECOND_PASS_NOTE;
401 403
				DifferenceVisitor visitor2 = new DifferenceVisitor(overlayLayer,
402 404
						featureProcessor, strategy2, onlyClipLayerSelection);
......
418 420
					strategy2.process(visitor3, cancelMonitor);
419 421
				}
420 422
				writer.postProcess();
421
				
422
			} catch (EditionException e) {
423

  
424
			} catch (SchemaEditionException e) {
423 425
				throw new GeoprocessException("Error al crear el esquema/fichero de la nueva capa");
424
			} catch (DriverException e) {
426
			} catch (ReadDriverException e) {
425 427
				throw new GeoprocessException("Error de driver al calcular el geoproceso interseccion");
426
			} catch (VisitException e) {
428
			} catch (ProcessVisitorException e) {
427 429
				throw new GeoprocessException("Error al procesar el feature de una capa durante el geoproceso interseccion");
428
			} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
429
				// TODO Auto-generated catch block
430
				e.printStackTrace();
431
			}finally{
430
			} catch (ExpansionFileReadException e) {
431
				throw new GeoprocessException("Error de driver al calcular el geoproceso interseccion");
432
			} catch (VisitorException e) {
433
				throw new GeoprocessException("Error al procesar el feature de una capa durante el geoproceso interseccion");
434
			} finally{
432 435
				finished = true;
433 436
			}
434 437
		}

Also available in: Unified diff