Revision 10626 trunk/extensions/extGeoprocessingExtensions/src/com/iver/cit/gvsig/geoprocess/impl/xyshift/fmap/XYShifterFeatureVisitor.java

View differences:

XYShifterFeatureVisitor.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.2  2006-06-29 17:58:31  azabala
48
 * Revision 1.3  2007-03-06 16:48:14  caballero
49
 * Exceptions
50
 *
51
 * Revision 1.2  2006/06/29 17:58:31  azabala
49 52
 * *** empty log message ***
50 53
 *
51 54
 * Revision 1.1  2006/06/28 18:17:21  azabala
......
57 60

  
58 61
import java.awt.geom.AffineTransform;
59 62

  
63
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
60 64
import com.hardcode.gdbms.engine.values.Value;
61 65
import com.hardcode.gdbms.engine.values.ValueFactory;
62
import com.iver.cit.gvsig.fmap.DriverException;
66
import com.iver.cit.gvsig.exceptions.visitors.ProcessVisitorException;
67
import com.iver.cit.gvsig.exceptions.visitors.StartVisitorException;
68
import com.iver.cit.gvsig.exceptions.visitors.StopWriterVisitorException;
69
import com.iver.cit.gvsig.exceptions.visitors.VisitorException;
63 70
import com.iver.cit.gvsig.fmap.core.IFeature;
64 71
import com.iver.cit.gvsig.fmap.core.IGeometry;
65 72
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
66 73
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition;
67
import com.iver.cit.gvsig.fmap.edition.EditionException;
68 74
import com.iver.cit.gvsig.fmap.layers.FBitSet;
69 75
import com.iver.cit.gvsig.fmap.layers.FLayer;
70 76
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
71 77
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
72 78
import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData;
73 79
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor;
74
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException;
75 80
import com.iver.cit.gvsig.geoprocess.core.fmap.FeatureFactory;
76 81
import com.iver.cit.gvsig.geoprocess.core.fmap.FeatureProcessor;
77 82

  
78 83
/**
79 84
 * This visitor apply an xy offset to visited features and save the result.
80
 * 
85
 *
81 86
 * @author azabala
82
 * 
87
 *
83 88
 */
84 89
public class XYShifterFeatureVisitor implements FeatureVisitor {
85 90
	/**
......
91 96
	 * recordset of the source layer
92 97
	 */
93 98
	SelectableDataSource recordset;
94
	
99

  
95 100
	/**
96 101
	 * Schema of the result layer (the same that the input layer)
97 102
	 */
......
110 115

  
111 116
	/**
112 117
	 * Default constructor
113
	 * 
118
	 *
114 119
	 * @param featureProcessor
115 120
	 * @param selection
116 121
	 * @param dx
......
118 123
	 * @param dy
119 124
	 *            offset to apply in y direction
120 125
	 */
121
	public XYShifterFeatureVisitor(FeatureProcessor featureProcessor, 
126
	public XYShifterFeatureVisitor(FeatureProcessor featureProcessor,
122 127
										ILayerDefinition layerDef,
123 128
										double dx, double dy) {
124 129
		this.featureProcessor = featureProcessor;
125 130
		this.layerDefinition = layerDef;
126 131
		this.offsetTransform = createTransform(dx, dy);
127 132
	}
128
	
133

  
129 134
	public void setSelection(FBitSet selection){
130 135
		this.selection = selection;
131 136
	}
......
136 141
		return solution;
137 142
	}
138 143

  
139
	public void visit(IGeometry g, int index) throws VisitException {
144
	public void visit(IGeometry g, int index) throws VisitorException, StopWriterVisitorException, ProcessVisitorException {
140 145
		if(g == null)
141 146
			return;
142 147
		if(selection != null){
......
148 153
		IFeature newFeature;
149 154
		try {
150 155
			newFeature = createFeature(newGeometry, index);
151
		} catch (DriverException e) {
152
			throw new VisitException("Error al construir el feature de resultado");
153
		} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
154
			throw new VisitException("Error al construir el feature de resultado");
156
		} catch (ReadDriverException e) {
157
			throw new ProcessVisitorException(recordset.getName(),e,"Error al construir el feature de resultado");
155 158
		}
156 159
		featureProcessor.processFeature(newFeature);
157 160

  
158 161
	}
159 162

  
160
	private IFeature createFeature(IGeometry geometry, int layerIndex)
161
												throws DriverException, com.hardcode.gdbms.engine.data.driver.DriverException {
163
	private IFeature createFeature(IGeometry geometry, int layerIndex) throws ReadDriverException {
162 164
		IFeature solution = null;
163 165
		FieldDescription[] fields = layerDefinition.getFieldsDesc();
164 166
		Value[] featureAttr = new Value[fields.length];
......
186 188
		return "Apply a xy shift to IGeometry coordinates";
187 189
	}
188 190

  
189
	public void stop(FLayer layer) {
191
	public void stop(FLayer layer) throws StopWriterVisitorException, VisitorException {
190 192
		featureProcessor.finish();
191 193
	}
192 194

  
193
	public boolean start(FLayer layer) {
195
	public boolean start(FLayer layer) throws StartVisitorException {
194 196
		if (layer instanceof AlphanumericData && layer instanceof VectorialData) {
195 197
			try {
196 198
				this.recordset = ((AlphanumericData) layer).getRecordset();
197 199
				this.featureProcessor.start();
198
			} catch (DriverException e) {
200
			} catch (ReadDriverException e) {
199 201
				return false;// must we throw an Exception??
200
			} catch (EditionException e) {
201
				return false;
202 202
			}
203 203
			return true;
204 204
		}

Also available in: Unified diff