Revision 335
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.fusespatially/src/main/java/org/gvsig/geoprocess/algorithm/fusespatially/FuseSpatiallyOperationFast.java | ||
---|---|---|
119 | 119 |
FeatureStore outFeatStoreTable, |
120 | 120 |
String[] attrNames, |
121 | 121 |
String[] attrNamesTable, |
122 |
boolean selectedGeom, |
|
122 |
boolean selectedGeomInput, |
|
123 |
boolean selectedGeomOutput, |
|
123 | 124 |
String idField) throws DataException { |
124 | 125 |
this.outFeatStoreTable = outFeatStoreTable; |
125 | 126 |
this.nameIdField = idField; |
126 | 127 |
this.inFeatureStore = inFeatStore; |
127 |
this.selectedGeom = selectedGeom; |
|
128 |
this.selectedGeomInput = selectedGeomInput; |
|
129 |
this.selectedGeomOverlay = selectedGeomOutput; |
|
128 | 130 |
FeatureSet featuresSet = null; |
129 | 131 |
featuresSet = inFeatStore.getFeatureSet(); |
130 | 132 |
|
131 | 133 |
setFeatureStore(outFeatStore, attrNames); |
132 | 134 |
DisposableIterator it = null; |
133 | 135 |
|
134 |
if(selectedGeom) { |
|
136 |
if(selectedGeomInput) {
|
|
135 | 137 |
FeatureSelection ds = inFeatStore.getFeatureSelection(); |
136 | 138 |
it = ds.iterator(); |
137 | 139 |
numberOfFeatures = (int) ds.getSelectedCount(); |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.fusespatially/src/main/java/org/gvsig/geoprocess/algorithm/fusespatially/FuseSpatiallyAlgorithm.java | ||
---|---|---|
156 | 156 |
outFeatStoreTable, |
157 | 157 |
new String[]{fid}, |
158 | 158 |
attrNamesTable, |
159 |
selectedGeom, |
|
159 |
selectedGeom, |
|
160 |
false, |
|
160 | 161 |
idField); |
161 | 162 |
|
162 | 163 |
if(getTaskMonitor().isCanceled()) |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.intersection/src/main/java/org/gvsig/geoprocess/algorithm/intersection/IntersectionAlgorithm.java | ||
---|---|---|
164 | 164 |
getTranslation("Intersection_point"), RESULT_POINT); |
165 | 165 |
|
166 | 166 |
getStatus().setTitle("Point"); |
167 |
operation.computesGeometryOperation(storeLayer, outFeatStorePoint, attrNames, selectedGeom, true); |
|
167 |
operation.computesGeometryOperation(storeLayer, outFeatStorePoint, attrNames, |
|
168 |
selectedGeom, false, true); |
|
168 | 169 |
|
169 | 170 |
//La de pol?gonos solo si es intersecci?n entre pol?gonos |
170 | 171 |
if (isPolygon(storeLayer) && isPolygon(storeOverlay)) { |
... | ... | |
172 | 173 |
buildOutPutStoreFromUnion(featureType1, featureType2, |
173 | 174 |
IVectorLayer.SHAPE_TYPE_POLYGON, getTranslation("Intersection_polygon"), RESULT_POL); |
174 | 175 |
getStatus().setTitle("Polygon"); |
175 |
operation.computesGeometryOperation(storeLayer, outFeatStorePol, attrNames, selectedGeom, true); |
|
176 |
operation.computesGeometryOperation(storeLayer, outFeatStorePol, attrNames, |
|
177 |
selectedGeom, false, true); |
|
176 | 178 |
} |
177 | 179 |
|
178 | 180 |
//La capa de l?neas se genera cuando ning?na de las dos es de puntos |
... | ... | |
181 | 183 |
buildOutPutStoreFromUnion(featureType1, featureType2, |
182 | 184 |
IVectorLayer.SHAPE_TYPE_LINE, getTranslation("Intersection_line"), RESULT_LINE); |
183 | 185 |
getStatus().setTitle("Line"); |
184 |
operation.computesGeometryOperation(storeLayer, outFeatStoreLine, attrNames, selectedGeom, true); |
|
186 |
operation.computesGeometryOperation(storeLayer, outFeatStoreLine, attrNames, |
|
187 |
selectedGeom, false, true); |
|
185 | 188 |
} |
186 | 189 |
|
187 | 190 |
if(outFeatStorePol == null) { |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.clip/src/main/java/org/gvsig/geoprocess/algorithm/clip/ClipAlgorithm.java | ||
---|---|---|
100 | 100 |
boolean selectedGeom = m_Parameters.getParameter(CHECK).getParameterValueAsBoolean(); |
101 | 101 |
|
102 | 102 |
try { |
103 |
clippingGeometry = ScalableUnionOperation.joinLayerGeometries(clip); |
|
103 |
clippingGeometry = ScalableUnionOperation.joinLayerGeometries(clip, false);
|
|
104 | 104 |
} catch (Exception e) { |
105 | 105 |
Sextante.addErrorToLog(e); |
106 | 106 |
return false; |
... | ... | |
124 | 124 |
|
125 | 125 |
ClipOperation operation = new ClipOperation(clippingGeometry, this); |
126 | 126 |
operation.setTaskStatus(getStatus()); |
127 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
127 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, |
|
128 |
selectedGeom, false, true); |
|
128 | 129 |
} else { |
129 | 130 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
130 | 131 |
getTranslation("Null_polygon"), RESULT_POL); |
... | ... | |
137 | 138 |
|
138 | 139 |
ClipOperation operation = new ClipOperation(clippingGeometry, this); |
139 | 140 |
operation.setTaskStatus(getStatus()); |
140 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
141 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, |
|
142 |
selectedGeom, false, true); |
|
141 | 143 |
} else { |
142 | 144 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE, |
143 | 145 |
getTranslation("Null_line"), RESULT_LIN); |
... | ... | |
150 | 152 |
|
151 | 153 |
ClipOperation operation = new ClipOperation(clippingGeometry, this); |
152 | 154 |
operation.setTaskStatus(getStatus()); |
153 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
155 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, |
|
156 |
selectedGeom, false, true); |
|
154 | 157 |
} else { |
155 | 158 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POINT, |
156 | 159 |
getTranslation("Null_point"), RESULT_POINT); |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dissolve/src/main/java/org/gvsig/geoprocess/algorithm/dissolve/DissolveOperationFast.java | ||
---|---|---|
129 | 129 |
public void computesGeometryOperation(FeatureStore inFeatStore, |
130 | 130 |
FeatureStore outFeatStore, |
131 | 131 |
String[] attrNames, |
132 |
boolean selectedGeom, |
|
132 |
boolean selectedGeomInput, |
|
133 |
boolean selectedGeomOutput, |
|
133 | 134 |
boolean closeOutStore) throws DataException { |
134 | 135 |
this.inFeatureStore = inFeatStore; |
135 |
this.selectedGeom = selectedGeom; |
|
136 | 136 |
FeatureSet featuresSet = null; |
137 | 137 |
featuresSet = inFeatStore.getFeatureSet(); |
138 | 138 |
|
139 | 139 |
setFeatureStore(outFeatStore, attrNames); |
140 | 140 |
DisposableIterator it = null; |
141 | 141 |
|
142 |
if(selectedGeom) { |
|
142 |
if(selectedGeomInput) {
|
|
143 | 143 |
FeatureSelection ds = inFeatStore.getFeatureSelection(); |
144 | 144 |
it = ds.iterator(); |
145 | 145 |
numberOfFeatures = (int) ds.getSelectedCount(); |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dissolve/src/main/java/org/gvsig/geoprocess/algorithm/dissolve/DissolveOperation.java | ||
---|---|---|
67 | 67 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
68 | 68 |
*/ |
69 | 69 |
public class DissolveOperation extends GeometryOperation { |
70 |
private EditableFeature lastEditFeature = null; |
|
71 |
private ArrayList<Geometry> geometries = new ArrayList<Geometry>(); |
|
72 |
private IDissolveRule criteria = null; |
|
73 |
private AtomicDissolveOperation atomicOperation = null; |
|
70 |
private EditableFeature lastEditFeature = null; |
|
71 |
private ArrayList<Geometry> geometries = new ArrayList<Geometry>(); |
|
72 |
private IDissolveRule criteria = null; |
|
73 |
private AtomicDissolveOperation atomicOperation = null; |
|
74 |
|
|
74 | 75 |
/** |
75 | 76 |
* Cada elemento representa una feature del vectorial de entrada. Cuando se hace un dissolve de |
76 | 77 |
* esa feature con otra su posici?n en el array se pone a false para no volver a procesarla. |
... | ... | |
97 | 98 |
return lastEditFeature; |
98 | 99 |
getAtomicDissolveOperation().setFeature(feature); |
99 | 100 |
try { |
100 |
getAtomicDissolveOperation().computesOperation(selectedGeom); |
|
101 |
getAtomicDissolveOperation().computesOperation(selectedGeomInput);
|
|
101 | 102 |
EditableFeature res = (EditableFeature)getAtomicDissolveOperation().getResult(); |
102 | 103 |
lastEditFeature = persister.addFeature(res, res.getDefaultGeometry()); |
103 | 104 |
} catch (DataException e) { |
... | ... | |
143 | 144 |
public void computesGeometryOperation(FeatureStore inFeatStore, |
144 | 145 |
FeatureStore outFeatStore, |
145 | 146 |
String[] attrNames, |
146 |
boolean selectedGeom, |
|
147 |
boolean selectedGeomInput, |
|
148 |
boolean selectedGeomOutput, |
|
147 | 149 |
boolean closeOutStore) throws DataException { |
148 | 150 |
this.inFeatureStore = inFeatStore; |
149 |
this.selectedGeom = selectedGeom; |
|
151 |
this.selectedGeomInput = selectedGeomInput; |
|
152 |
this.selectedGeomOverlay = selectedGeomOutput; |
|
150 | 153 |
FeatureSet featuresSet = null; |
151 | 154 |
featuresSet = inFeatStore.getFeatureSet(); |
152 | 155 |
|
153 | 156 |
setFeatureStore(outFeatStore, attrNames); |
154 | 157 |
DisposableIterator it = null; |
155 | 158 |
|
156 |
if(selectedGeom) { |
|
159 |
if(selectedGeomInput) {
|
|
157 | 160 |
FeatureSelection ds = inFeatStore.getFeatureSelection(); |
158 | 161 |
it = ds.iterator(); |
159 | 162 |
numberOfFeatures = (int) ds.getSelectedCount(); |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dissolve/src/main/java/org/gvsig/geoprocess/algorithm/dissolve/DissolveAlgorithm.java | ||
---|---|---|
124 | 124 |
try { |
125 | 125 |
DissolveOperationFast operation = new DissolveOperationFast(criteria, this); |
126 | 126 |
operation.setTaskStatus(getStatus()); |
127 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
127 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, |
|
128 |
selectedGeom, false, true); |
|
128 | 129 |
} catch (DataException e) { |
129 | 130 |
Sextante.addErrorToLog(e); |
130 | 131 |
return false; |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.union/src/main/java/org/gvsig/geoprocess/algorithm/union/UnionAlgorithm.java | ||
---|---|---|
243 | 243 |
private void computesIntersection(FeatureStore storeLayer1, FeatureStore storeLayer2, FeatureStore featStoreOut, boolean selectedGeom, boolean close) throws DataException, WrongParameterTypeException, WrongParameterIDException, NullParameterValueException { |
244 | 244 |
GeometryOperation intersection = new IntersectionOperation(storeLayer2, this); |
245 | 245 |
intersection.setTaskStatus(getStatus()); |
246 |
intersection.computesGeometryOperation(storeLayer1, featStoreOut, attrNames, selectedGeom, close); |
|
246 |
intersection.computesGeometryOperation(storeLayer1, featStoreOut, attrNames, |
|
247 |
selectedGeom, false, close); |
|
247 | 248 |
} |
248 | 249 |
|
249 | 250 |
/** |
... | ... | |
259 | 260 |
* @throws NullParameterValueException |
260 | 261 |
*/ |
261 | 262 |
private void computesDifference(FeatureStore storeLayer1, FeatureStore storeLayer2, FeatureStore featStoreOut, boolean selectedGeom, boolean close) throws DataException, WrongParameterTypeException, WrongParameterIDException, NullParameterValueException { |
262 |
Geometry unionGeom1 = ScalableUnionOperation.joinLayerGeometries(storeLayer2); |
|
263 |
Geometry unionGeom1 = ScalableUnionOperation.joinLayerGeometries(storeLayer2, false);
|
|
263 | 264 |
GeometryOperation differenceL1_L2 = new DifferenceOperation(unionGeom1, this); |
264 | 265 |
differenceL1_L2.setTaskStatus(getStatus()); |
265 |
differenceL1_L2.computesGeometryOperation(storeLayer1, featStoreOut, attrNames, selectedGeom, close); |
|
266 |
differenceL1_L2.computesGeometryOperation(storeLayer1, featStoreOut, attrNames, |
|
267 |
selectedGeom, false, close); |
|
266 | 268 |
} |
267 | 269 |
|
268 | 270 |
} |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/java/org/gvsig/geoprocess/algorithm/buffer/BufferAlgorithm.java | ||
---|---|---|
194 | 194 |
|
195 | 195 |
operation.setTaskStatus(getStatus()); |
196 | 196 |
operation.computesGeometryOperation(storeLayer, outAuxFeatStore, |
197 |
attrNames, selectedGeom, true); |
|
197 |
attrNames, selectedGeom, false, true);
|
|
198 | 198 |
|
199 | 199 |
outAuxFeatStore = open(file, storeLayer.getDefaultFeatureType().getDefaultSRS()); |
200 | 200 |
FuseSpatiallyAlgorithm alg = new FuseSpatiallyAlgorithm(); |
... | ... | |
210 | 210 |
// Computes the operation |
211 | 211 |
operation.setTaskStatus(getStatus()); |
212 | 212 |
operation.computesGeometryOperation(storeLayer, outFeatStore, |
213 |
attrNames, selectedGeom, true); |
|
213 |
attrNames, selectedGeom, false, true);
|
|
214 | 214 |
} |
215 | 215 |
} catch (DataException e) { |
216 | 216 |
Sextante.addErrorToLog(e); |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.base/src/main/java/org/gvsig/geoprocess/algorithm/base/core/GeometryOperation.java | ||
---|---|---|
46 | 46 |
*/ |
47 | 47 |
@SuppressWarnings("deprecation") |
48 | 48 |
public abstract class GeometryOperation { |
49 |
protected DALFeaturePersister persister = null; |
|
50 |
protected FeatureStore inFeatureStore = null; |
|
51 |
protected ArrayList<FeatureStore> inFeatureStoreList = null; |
|
52 |
protected boolean selectedGeom = false; |
|
53 |
protected int numberOfFeatures = 0; |
|
54 |
protected EditableFeature lastEditFeature = null; |
|
55 |
protected SimpleTaskStatus status = null; |
|
56 |
protected AbstractSextanteGeoProcess process = null; |
|
57 |
protected int procesSize = 0; |
|
49 |
protected DALFeaturePersister persister = null; |
|
50 |
protected FeatureStore inFeatureStore = null; |
|
51 |
protected ArrayList<FeatureStore> inFeatureStoreList = null; |
|
52 |
protected int numberOfFeatures = 0; |
|
53 |
protected EditableFeature lastEditFeature = null; |
|
54 |
protected SimpleTaskStatus status = null; |
|
55 |
protected AbstractSextanteGeoProcess process = null; |
|
56 |
protected boolean selectedGeomInput = false; |
|
57 |
protected boolean selectedGeomOverlay = false; |
|
58 |
protected int procesSize = 0; |
|
58 | 59 |
|
59 | 60 |
public GeometryOperation(AbstractSextanteGeoProcess process) { |
60 | 61 |
this.process = process; |
61 | 62 |
} |
62 | 63 |
|
64 |
/** |
|
65 |
* Assigns the flag to use only the selected geometries |
|
66 |
* in the overlay layer |
|
67 |
*/ |
|
68 |
public void setSelectedGeomOverlayLayer(boolean setSelected) { |
|
69 |
this.selectedGeomOverlay = setSelected; |
|
70 |
} |
|
71 |
|
|
63 | 72 |
/** |
64 | 73 |
* Invokes this operation and returns an EditableFeature |
65 | 74 |
* @param g |
... | ... | |
109 | 118 |
public void computesGeometryOperation(FeatureStore inFeatStore, |
110 | 119 |
FeatureStore outFeatStore, |
111 | 120 |
String[] attrNames, |
112 |
boolean selectedGeom, |
|
121 |
boolean selectedGeomInput, |
|
122 |
boolean selectedGeomOverlay, |
|
113 | 123 |
boolean closeOutStore) throws DataException { |
114 | 124 |
this.inFeatureStore = inFeatStore; |
115 |
this.selectedGeom = selectedGeom; |
|
116 | 125 |
FeatureSet featuresSet = null; |
117 |
|
|
126 |
this.selectedGeomInput = selectedGeomInput; |
|
127 |
this.selectedGeomOverlay = selectedGeomOverlay; |
|
118 | 128 |
if(outFeatStore != null) |
119 | 129 |
setFeatureStore(outFeatStore, attrNames); |
120 | 130 |
DisposableIterator it = null; |
121 | 131 |
|
122 |
if(selectedGeom) { |
|
132 |
if(selectedGeomInput) {
|
|
123 | 133 |
featuresSet = (FeatureSet)inFeatStore.getSelection(); |
124 | 134 |
} else { |
125 | 135 |
featuresSet = inFeatStore.getFeatureSet(); |
... | ... | |
182 | 192 |
public void computesFeatureOperation(FeatureStore inFeatStore, |
183 | 193 |
FeatureStore outFeatStore, |
184 | 194 |
String[] attrNames, |
185 |
boolean selectedGeom, |
|
195 |
boolean selectedGeomInput, |
|
196 |
boolean selectedGeomOverlay, |
|
186 | 197 |
boolean closeOutStore) throws DataException { |
187 | 198 |
this.inFeatureStore = inFeatStore; |
188 |
this.selectedGeom = selectedGeom; |
|
189 | 199 |
FeatureSet featuresSet = null; |
190 | 200 |
featuresSet = inFeatStore.getFeatureSet(); |
201 |
this.selectedGeomInput = selectedGeomInput; |
|
202 |
this.selectedGeomOverlay = selectedGeomOverlay; |
|
191 | 203 |
|
192 | 204 |
if(outFeatStore != null) |
193 | 205 |
setFeatureStore(outFeatStore, attrNames); |
194 | 206 |
DisposableIterator it = null; |
195 | 207 |
|
196 |
if(selectedGeom) { |
|
208 |
if(selectedGeomInput) {
|
|
197 | 209 |
DataSet ds = inFeatStore.getSelection(); |
198 | 210 |
it = ((FeatureSelection) ds).fastIterator(); |
199 | 211 |
} else |
... | ... | |
236 | 248 |
public void computesGeometryOperationInAList(ArrayList<FeatureStore> inFeatStoreList, |
237 | 249 |
FeatureStore outFeatStore, |
238 | 250 |
String[] attrNames, |
239 |
boolean selectedGeom, |
|
251 |
boolean selectedGeomInput, |
|
252 |
boolean selectedGeomOverlay, |
|
240 | 253 |
boolean closeOutStore) throws DataException { |
241 | 254 |
this.inFeatureStoreList = inFeatStoreList; |
255 |
this.selectedGeomInput = selectedGeomInput; |
|
256 |
this.selectedGeomOverlay = selectedGeomOverlay; |
|
242 | 257 |
|
243 | 258 |
if (status != null && process != null) { |
244 | 259 |
status.setRangeOfValues(0, inFeatStoreList.size()); |
... | ... | |
255 | 270 |
computesGeometryOperation(inFeatStoreList.get(i), |
256 | 271 |
i == 0 ? outFeatStore : null, |
257 | 272 |
attrNames, |
258 |
selectedGeom, |
|
273 |
selectedGeomInput, |
|
274 |
selectedGeomOverlay, |
|
259 | 275 |
false); |
260 | 276 |
if(process.getTaskMonitor().isCanceled()) |
261 | 277 |
return; |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.base/src/main/java/org/gvsig/geoprocess/algorithm/base/core/ScalableUnionOperation.java | ||
---|---|---|
157 | 157 |
* @throws VisitorException |
158 | 158 |
* @throws ExpansionFileReadException |
159 | 159 |
*/ |
160 |
public static org.gvsig.fmap.geom.Geometry joinLayerGeometries(IVectorLayer input) throws WrongParameterTypeException, WrongParameterIDException, NullParameterValueException { |
|
160 |
public static org.gvsig.fmap.geom.Geometry joinLayerGeometries(IVectorLayer input, boolean selectedGeom) throws WrongParameterTypeException, WrongParameterIDException, NullParameterValueException {
|
|
161 | 161 |
FeatureStore store = null; |
162 | 162 |
|
163 | 163 |
if(input instanceof FlyrVectIVectorLayer) |
... | ... | |
165 | 165 |
else |
166 | 166 |
return null; |
167 | 167 |
|
168 |
return joinLayerGeometries(store); |
|
168 |
return joinLayerGeometries(store, selectedGeom);
|
|
169 | 169 |
} |
170 | 170 |
|
171 | 171 |
/** |
... | ... | |
182 | 182 |
* @throws ExpansionFileReadException |
183 | 183 |
*/ |
184 | 184 |
@SuppressWarnings({ "unchecked", "deprecation" }) |
185 |
public static org.gvsig.fmap.geom.Geometry joinLayerGeometries(FeatureStore store) throws WrongParameterTypeException, WrongParameterIDException, NullParameterValueException { |
|
185 |
public static org.gvsig.fmap.geom.Geometry joinLayerGeometries(FeatureStore store, boolean selectedGeom) throws WrongParameterTypeException, WrongParameterIDException, NullParameterValueException {
|
|
186 | 186 |
ScalableUnionOperation operation = new ScalableUnionOperation(); |
187 | 187 |
|
188 | 188 |
FeatureSet features = null; |
189 | 189 |
try { |
190 |
features = store.getFeatureSet(); |
|
190 |
if(selectedGeom) { |
|
191 |
features = (FeatureSet)store.getSelection(); |
|
192 |
} else { |
|
193 |
features = store.getFeatureSet(); |
|
194 |
} |
|
191 | 195 |
DisposableIterator it = features.iterator(); |
192 | 196 |
while( it.hasNext() ) { |
193 | 197 |
Feature feature = (Feature)it.next(); |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.difference/src/main/java/org/gvsig/geoprocess/algorithm/difference/DifferenceAlgorithm.java | ||
---|---|---|
43 | 43 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
44 | 44 |
*/ |
45 | 45 |
public class DifferenceAlgorithm extends AbstractSextanteGeoProcess { |
46 |
public static final String RESULT_POL = "RESULT_POL"; |
|
47 |
public static final String RESULT_POINT = "RESULT_POINT"; |
|
48 |
public static final String RESULT_LINE = "RESULT_LINE"; |
|
49 |
public static final String LAYER = "LAYER"; |
|
50 |
public static final String DIF = "DIF"; |
|
51 |
public static final String CHECK_INPUT = "CHECK_INPUT"; |
|
52 |
public static final String CHECK_OUTPUT = "CHECK_OUTPUT"; |
|
46 | 53 |
|
47 |
public static final String RESULT = "RESULT"; |
|
48 |
public static final String LAYER = "LAYER"; |
|
49 |
public static final String DIF = "DIF"; |
|
50 |
public static final String CHECK = "CHECK"; |
|
51 |
|
|
52 | 54 |
public void defineCharacteristics(){ |
53 | 55 |
setName(getTranslation("Difference")); |
54 | 56 |
setGroup(getTranslation("basic_vect_algorithms")); |
... | ... | |
61 | 63 |
m_Parameters.addInputVectorLayer(DIF, getTranslation("Overlays_layer"), |
62 | 64 |
IVectorLayer.SHAPE_TYPE_WRONG, |
63 | 65 |
true); |
64 |
m_Parameters.addBoolean(CHECK, |
|
66 |
m_Parameters.addBoolean(CHECK_INPUT,
|
|
65 | 67 |
getTranslation("Selected_geometries_input_layer"), false); |
68 |
m_Parameters.addBoolean(CHECK_OUTPUT, |
|
69 |
getTranslation("Selected_geometries_input_layer"), false); |
|
66 | 70 |
} catch (RepeatedParameterNameException e) { |
67 | 71 |
Sextante.addErrorToLog(e); |
68 | 72 |
} |
69 |
addOutputVectorLayer(RESULT, getTranslation("Difference"), |
|
70 |
OutputVectorLayer.SHAPE_TYPE_UNDEFINED); |
|
73 |
|
|
74 |
addOutputVectorLayer(RESULT_POL, getTranslation("Difference_polygon"), |
|
75 |
OutputVectorLayer.SHAPE_TYPE_POLYGON); |
|
76 |
addOutputVectorLayer(RESULT_LINE, getTranslation("Difference_line"), |
|
77 |
OutputVectorLayer.SHAPE_TYPE_LINE); |
|
78 |
addOutputVectorLayer(RESULT_POINT, getTranslation("Difference_point"), |
|
79 |
OutputVectorLayer.SHAPE_TYPE_POINT); |
|
71 | 80 |
} |
72 | 81 |
|
73 | 82 |
/* |
... | ... | |
75 | 84 |
* @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm() |
76 | 85 |
*/ |
77 | 86 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
78 |
if(existsOutPutFile(DifferenceAlgorithm.RESULT, 0)) { |
|
87 |
if(existsOutPutFile(RESULT_POL, 0) || |
|
88 |
existsOutPutFile(RESULT_LINE, 0) || |
|
89 |
existsOutPutFile(RESULT_POINT, 0)) { |
|
79 | 90 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
80 | 91 |
} |
81 | 92 |
org.gvsig.fmap.geom.Geometry overlayGeometry = null; |
82 | 93 |
IVectorLayer dif = m_Parameters.getParameterValueAsVectorLayer(DIF); |
83 | 94 |
IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER); |
84 |
boolean selectedGeom = m_Parameters.getParameter(CHECK).getParameterValueAsBoolean(); |
|
95 |
boolean selectedGeomInput = m_Parameters.getParameter(CHECK_INPUT).getParameterValueAsBoolean(); |
|
96 |
boolean selectedGeomOutput = m_Parameters.getParameter(CHECK_OUTPUT).getParameterValueAsBoolean(); |
|
85 | 97 |
|
86 | 98 |
try { |
87 |
overlayGeometry = ScalableUnionOperation.joinLayerGeometries(dif); |
|
99 |
overlayGeometry = ScalableUnionOperation.joinLayerGeometries(dif, selectedGeomOutput);
|
|
88 | 100 |
} catch (Exception e) { |
89 | 101 |
Sextante.addErrorToLog(e); |
90 | 102 |
return false; |
... | ... | |
100 | 112 |
FeatureSet features = null; |
101 | 113 |
features = storeLayer.getFeatureSet(); |
102 | 114 |
FeatureType featureType = features.getDefaultFeatureType(); |
103 |
FeatureStore outFeatStore = |
|
104 |
buildOutPutStore(featureType, layer.getShapeType(), |
|
105 |
getTranslation("Difference"), RESULT); |
|
106 |
|
|
115 |
|
|
107 | 116 |
GeometryOperation operation = new DifferenceOperation(overlayGeometry, this); |
108 | 117 |
operation.setTaskStatus(getStatus()); |
109 |
operation.computesGeometryOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
118 |
|
|
119 |
if (isPolygon(storeLayer) || isUndefined(storeLayer)) { |
|
120 |
FeatureStore outFeatStore = |
|
121 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
122 |
getTranslation("Difference_polygon"), RESULT_POL); |
|
123 |
|
|
124 |
operation.computesGeometryOperation(storeLayer, outFeatStore, |
|
125 |
attrNames, selectedGeomInput, selectedGeomOutput, true); |
|
126 |
} else { |
|
127 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
|
128 |
getTranslation("Null_polygon"), RESULT_POL); |
|
129 |
} |
|
130 |
|
|
131 |
if (isLine(storeLayer) || isUndefined(storeLayer)) { |
|
132 |
FeatureStore outFeatStore = |
|
133 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE, |
|
134 |
getTranslation("Difference_line"), RESULT_LINE); |
|
135 |
|
|
136 |
operation.computesGeometryOperation(storeLayer, outFeatStore, |
|
137 |
attrNames, selectedGeomInput, selectedGeomOutput, true); |
|
138 |
} else { |
|
139 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_LINE, |
|
140 |
getTranslation("Null_line"), RESULT_LINE); |
|
141 |
} |
|
142 |
|
|
143 |
if (isPoint(storeLayer) || isUndefined(storeLayer)) { |
|
144 |
FeatureStore outFeatStore = |
|
145 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
|
146 |
getTranslation("Difference_point"), RESULT_POINT); |
|
147 |
|
|
148 |
operation.computesGeometryOperation(storeLayer, outFeatStore, |
|
149 |
attrNames, selectedGeomInput, selectedGeomOutput, true); |
|
150 |
} else { |
|
151 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
|
152 |
getTranslation("Null_point"), RESULT_POINT); |
|
153 |
} |
|
154 |
|
|
110 | 155 |
} catch (DataException e) { |
111 | 156 |
Sextante.addErrorToLog(e); |
112 | 157 |
return false; |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.reproject/src/main/java/org/gvsig/geoprocess/algorithm/reproject/ReprojectAlgorithm.java | ||
---|---|---|
123 | 123 |
FeatureStore outFeatStore = |
124 | 124 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
125 | 125 |
getTranslation("Reproject_polygon"), RESULT_POL); |
126 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
126 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
127 |
selectedGeom, false, true); |
|
127 | 128 |
} else { |
128 | 129 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
129 | 130 |
getTranslation("Null_polygon"), RESULT_POL); |
... | ... | |
133 | 134 |
FeatureStore outFeatStore = |
134 | 135 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE, |
135 | 136 |
getTranslation("Reproject_line"), RESULT_LINE); |
136 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
137 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
138 |
selectedGeom, false, true); |
|
137 | 139 |
} else { |
138 | 140 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_LINE, |
139 | 141 |
getTranslation("Null_line"), RESULT_LINE); |
... | ... | |
143 | 145 |
FeatureStore outFeatStore = |
144 | 146 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
145 | 147 |
getTranslation("Reproject_point"), RESULT_POINT); |
146 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
148 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
149 |
selectedGeom, false, true); |
|
147 | 150 |
} else { |
148 | 151 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
149 | 152 |
getTranslation("Null_point"), RESULT_POINT); |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.spatialjoin/src/main/java/org/gvsig/geoprocess/algorithm/spatialjoin/SpatialJoinAlgorithm.java | ||
---|---|---|
176 | 176 |
outFeatStore, |
177 | 177 |
attrNames, |
178 | 178 |
selectedGeom, |
179 |
false, |
|
179 | 180 |
true); |
180 | 181 |
} catch (DataException e) { |
181 | 182 |
Sextante.addErrorToLog(e); |
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 | ||
---|---|---|
116 | 116 |
|
117 | 117 |
GeometryOperation operation = new XYShiftOperation(x, y, this); |
118 | 118 |
operation.setTaskStatus(getStatus()); |
119 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
119 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
120 |
selectedGeom, false, true); |
|
120 | 121 |
} else { |
121 | 122 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
122 | 123 |
getTranslation("Null_polygon"), RESULT_POL); |
... | ... | |
129 | 130 |
|
130 | 131 |
GeometryOperation operation = new XYShiftOperation(x, y, this); |
131 | 132 |
operation.setTaskStatus(getStatus()); |
132 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
133 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
134 |
selectedGeom, false, true); |
|
133 | 135 |
} else { |
134 | 136 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_LINE, |
135 | 137 |
getTranslation("Null_line"), RESULT_LINE); |
... | ... | |
142 | 144 |
|
143 | 145 |
GeometryOperation operation = new XYShiftOperation(x, y, this); |
144 | 146 |
operation.setTaskStatus(getStatus()); |
145 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true); |
|
147 |
operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, |
|
148 |
selectedGeom, false, true); |
|
146 | 149 |
} else { |
147 | 150 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
148 | 151 |
getTranslation("Null_point"), RESULT_POINT); |
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.merge/src/main/java/org/gvsig/geoprocess/algorithm/merge/MergeAlgorithm.java | ||
---|---|---|
91 | 91 |
*/ |
92 | 92 |
@SuppressWarnings("unchecked") |
93 | 93 |
public boolean processAlgorithm() throws GeoAlgorithmExecutionException { |
94 |
if(existsOutPutFile(MergeAlgorithm.RESULT_POL, 0) ||
|
|
95 |
existsOutPutFile(MergeAlgorithm.RESULT_LINE, 0) ||
|
|
96 |
existsOutPutFile(MergeAlgorithm.RESULT_POINT, 0)) {
|
|
94 |
if(existsOutPutFile(RESULT_POL, 0) || |
|
95 |
existsOutPutFile(RESULT_LINE, 0) || |
|
96 |
existsOutPutFile(RESULT_POINT, 0)) { |
|
97 | 97 |
throw new GeoAlgorithmExecutionException(getTranslation("file_exists")); |
98 | 98 |
} |
99 | 99 |
IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(FIELDLAYER); |
... | ... | |
142 | 142 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
143 | 143 |
getTranslation("Merge_polygon"), RESULT_POL); |
144 | 144 |
|
145 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, false, true); |
|
145 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, |
|
146 |
false, false, true); |
|
146 | 147 |
} else { |
147 | 148 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_POLYGON, |
148 | 149 |
getTranslation("Null_polygon"), RESULT_POL); |
... | ... | |
153 | 154 |
buildOutPutStore(featureType, IVectorLayer.SHAPE_TYPE_LINE, |
154 | 155 |
getTranslation("Merge_line"), RESULT_LINE); |
155 | 156 |
|
156 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, false, true); |
|
157 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, |
|
158 |
false, false, true); |
|
157 | 159 |
} else { |
158 | 160 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_LINE, |
159 | 161 |
getTranslation("Null_line"), RESULT_LINE); |
... | ... | |
164 | 166 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
165 | 167 |
getTranslation("Merge_point"), RESULT_POINT); |
166 | 168 |
|
167 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, false, true); |
|
169 |
operation.computesGeometryOperationInAList(featureStoreList, outFeatStore, attrNames, |
|
170 |
false, false, true); |
|
168 | 171 |
} else { |
169 | 172 |
buildOutPutStore(featureType.getCopy(), IVectorLayer.SHAPE_TYPE_POINT, |
170 | 173 |
getTranslation("Null_point"), RESULT_POINT); |
Also available in: Unified diff