Revision 725 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 | ||
---|---|---|
28 | 28 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
29 | 29 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
30 | 30 |
import org.gvsig.fmap.dal.feature.Feature; |
31 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
33 | 32 |
import org.gvsig.fmap.geom.Geometry; |
34 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
35 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
36 | 33 |
import org.gvsig.tools.dynobject.DynObject; |
37 | 34 |
import org.gvsig.tools.task.SimpleTaskStatus; |
38 | 35 |
import org.gvsig.topology.lib.spi.AbstractTopologyRule; |
... | ... | |
60 | 57 |
"CreateFeature", |
61 | 58 |
"Create Feature", |
62 | 59 |
"The Create Feature fix creates a new polygon feature out " |
63 |
+ "of the error shape and removes the portion of "
|
|
64 |
+ "overlap from each of the features, causing the "
|
|
65 |
+ "error to create a planar representation of the "
|
|
66 |
+ "feature geometry. This fix can be applied to "
|
|
67 |
+ "one or more selected Must Not Overlap errors."
|
|
60 |
+ "of the error shape and removes the portion of " |
|
61 |
+ "overlap from each of the features, causing the " |
|
62 |
+ "error to create a planar representation of the " |
|
63 |
+ "feature geometry. This fix can be applied to " |
|
64 |
+ "one or more selected Must Not Overlap errors." |
|
68 | 65 |
); |
69 | 66 |
} |
70 | 67 |
|
71 | 68 |
@Override |
72 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
|
|
69 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) { |
|
73 | 70 |
try { |
74 | 71 |
// TODO |
75 | 72 |
} catch (Exception ex) { |
... | ... | |
87 | 84 |
"Subtract", |
88 | 85 |
"Subtract", |
89 | 86 |
"The Subtract fix removes the overlapping portion of " |
90 |
+ "geometry from each feature that is causing the "
|
|
91 |
+ "error and leaves a gap or void in its place. "
|
|
92 |
+ "This fix can be applied to one or more selected "
|
|
93 |
+ "Must Not Overlap errors."
|
|
87 |
+ "geometry from each feature that is causing the " |
|
88 |
+ "error and leaves a gap or void in its place. " |
|
89 |
+ "This fix can be applied to one or more selected " |
|
90 |
+ "Must Not Overlap errors." |
|
94 | 91 |
); |
95 | 92 |
} |
96 | 93 |
|
97 | 94 |
@Override |
98 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
|
|
95 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) { |
|
99 | 96 |
try { |
100 | 97 |
// TODO |
101 | 98 |
} catch (Exception ex) { |
... | ... | |
113 | 110 |
"Merge", |
114 | 111 |
"Merge", |
115 | 112 |
"The Merge fix adds the portion of overlap from one feature " |
116 |
+ "and subtracts it from the others that are "
|
|
117 |
+ "violating the rule. You need to pick the feature "
|
|
118 |
+ "that receives the portion of overlap using the "
|
|
119 |
+ "Merge dialog box. This fix can be applied to one "
|
|
120 |
+ "Must Not Overlap error only."
|
|
113 |
+ "and subtracts it from the others that are " |
|
114 |
+ "violating the rule. You need to pick the feature " |
|
115 |
+ "that receives the portion of overlap using the " |
|
116 |
+ "Merge dialog box. This fix can be applied to one " |
|
117 |
+ "Must Not Overlap error only." |
|
121 | 118 |
); |
122 | 119 |
} |
123 | 120 |
|
124 | 121 |
@Override |
125 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
|
|
122 |
public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) { |
|
126 | 123 |
try { |
127 | 124 |
// TODO |
128 | 125 |
} catch (Exception ex) { |
... | ... | |
130 | 127 |
} |
131 | 128 |
} |
132 | 129 |
} |
133 |
|
|
130 |
|
|
134 | 131 |
private String geomName; |
135 | 132 |
private Expression expression = null; |
136 | 133 |
private ExpressionBuilder expressionBuilder = null; |
137 |
|
|
134 |
|
|
138 | 135 |
public MustNotOverlapPolygonRule( |
139 | 136 |
TopologyPlan plan, |
140 | 137 |
TopologyRuleFactory factory |
... | ... | |
144 | 141 |
this.addAction(new MergeAction()); |
145 | 142 |
this.addAction(new SubtractAction()); |
146 | 143 |
} |
147 |
|
|
144 |
|
|
148 | 145 |
public MustNotOverlapPolygonRule( |
149 | 146 |
TopologyPlan plan, |
150 | 147 |
TopologyRuleFactory factory, |
... | ... | |
160 | 157 |
@Override |
161 | 158 |
protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature1) throws Exception { |
162 | 159 |
try { |
163 |
if( this.expression == null ) {
|
|
160 |
if (this.expression == null) {
|
|
164 | 161 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
165 | 162 |
this.expression = manager.createExpression(); |
166 | 163 |
this.expressionBuilder = manager.createExpressionBuilder(); |
167 | 164 |
this.geomName = feature1.getType().getDefaultGeometryAttributeName(); |
168 |
}
|
|
165 |
} |
|
169 | 166 |
Geometry polygon = feature1.getDefaultGeometry(); |
170 |
this.expression.setPhrase( |
|
171 |
this.expressionBuilder.ifnull( |
|
172 |
this.expressionBuilder.column(this.geomName), |
|
173 |
this.expressionBuilder.constant(false), |
|
174 |
this.expressionBuilder.ST_Overlaps( |
|
175 |
this.expressionBuilder.column(this.geomName), |
|
176 |
this.expressionBuilder.geometry(polygon) |
|
177 |
) |
|
178 |
).toString() |
|
179 |
); |
|
180 |
FeatureStore store = this.getDataSet1().getStore(); |
|
181 |
FeatureSet set = null; |
|
182 |
DisposableIterator it = null; |
|
183 |
try { |
|
184 |
Feature f = store.findFirst(this.expression); |
|
185 |
if( f!=null ) { |
|
167 |
if( polygon==null ) { |
|
168 |
return; |
|
169 |
} |
|
170 |
TopologyDataSet theDataSet = this.getDataSet1(); |
|
171 |
if (theDataSet.getSpatialIndex() != null) { |
|
172 |
for (FeatureReference reference : theDataSet.query(polygon)) { |
|
173 |
if (reference.equals(feature1.getReference())) { |
|
174 |
continue; |
|
175 |
} |
|
176 |
Feature feature = reference.getFeature(); |
|
177 |
if (polygon.overlaps(feature.getDefaultGeometry())) { |
|
178 |
report.addLine(this, |
|
179 |
theDataSet, |
|
180 |
null, |
|
181 |
polygon, |
|
182 |
feature1.getReference(), |
|
183 |
null, |
|
184 |
false, |
|
185 |
"The polygon overlay with others." |
|
186 |
); |
|
187 |
break; |
|
188 |
} |
|
189 |
} |
|
190 |
} else { |
|
191 |
this.expression.setPhrase( |
|
192 |
this.expressionBuilder.ifnull( |
|
193 |
this.expressionBuilder.column(this.geomName), |
|
194 |
this.expressionBuilder.constant(false), |
|
195 |
this.expressionBuilder.ST_Overlaps( |
|
196 |
this.expressionBuilder.column(this.geomName), |
|
197 |
this.expressionBuilder.geometry(polygon) |
|
198 |
) |
|
199 |
).toString() |
|
200 |
); |
|
201 |
if (theDataSet.findFirst(this.expression) != null) { |
|
186 | 202 |
report.addLine(this, |
187 |
this.getDataSet1(),
|
|
203 |
theDataSet,
|
|
188 | 204 |
null, |
189 | 205 |
polygon, |
190 | 206 |
feature1.getReference(), |
... | ... | |
193 | 209 |
"The polygon overlay with others." |
194 | 210 |
); |
195 | 211 |
} |
196 |
} finally { |
|
197 |
DisposeUtils.disposeQuietly(set); |
|
198 |
DisposeUtils.disposeQuietly(it); |
|
199 | 212 |
} |
200 |
} catch(Exception ex) { |
|
213 |
} catch (Exception ex) {
|
|
201 | 214 |
LOGGER.warn("Can't check feature.", ex); |
202 | 215 |
} finally { |
203 | 216 |
} |
Also available in: Unified diff