Revision 3954 org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/MustNotOverlapPolygonRule.java
MustNotOverlapPolygonRule.java | ||
---|---|---|
24 | 24 |
package org.gvsig.topology.rule; |
25 | 25 |
|
26 | 26 |
import org.gvsig.expressionevaluator.Expression; |
27 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
28 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
|
29 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
|
30 | 27 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
31 | 28 |
import org.gvsig.expressionevaluator.GeometryExpressionBuilder; |
32 | 29 |
import org.gvsig.expressionevaluator.GeometryExpressionUtils; |
30 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
33 | 31 |
import org.gvsig.fmap.dal.feature.Feature; |
34 | 32 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
35 | 33 |
import org.gvsig.fmap.geom.Geometry; |
... | ... | |
71 | 69 |
@Override |
72 | 70 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) { |
73 | 71 |
try { |
74 |
// TODO |
|
72 |
Geometry errorGeom = line.getError(); |
|
73 |
TopologyDataSet dataSet = rule.getDataSet1(); |
|
74 |
|
|
75 |
for (FeatureReference reference : dataSet.query(errorGeom)) { |
|
76 |
Feature initialFeature = reference.getFeature(); |
|
77 |
Geometry initialFeatureGeom = initialFeature.getDefaultGeometry(); |
|
78 |
// initialFeature1.getEditable(); |
|
79 |
if (initialFeatureGeom.intersects(errorGeom)) { |
|
80 |
Geometry targetFeatureGeom = initialFeatureGeom.difference(errorGeom); |
|
81 |
EditableFeature targetFeature = dataSet.createNewFeature(); |
|
82 |
targetFeature.copyFrom(initialFeature); |
|
83 |
targetFeature.setDefaultGeometry(targetFeatureGeom); |
|
84 |
dataSet.insert(targetFeature); |
|
85 |
dataSet.delete(reference); |
|
86 |
} |
|
87 |
} |
|
88 |
EditableFeature newFeature = dataSet.createNewFeature(); |
|
89 |
newFeature.setDefaultGeometry(errorGeom); |
|
90 |
dataSet.insert(newFeature); |
|
91 |
|
|
75 | 92 |
} catch (Exception ex) { |
76 | 93 |
throw new ExecuteTopologyRuleActionException(ex); |
77 | 94 |
} |
... | ... | |
97 | 114 |
@Override |
98 | 115 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) { |
99 | 116 |
try { |
100 |
// TODO |
|
117 |
Geometry errorGeom = line.getError(); |
|
118 |
TopologyDataSet dataSet = rule.getDataSet1(); |
|
119 |
|
|
120 |
for (FeatureReference reference : dataSet.query(errorGeom)) { |
|
121 |
Feature initialFeature = reference.getFeature(); |
|
122 |
Geometry initialFeatureGeom = initialFeature.getDefaultGeometry(); |
|
123 |
// initialFeature1.getEditable(); |
|
124 |
if (initialFeatureGeom.intersects(errorGeom)) { |
|
125 |
Geometry targetFeatureGeom = initialFeatureGeom.difference(errorGeom); |
|
126 |
EditableFeature targetFeature = dataSet.createNewFeature(); |
|
127 |
targetFeature.copyFrom(initialFeature); |
|
128 |
targetFeature.setDefaultGeometry(targetFeatureGeom); |
|
129 |
dataSet.insert(targetFeature); |
|
130 |
dataSet.delete(reference); |
|
131 |
} |
|
132 |
} |
|
101 | 133 |
} catch (Exception ex) { |
102 | 134 |
throw new ExecuteTopologyRuleActionException(ex); |
103 | 135 |
} |
104 | 136 |
} |
105 |
|
|
106 | 137 |
} |
107 | 138 |
|
108 | 139 |
private class MergeAction extends AbstractTopologyRuleAction { |
... | ... | |
121 | 152 |
); |
122 | 153 |
} |
123 | 154 |
|
155 |
// @Override |
|
156 |
// public boolean hasParameters() { |
|
157 |
// return true; |
|
158 |
// } |
|
159 |
// |
|
160 |
// @Override |
|
161 |
// public DynObject createParameters() { |
|
162 |
// DynObjectManager dynObjectManager = ToolsLocator.getDynObjectManager(); |
|
163 |
// DynClass parametersDefinition = dynObjectManager.createDynClass("MustNotOverlapPolygonRulActionParameters","MustNotOverlapPolygonRulActionParameters"); |
|
164 |
// parametersDefinition.addDynFieldString("polygonToApply").setDescription("Polygon to apply topology rule action"); |
|
165 |
// DynObject ruleActionParameters = dynObjectManager.createDynObject(parametersDefinition); |
|
166 |
// //rellenar el desplegable con la lista de poligoos que se superponen |
|
167 |
// return ruleActionParameters; |
|
168 |
// } |
|
169 |
|
|
124 | 170 |
@Override |
125 | 171 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) { |
126 | 172 |
try { |
127 |
// TODO |
|
173 |
Geometry errorGeom = line.getError(); |
|
174 |
TopologyDataSet dataSet = rule.getDataSet1(); |
|
175 |
|
|
176 |
Feature initialFeature1 = line.getFeature1().getFeature(); |
|
177 |
EditableFeature targetFeature1 = dataSet.createNewFeature(); |
|
178 |
targetFeature1.copyFrom(initialFeature1); |
|
179 |
|
|
180 |
Feature initialFeature2 = line.getFeature2().getFeature(); |
|
181 |
EditableFeature targetFeature2 = dataSet.createNewFeature(); |
|
182 |
targetFeature2.copyFrom(initialFeature2); |
|
183 |
|
|
184 |
Geometry initialFeature1Geom = initialFeature1.getDefaultGeometry(); |
|
185 |
// Geometry targetFeature1Geom = initialFeature1Geom.union(errorGeom); |
|
186 |
|
|
187 |
Geometry initialFeature2Geom = initialFeature2.getDefaultGeometry(); |
|
188 |
Geometry targetFeature2Geom = initialFeature2Geom.difference(initialFeature1Geom); |
|
189 |
|
|
190 |
// targetFeature1.setDefaultGeometry(targetFeature1Geom); |
|
191 |
targetFeature2.setDefaultGeometry(targetFeature2Geom); |
|
192 |
|
|
193 |
// dataSet.insert(targetFeature1); |
|
194 |
dataSet.insert(targetFeature2); |
|
195 |
|
|
196 |
dataSet.delete(line.getFeature1()); |
|
197 |
dataSet.delete(line.getFeature2()); |
|
198 |
|
|
128 | 199 |
} catch (Exception ex) { |
129 | 200 |
throw new ExecuteTopologyRuleActionException(ex); |
130 | 201 |
} |
131 | 202 |
} |
203 |
|
|
132 | 204 |
} |
133 | 205 |
|
134 | 206 |
private String geomName; |
... | ... | |
175 | 247 |
polygon, |
176 | 248 |
error, |
177 | 249 |
feature1.getReference(), |
178 |
null,
|
|
250 |
reference,
|
|
179 | 251 |
false, |
180 | 252 |
"The polygon overlay with others." |
181 | 253 |
); |
182 |
break; |
|
254 |
// break;
|
|
183 | 255 |
} |
184 | 256 |
} |
185 | 257 |
} else { |
... | ... | |
206 | 278 |
polygon, |
207 | 279 |
error, |
208 | 280 |
feature1.getReference(), |
209 |
null,
|
|
281 |
feature.getReference(),
|
|
210 | 282 |
false, |
211 | 283 |
"The polygon overlay with others." |
212 | 284 |
); |
Also available in: Unified diff