Revision 10626 trunk/extensions/extGeoProcessing/src/com/iver/cit/gvsig/geoprocess/impl/merge/fmap/MergeGeoprocess.java
MergeGeoprocess.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.3 2006-07-26 17:22:23 azabala |
|
48 |
* Revision 1.4 2007-03-06 16:47:58 caballero |
|
49 |
* Exceptions |
|
50 |
* |
|
51 |
* Revision 1.3 2006/07/26 17:22:23 azabala |
|
49 | 52 |
* createTask and process method are consistent now |
50 | 53 |
* |
51 | 54 |
* Revision 1.2 2006/06/29 07:33:57 fjp |
... | ... | |
81 | 84 |
|
82 | 85 |
import java.util.Map; |
83 | 86 |
|
87 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
88 |
import com.hardcode.gdbms.driver.exceptions.SchemaEditionException; |
|
84 | 89 |
import com.iver.andami.PluginServices; |
85 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
90 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
|
91 |
import com.iver.cit.gvsig.exceptions.visitors.StartWriterVisitorException; |
|
92 |
import com.iver.cit.gvsig.exceptions.visitors.StopWriterVisitorException; |
|
93 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
86 | 94 |
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
87 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
|
88 | 95 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
89 | 96 |
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
90 | 97 |
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager; |
91 |
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException; |
|
92 | 98 |
import com.iver.cit.gvsig.geoprocess.core.fmap.AbstractGeoprocess; |
93 | 99 |
import com.iver.cit.gvsig.geoprocess.core.fmap.DeferredFeaturePersisterProcessor; |
94 | 100 |
import com.iver.cit.gvsig.geoprocess.core.fmap.DefinitionUtils; |
... | ... | |
99 | 105 |
/** |
100 | 106 |
* This geoprocess is "equivalent" to UNION relational operator. |
101 | 107 |
* Output layer will have a geometry for each geometry of input layer. |
102 |
*
|
|
108 |
* |
|
103 | 109 |
* Also, output layer will preserve a schema of one of input layers. |
104 | 110 |
* @author azabala |
105 |
*
|
|
111 |
* |
|
106 | 112 |
* FIXME Hereda de AbstractGeoprocess firstLayer. REVISAR |
107 | 113 |
* |
108 | 114 |
*/ |
... | ... | |
116 | 122 |
*/ |
117 | 123 |
private FLyrVect outputSchemaLayer; |
118 | 124 |
private ILayerDefinition resultLayerDefinition; |
119 |
|
|
125 |
|
|
120 | 126 |
public MergeGeoprocess(){ |
121 |
|
|
127 |
|
|
122 | 128 |
} |
123 |
|
|
129 |
|
|
124 | 130 |
public void setParameters(Map params) throws GeoprocessException { |
125 | 131 |
} |
126 | 132 |
|
... | ... | |
138 | 144 |
if(inputLayers[i].getShapeType() != shapeType) |
139 | 145 |
throw new GeoprocessException("Las capas a juntar deben tener el mismo tipo de geometria"); |
140 | 146 |
} |
141 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
|
147 |
} catch (ReadDriverException e) {
|
|
142 | 148 |
throw new GeoprocessException("Error al tratar de determinar el tipo de geometria de las capas a mezclar"); |
143 | 149 |
} |
144 | 150 |
} |
... | ... | |
154 | 160 |
public void cancel() { |
155 | 161 |
try { |
156 | 162 |
schemaManager.removeSchema(""); |
157 |
} catch (EditionException e) { |
|
163 |
} catch (SchemaEditionException e) {
|
|
158 | 164 |
// TODO Auto-generated catch block |
159 | 165 |
e.printStackTrace(); |
160 | 166 |
} |
... | ... | |
164 | 170 |
if(this.resultLayerDefinition == null) |
165 | 171 |
{ |
166 | 172 |
try { |
167 |
this.resultLayerDefinition =
|
|
173 |
this.resultLayerDefinition = |
|
168 | 174 |
DefinitionUtils. |
169 | 175 |
createLayerDefinition(this.outputSchemaLayer); |
170 | 176 |
} catch (Exception e) { |
... | ... | |
185 | 191 |
} |
186 | 192 |
|
187 | 193 |
public IMonitorableTask createTask() { |
188 |
try { |
|
189 |
return new MergeMonitorableTask(); |
|
190 |
} catch (DriverIOException e) {
|
|
191 |
return null; |
|
192 |
} |
|
194 |
try {
|
|
195 |
return new MergeMonitorableTask();
|
|
196 |
} catch (ReadDriverException e) {
|
|
197 |
return null;
|
|
198 |
}
|
|
193 | 199 |
} |
194 |
|
|
200 |
|
|
195 | 201 |
class MergeMonitorableTask implements IMonitorableTask { |
196 | 202 |
private CancellableMonitorable cancelMonitor = null; |
197 | 203 |
String MERGE_MESSAGE = PluginServices.getText(this, "Mensaje_juntar"); |
... | ... | |
199 | 205 |
String OF = PluginServices.getText(this, "De"); |
200 | 206 |
private boolean finished = false; |
201 | 207 |
|
202 |
MergeMonitorableTask() throws DriverIOException {
|
|
208 |
MergeMonitorableTask() throws ReadDriverException {
|
|
203 | 209 |
initialize(); |
204 | 210 |
} |
205 |
void initialize() throws DriverIOException {
|
|
211 |
void initialize() throws ReadDriverException {
|
|
206 | 212 |
cancelMonitor = createCancelMonitor(); |
207 | 213 |
} |
208 | 214 |
|
209 |
private CancellableMonitorable createCancelMonitor() |
|
210 |
throws DriverIOException { |
|
211 |
DefaultCancellableMonitorable monitor = new |
|
215 |
private CancellableMonitorable createCancelMonitor() throws ReadDriverException { |
|
216 |
DefaultCancellableMonitorable monitor = new |
|
212 | 217 |
DefaultCancellableMonitorable(); |
213 | 218 |
monitor.setInitialStep(0); |
214 | 219 |
monitor.setDeterminatedProcess(true); |
... | ... | |
252 | 257 |
new DeferredFeaturePersisterProcessor(writer); |
253 | 258 |
try { |
254 | 259 |
writer.preProcess(); |
255 |
} catch (EditionException e1) {
|
|
260 |
} catch (StartWriterVisitorException e1) {
|
|
256 | 261 |
finished = true; |
257 | 262 |
throw new GeoprocessException("Error al preparar la capa resultado"); |
258 | 263 |
} |
259 |
MergeVisitor merge = new MergeVisitor(createLayerDefinition(),
|
|
264 |
MergeVisitor merge = new MergeVisitor(createLayerDefinition(), |
|
260 | 265 |
processor); |
261 | 266 |
for(int i = 0; i < inputLayers.length; i++){ |
262 | 267 |
Strategy strategy = StrategyManager. |
263 | 268 |
getStrategy(inputLayers[i]); |
264 | 269 |
try { |
265 | 270 |
strategy.process(merge, cancelMonitor); |
266 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
|
271 |
} catch (ReadDriverException e) {
|
|
267 | 272 |
finished = true; |
268 | 273 |
throw new GeoprocessException("Merge: error al leer la capa "+inputLayers[i].getName()); |
269 |
} catch (VisitException e) {
|
|
274 |
} catch (ProcessVisitorException e) {
|
|
270 | 275 |
finished = true; |
271 | 276 |
throw new GeoprocessException("Merge: error al procesar la capa "+inputLayers[i].getName()); |
277 |
} catch (VisitorException e) { |
|
278 |
finished = true; |
|
279 |
throw new GeoprocessException("Merge: error al procesar la capa "+inputLayers[i].getName()); |
|
272 | 280 |
} |
273 | 281 |
}//for |
274 | 282 |
try { |
275 | 283 |
writer.postProcess(); |
276 |
} catch (EditionException e) {
|
|
284 |
} catch (StopWriterVisitorException e) {
|
|
277 | 285 |
finished = true; |
278 | 286 |
throw new GeoprocessException("Error al preparar la capa resultado"); |
279 | 287 |
} |
280 | 288 |
finished = true; |
281 |
|
|
289 |
|
|
282 | 290 |
} |
283 | 291 |
|
284 | 292 |
public boolean isDefined() { |
Also available in: Unified diff