Revision 329 org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.xyshift/src/main/java/org/gvsig/geoprocess/algorithm/xyshift/XYShiftAlgorithm.java

View differences:

XYShiftAlgorithm.java
44 44
 */
45 45
public class XYShiftAlgorithm extends AbstractSextanteGeoProcess {
46 46

  
47
	public static final String  RESULT    = "RESULT";
48
	public static final String  LAYER     = "LAYER";
49
	public static final String  CHECK     = "CHECK";
50
	public static final String  X         = "X";
51
	public static final String  Y         = "Y";
47
	public static final String  RESULT_POL      = "RESULT_POL";
48
	public static final String  RESULT_POINT    = "RESULT_POINT";
49
	public static final String  RESULT_LINE     = "RESULT_LINE";
50
	public static final String  LAYER           = "LAYER";
51
	public static final String  CHECK           = "CHECK";
52
	public static final String  X               = "X";
53
	public static final String  Y               = "Y";
52 54

  
53 55
	/*
54 56
	 * (non-Javadoc)
......
73 75
		} catch (RepeatedParameterNameException e) {
74 76
			Sextante.addErrorToLog(e);
75 77
		}
76
        addOutputVectorLayer(RESULT, getTranslation("XY-Shift"),
77
            OutputVectorLayer.SHAPE_TYPE_UNDEFINED);
78
		addOutputVectorLayer(RESULT_POL, getTranslation("XYShift_polygon"),
79
				OutputVectorLayer.SHAPE_TYPE_POLYGON);
80
		addOutputVectorLayer(RESULT_LINE, getTranslation("XYShift_line"),
81
				OutputVectorLayer.SHAPE_TYPE_LINE);
82
		addOutputVectorLayer(RESULT_POINT, getTranslation("XYShift_point"),
83
				OutputVectorLayer.SHAPE_TYPE_POINT);
78 84
	}
79
	
85

  
80 86
	/*
81 87
	 * (non-Javadoc)
82 88
	 * @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm()
83 89
	 */
84 90
	public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
85
		if(existsOutPutFile(XYShiftAlgorithm.RESULT, 0)) {
91
		if(existsOutPutFile(XYShiftAlgorithm.RESULT_POL, 0) || 
92
			existsOutPutFile(XYShiftAlgorithm.RESULT_LINE, 0) ||
93
			existsOutPutFile(XYShiftAlgorithm.RESULT_POINT, 0)) {
86 94
    		throw new GeoAlgorithmExecutionException(getTranslation("file_exists"));
87 95
    	}
88 96
		IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER);
......
100 108
			FeatureSet features = null;
101 109
			features = storeLayer.getFeatureSet();
102 110
			FeatureType featureType = features.getDefaultFeatureType();
103
            FeatureStore outFeatStore =
104
                buildOutPutStore(featureType, layer.getShapeType(),
105
                    getTranslation("XYShift"), RESULT);
106 111
			
107
			GeometryOperation operation = new XYShiftOperation(x, y, this);
108
            operation.setTaskStatus(getStatus());
109
			operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true);
112
			if (isPolygon(storeLayer) || isUndefined(storeLayer)) {
113
				FeatureStore outFeatStore =
114
					buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON,
115
							getTranslation("XYShift_polygon"), RESULT_POL);
116

  
117
				GeometryOperation operation = new XYShiftOperation(x, y, this);
118
				operation.setTaskStatus(getStatus());
119
				operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true);
120
			} else {
121
				buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON,
122
						getTranslation("Null_polygon"), RESULT_POL);
123
			}
124
			
125
			if (isLine(storeLayer) || isUndefined(storeLayer)) {
126
				FeatureStore outFeatStore =
127
					buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE,
128
							getTranslation("XYShift_line"), RESULT_LINE);
129

  
130
				GeometryOperation operation = new XYShiftOperation(x, y, this);
131
				operation.setTaskStatus(getStatus());
132
				operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true);
133
			} else {
134
				buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE,
135
						getTranslation("Null_line"), RESULT_LINE);
136
			}
137
			
138
			if (isPoint(storeLayer) || isUndefined(storeLayer)) {
139
				FeatureStore outFeatStore =
140
					buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT,
141
							getTranslation("XYShift_point"), RESULT_POINT);
142

  
143
				GeometryOperation operation = new XYShiftOperation(x, y, this);
144
				operation.setTaskStatus(getStatus());
145
				operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true);
146
			} else {
147
				buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT,
148
						getTranslation("Null_point"), RESULT_POINT);
149
			}
110 150
		} catch (DataException e) {
111 151
			Sextante.addErrorToLog(e);
112 152
			return false;

Also available in: Unified diff