Revision 10626 trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/difference/fmap/DifferenceGeoprocess.java
DifferenceGeoprocess.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 |
... | ... | |
93 | 96 |
|
94 | 97 |
import java.util.Map; |
95 | 98 |
|
96 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
|
99 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
100 |
import com.hardcode.gdbms.driver.exceptions.SchemaEditionException; |
|
97 | 101 |
import com.iver.andami.PluginServices; |
102 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
|
103 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
|
104 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
98 | 105 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
99 | 106 |
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
100 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
|
101 | 107 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
102 | 108 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
103 | 109 |
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
104 | 110 |
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager; |
105 |
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException; |
|
106 | 111 |
import com.iver.cit.gvsig.geoprocess.core.fmap.AbstractGeoprocess; |
107 | 112 |
import com.iver.cit.gvsig.geoprocess.core.fmap.DefinitionUtils; |
108 | 113 |
import com.iver.cit.gvsig.geoprocess.core.fmap.FeaturePersisterProcessor2; |
... | ... | |
119 | 124 |
* other geometry doesnt have. |
120 | 125 |
* By analogy, this geoprocess computes difference geometries between vectorial |
121 | 126 |
* layers. |
122 |
*
|
|
127 |
* |
|
123 | 128 |
* @author azabala |
124 |
*
|
|
129 |
* |
|
125 | 130 |
*/ |
126 | 131 |
public class DifferenceGeoprocess extends AbstractGeoprocess |
127 | 132 |
implements IOverlayGeoprocess { |
... | ... | |
183 | 188 |
"Operacion de interseccion sin especificar capa de resultados"); |
184 | 189 |
} |
185 | 190 |
try { |
186 |
if (firstLayer.getShapeType() != XTypes.POLYGON
|
|
191 |
if (firstLayer.getShapeType() != XTypes.POLYGON |
|
187 | 192 |
&& firstLayer.getShapeType() != XTypes.MULTI) { |
188 | 193 |
throw new GeoprocessException( |
189 | 194 |
"Primera capa de interseccion no es de pol?gonos"); |
... | ... | |
193 | 198 |
throw new GeoprocessException( |
194 | 199 |
"Segunda capa de interseccion no es de pol?gonos"); |
195 | 200 |
} |
196 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
|
201 |
} catch (ReadDriverException e) {
|
|
197 | 202 |
throw new GeoprocessException( |
198 |
"Error al tratar de chequear si las capas a intersectar son de pol?gonos");
|
|
203 |
"Error al tratar de chequear si las capas a intersectar son de pol?gonos"); |
|
199 | 204 |
} |
200 | 205 |
|
201 | 206 |
} |
202 | 207 |
|
203 |
|
|
208 |
|
|
204 | 209 |
//FIXME La unica diferencia entre este geoproceso y el intersection |
205 |
//es que usa visitors distintos
|
|
210 |
//es que usa visitors distintos |
|
206 | 211 |
//REDISE?AR TODOS LOS OVERLAYGEOPROCESS |
207 | 212 |
public void process() throws GeoprocessException { |
208 | 213 |
|
... | ... | |
212 | 217 |
// Prepare the result |
213 | 218 |
this.schemaManager.createSchema(createLayerDefinition()); |
214 | 219 |
writer.preProcess(); |
215 |
Strategy strategy =
|
|
220 |
Strategy strategy = |
|
216 | 221 |
StrategyManager.getStrategy(firstLayer); |
217 | 222 |
FeaturePersisterProcessor2 featureProcessor = new FeaturePersisterProcessor2( |
218 | 223 |
writer); |
219 |
Strategy overlayStrategy =
|
|
224 |
Strategy overlayStrategy = |
|
220 | 225 |
StrategyManager.getStrategy(overlayLayer); |
221 | 226 |
DifferenceVisitor visitor = new DifferenceVisitor(overlayLayer, |
222 | 227 |
featureProcessor, overlayStrategy, onlyClipLayerSelection); |
... | ... | |
228 | 233 |
strategy.process(visitor); |
229 | 234 |
} |
230 | 235 |
|
231 |
} catch (EditionException e) {
|
|
236 |
} catch (ProcessVisitorException e) {
|
|
232 | 237 |
throw new GeoprocessException( |
233 |
"Error al crear el esquema/fichero de la nueva capa");
|
|
234 |
} catch (DriverException e) { |
|
238 |
"Error al procesar el feature de una capa durante el geoproceso interseccion");
|
|
239 |
} catch (ReadDriverException e) {
|
|
235 | 240 |
throw new GeoprocessException( |
236 |
"Error de driver al calcular el geoproceso interseccion");
|
|
237 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
|
241 |
"Error de driver al calcular el geoproceso interseccion"); |
|
242 |
} catch (SchemaEditionException e) {
|
|
238 | 243 |
throw new GeoprocessException( |
239 |
"Error de driver al calcular el geoproceso interseccion");
|
|
240 |
} catch (VisitException e) {
|
|
244 |
"Error en el esquema de la nueva capa");
|
|
245 |
} catch (ExpansionFileReadException e) {
|
|
241 | 246 |
throw new GeoprocessException( |
242 |
"Error al procesar el feature de una capa durante el geoproceso interseccion"); |
|
247 |
"Error de driver al calcular el geoproceso interseccion"); |
|
248 |
} catch (VisitorException e) { |
|
249 |
throw new GeoprocessException( |
|
250 |
"Error de driver al calcular el geoproceso interseccion"); |
|
243 | 251 |
} |
244 | 252 |
} |
245 | 253 |
|
246 | 254 |
public void cancel() { |
247 | 255 |
try { |
248 | 256 |
schemaManager.removeSchema(""); |
249 |
} catch (EditionException e) { |
|
250 |
// FIXME (debe lanzar una excepcion cancel)
|
|
257 |
} catch (SchemaEditionException e) {
|
|
258 |
// TODO Auto-generated catch block
|
|
251 | 259 |
e.printStackTrace(); |
252 | 260 |
} |
253 | 261 |
} |
... | ... | |
275 | 283 |
return null; |
276 | 284 |
} |
277 | 285 |
} |
278 |
|
|
286 |
|
|
279 | 287 |
/** |
280 | 288 |
* IMonitorableTask that allows to run diff geoprocess in background, |
281 | 289 |
* with cancelation requests. |
282 |
*
|
|
290 |
* |
|
283 | 291 |
* @author azabala |
284 |
*
|
|
292 |
* |
|
285 | 293 |
*/ |
286 | 294 |
class DifferenceMonitorableTask implements IMonitorableTask { |
287 | 295 |
private CancellableMonitorable cancelMonitor = null; |
... | ... | |
297 | 305 |
cancelMonitor = createCancelMonitor(); |
298 | 306 |
} |
299 | 307 |
|
300 |
private CancellableMonitorable createCancelMonitor() |
|
301 |
throws DriverIOException { |
|
302 |
DefaultCancellableMonitorable monitor = new |
|
308 |
private CancellableMonitorable createCancelMonitor() { |
|
309 |
DefaultCancellableMonitorable monitor = new |
|
303 | 310 |
DefaultCancellableMonitorable(); |
304 | 311 |
monitor.setInitialStep(0); |
305 | 312 |
//Really its undeterminated, but so we must to process all |
306 |
//elements of first layer (or selection) we are going to
|
|
313 |
//elements of first layer (or selection) we are going to |
|
307 | 314 |
//consideer determinated |
308 | 315 |
monitor.setDeterminatedProcess(true); |
309 | 316 |
int numSteps = 0; |
... | ... | |
311 | 318 |
FBitSet selection = null; |
312 | 319 |
try { |
313 | 320 |
selection = firstLayer.getRecordset().getSelection(); |
314 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
|
321 |
} catch (ReadDriverException e) {
|
|
315 | 322 |
// TODO Auto-generated catch block |
316 | 323 |
e.printStackTrace(); |
317 | 324 |
} |
318 | 325 |
numSteps = selection.cardinality(); |
319 | 326 |
} else { |
320 |
numSteps = firstLayer.getSource().getShapeCount(); |
|
327 |
try { |
|
328 |
numSteps = firstLayer.getSource().getShapeCount(); |
|
329 |
} catch (ReadDriverException e) { |
|
330 |
// TODO Auto-generated catch block |
|
331 |
e.printStackTrace(); |
|
332 |
} |
|
321 | 333 |
} |
322 | 334 |
monitor.setFinalStep(numSteps); |
323 | 335 |
return monitor; |
... | ... | |
355 | 367 |
try { |
356 | 368 |
schemaManager.createSchema(createLayerDefinition()); |
357 | 369 |
writer.preProcess(); |
358 |
Strategy strategy =
|
|
370 |
Strategy strategy = |
|
359 | 371 |
StrategyManager.getStrategy(firstLayer); |
360 | 372 |
FeaturePersisterProcessor2 featureProcessor = |
361 | 373 |
new FeaturePersisterProcessor2(writer); |
362 |
Strategy overlayStrategy =
|
|
374 |
Strategy overlayStrategy = |
|
363 | 375 |
StrategyManager.getStrategy(overlayLayer); |
364 | 376 |
DifferenceVisitor visitor = new DifferenceVisitor(overlayLayer, |
365 | 377 |
featureProcessor, overlayStrategy, onlyClipLayerSelection); |
... | ... | |
371 | 383 |
strategy.process(visitor, cancelMonitor); |
372 | 384 |
} |
373 | 385 |
|
374 |
} catch (EditionException e) {
|
|
386 |
} catch (ProcessVisitorException e) {
|
|
375 | 387 |
throw new GeoprocessException( |
376 |
"Error al crear el esquema/fichero de la nueva capa");
|
|
377 |
} catch (DriverException e) {
|
|
388 |
"Error al procesar el feature de una capa durante el geoproceso interseccion");
|
|
389 |
} catch (SchemaEditionException e) {
|
|
378 | 390 |
throw new GeoprocessException( |
379 |
"Error de driver al calcular el geoproceso interseccion");
|
|
380 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
|
391 |
"Error al crear el esquema/fichero de la nueva capa");
|
|
392 |
} catch (ReadDriverException e) {
|
|
381 | 393 |
throw new GeoprocessException( |
382 |
"Error de driver al calcular el geoproceso interseccion");
|
|
383 |
} catch (VisitException e) {
|
|
394 |
"Error de driver al calcular el geoproceso interseccion"); |
|
395 |
} catch (ExpansionFileReadException e) {
|
|
384 | 396 |
throw new GeoprocessException( |
385 |
"Error al procesar el feature de una capa durante el geoproceso interseccion"); |
|
397 |
"Error de driver al calcular el geoproceso interseccion"); |
|
398 |
} catch (VisitorException e) { |
|
399 |
throw new GeoprocessException( |
|
400 |
"Error de driver al calcular el geoproceso interseccion"); |
|
386 | 401 |
}finally{ |
387 | 402 |
finished = true; |
388 | 403 |
} |
Also available in: Unified diff