Revision 10626 trunk/extensions/extGeoprocessingExtensions/src/com/iver/cit/gvsig/geoprocess/impl/reproject/fmap/ReprojectGeoprocess.java
ReprojectGeoprocess.java | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
* $Id$ |
47 | 47 |
* $Log$ |
48 |
* Revision 1.3 2006-08-11 17:20:32 azabala |
|
48 |
* Revision 1.4 2007-03-06 16:48:14 caballero |
|
49 |
* Exceptions |
|
50 |
* |
|
51 |
* Revision 1.3 2006/08/11 17:20:32 azabala |
|
49 | 52 |
* *** empty log message *** |
50 | 53 |
* |
51 | 54 |
* Revision 1.2 2006/07/04 16:43:18 azabala |
... | ... | |
65 | 68 |
import org.cresques.cts.gt2.CoordSys; |
66 | 69 |
|
67 | 70 |
|
71 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
68 | 72 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
69 | 73 |
import com.hardcode.gdbms.engine.values.Value; |
70 | 74 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
71 | 75 |
import com.iver.andami.PluginServices; |
76 |
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException; |
|
77 |
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException; |
|
78 |
import com.iver.cit.gvsig.exceptions.visitors.StopWriterVisitorException; |
|
79 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
|
72 | 80 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
73 | 81 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
74 | 82 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
75 | 83 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
76 | 84 |
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
77 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
|
78 | 85 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
79 | 86 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
80 | 87 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
... | ... | |
84 | 91 |
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor; |
85 | 92 |
import com.iver.cit.gvsig.fmap.operations.strategies.Strategy; |
86 | 93 |
import com.iver.cit.gvsig.fmap.operations.strategies.StrategyManager; |
87 |
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException; |
|
88 | 94 |
import com.iver.cit.gvsig.geoprocess.core.fmap.AbstractGeoprocess; |
89 | 95 |
import com.iver.cit.gvsig.geoprocess.core.fmap.DefinitionUtils; |
90 | 96 |
import com.iver.cit.gvsig.geoprocess.core.fmap.FeatureFactory; |
... | ... | |
115 | 121 |
* Target projection for features of the input layer |
116 | 122 |
*/ |
117 | 123 |
private IProjection targetProjection; |
118 |
|
|
124 |
|
|
119 | 125 |
ReprojectTask task = null; |
120 | 126 |
|
121 | 127 |
public ReprojectGeoprocess() { |
122 | 128 |
super(); |
123 | 129 |
} |
124 |
|
|
130 |
|
|
125 | 131 |
public void setFirstLayer(FLyrVect inputLayer){ |
126 | 132 |
this.firstLayer = inputLayer; |
127 | 133 |
} |
... | ... | |
160 | 166 |
try { |
161 | 167 |
resultLayerDefinition = DefinitionUtils |
162 | 168 |
.createLayerDefinition(super.firstLayer); |
163 |
} catch (DriverException e) { |
|
169 |
} catch (ReadDriverException e) {
|
|
164 | 170 |
// TODO Auto-generated catch block |
165 | 171 |
e.printStackTrace(); |
166 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) { |
|
167 |
// TODO Auto-generated catch block |
|
168 |
e.printStackTrace(); |
|
169 | 172 |
} |
170 | 173 |
} |
171 | 174 |
return resultLayerDefinition; |
... | ... | |
193 | 196 |
this.ct = coordTrans; |
194 | 197 |
} |
195 | 198 |
|
196 |
public void visit(IGeometry g, int index) throws VisitException { |
|
199 |
public void visit(IGeometry g, int index) throws VisitorException, StopWriterVisitorException, ProcessVisitorException {
|
|
197 | 200 |
if (g == null) |
198 | 201 |
return; |
199 | 202 |
if (selection != null) { |
... | ... | |
204 | 207 |
IFeature feature = null; |
205 | 208 |
try { |
206 | 209 |
feature = createFeature(g, index); |
207 |
} catch (DriverException e) { |
|
208 |
throw new VisitException("Error al crear al reproyectar "+index, e);
|
|
210 |
} catch (ReadDriverException e) {
|
|
211 |
throw new ProcessVisitorException(recordset.getName(),e,"Error al crear al reproyectar "+index);
|
|
209 | 212 |
} |
210 | 213 |
processor.processFeature(feature); |
211 | 214 |
} |
... | ... | |
214 | 217 |
return ""; |
215 | 218 |
} |
216 | 219 |
|
217 |
public void stop(FLayer layer) { |
|
220 |
public void stop(FLayer layer) throws StopWriterVisitorException, VisitorException {
|
|
218 | 221 |
processor.finish(); |
219 | 222 |
} |
220 | 223 |
|
221 |
public boolean start(FLayer layer) { |
|
224 |
public boolean start(FLayer layer) throws StartVisitorException {
|
|
222 | 225 |
if (layer instanceof AlphanumericData |
223 | 226 |
&& layer instanceof VectorialData) { |
224 | 227 |
try { |
225 | 228 |
this.recordset = ((AlphanumericData) layer).getRecordset(); |
226 | 229 |
this.processor.start(); |
227 |
} catch (EditionException e) {
|
|
230 |
} catch (ReadDriverException e) {
|
|
228 | 231 |
return false; |
229 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) { |
|
230 |
return false; |
|
231 | 232 |
} |
232 | 233 |
return true; |
233 | 234 |
} |
... | ... | |
235 | 236 |
} |
236 | 237 |
|
237 | 238 |
private IFeature createFeature(IGeometry geometry, int layerIndex) |
238 |
throws DriverException, |
|
239 |
com.hardcode.gdbms.engine.data.driver.DriverException { |
|
239 |
throws ReadDriverException { |
|
240 | 240 |
IFeature solution = null; |
241 | 241 |
FieldDescription[] fields = layerDefinition.getFieldsDesc(); |
242 | 242 |
Value[] featureAttr = new Value[fields.length]; |
... | ... | |
275 | 275 |
int numShapes = firstLayer.getSource().getShapeCount(); |
276 | 276 |
setFinalStep(numShapes); |
277 | 277 |
}// else |
278 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
|
278 |
} catch (ReadDriverException e) {
|
|
279 | 279 |
// TODO Auto-generated catch block |
280 | 280 |
e.printStackTrace(); |
281 |
} catch (DriverIOException e) { |
|
282 |
// TODO Auto-generated catch block |
|
283 |
e.printStackTrace(); |
|
284 | 281 |
} |
285 | 282 |
setDeterminatedProcess(true); |
286 | 283 |
setStatusMessage(PluginServices.getText(this, |
... | ... | |
296 | 293 |
selection = firstLayer.getRecordset().getSelection(); |
297 | 294 |
IProjection from = firstLayer.getProjection(); |
298 | 295 |
IProjection to = targetProjection; |
299 |
|
|
296 |
|
|
300 | 297 |
// ICoordTrans ct = new CoordTrans((CoordSys) to, (CoordSys) from); |
301 | 298 |
ICoordTrans ct = from.getCT((CoordSys)to); |
302 |
ReprojectVisitor visitor = new ReprojectVisitor(resultLayerDefinition,
|
|
299 |
ReprojectVisitor visitor = new ReprojectVisitor(resultLayerDefinition, |
|
303 | 300 |
processor, selection, ct); |
304 | 301 |
Strategy strategy = StrategyManager.getStrategy(firstLayer); |
305 | 302 |
try { |
Also available in: Unified diff