Revision 4555
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyReport.java | ||
---|---|---|
30 | 30 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
31 | 31 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
32 | 32 |
import org.gvsig.expressionevaluator.MutableSymbolTable; |
33 |
import org.gvsig.fmap.dal.feature.Feature; |
|
33 | 34 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
34 | 35 |
import org.gvsig.fmap.geom.Geometry; |
35 | 36 |
import org.gvsig.tools.task.SimpleTaskStatus; |
... | ... | |
210 | 211 |
} |
211 | 212 |
return TOPOLOGY_PLAN_STATUS_PASSED; |
212 | 213 |
} |
214 |
|
|
215 |
@Override |
|
216 |
public TopologyReportLine addCodeException(TopologyRule rule, TopologyDataSet dataSet1, Feature feature1, Throwable exception) { |
|
217 |
FeatureReference ref = null; |
|
218 |
if(feature1 != null){ |
|
219 |
ref = feature1.getReference(); |
|
220 |
} |
|
221 |
String msg = null; |
|
222 |
if(exception != null){ |
|
223 |
msg = exception.getLocalizedMessage(); |
|
224 |
} |
|
225 |
return this.addLine(rule, dataSet1, null, null, null, ref, null, false, msg); |
|
226 |
} |
|
213 | 227 |
|
214 |
|
|
215 | 228 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PolygonContainsPolygonRule.java | ||
---|---|---|
130 | 130 |
} |
131 | 131 |
} catch (Exception ex) { |
132 | 132 |
LOGGER.warn("Can't check feature.", ex); |
133 |
addCodeException(report, feature1, ex); |
|
133 | 134 |
} finally { |
134 | 135 |
if (set != null) { |
135 | 136 |
set.dispose(); |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PolygonContainsPointRule.java | ||
---|---|---|
172 | 172 |
} |
173 | 173 |
} catch (Exception ex) { |
174 | 174 |
LOGGER.warn("Can't check feature.", ex); |
175 |
addCodeException(report, feature1, ex); |
|
175 | 176 |
} finally { |
176 | 177 |
if (set != null) { |
177 | 178 |
set.dispose(); |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PolygonContainsOnePointRule.java | ||
---|---|---|
177 | 177 |
} |
178 | 178 |
} catch (Exception ex) { |
179 | 179 |
LOGGER.warn("Can't check feature.", ex); |
180 |
addCodeException(report, feature1, ex); |
|
180 | 181 |
} finally { |
181 | 182 |
if (set != null) { |
182 | 183 |
set.dispose(); |
... | ... | |
246 | 247 |
} |
247 | 248 |
} catch (Exception ex) { |
248 | 249 |
LOGGER.warn("Can't check feature.", ex); |
250 |
addCodeException(report, feature2, ex); |
|
249 | 251 |
} finally { |
250 | 252 |
if (set != null) { |
251 | 253 |
set.dispose(); |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PointMustBeProperlyInsidePolygonRule.java | ||
---|---|---|
177 | 177 |
} |
178 | 178 |
} catch (Exception ex) { |
179 | 179 |
LOGGER.warn("Can't check feature.", ex); |
180 |
addCodeException(report, feature1, ex); |
|
180 | 181 |
} finally { |
181 | 182 |
if (set != null) { |
182 | 183 |
set.dispose(); |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/LineMustBeCoveredByBoundaryOfPolygonRule.java | ||
---|---|---|
216 | 216 |
int count = 0; |
217 | 217 |
|
218 | 218 |
if (theDataSet2.getSpatialIndex() != null) { |
219 |
boolean overlaps = false; |
|
220 | 219 |
Iterable<FeatureReference> feats = theDataSet2.query(line); |
221 | 220 |
for (FeatureReference featureReference : feats) { |
222 | 221 |
Feature feature2 = featureReference.getFeature(); |
... | ... | |
228 | 227 |
} |
229 | 228 |
|
230 | 229 |
if (boundary != null && boundary.intersects(line)) { |
231 |
overlaps = true; |
|
232 | 230 |
multipolygon.addPrimitives(otherPolygon); |
233 | 231 |
if(count > maxCrossingPolygons) { |
234 | 232 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
... | ... | |
251 | 249 |
} |
252 | 250 |
} |
253 | 251 |
} |
254 |
if (!overlaps) { |
|
255 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
256 |
report.addLine(this, |
|
257 |
this.getDataSet1(), |
|
258 |
this.getDataSet2(), |
|
259 |
line, |
|
260 |
line, |
|
261 |
feature1.getReference(), |
|
262 |
null, |
|
263 |
false, |
|
264 |
i18n.getTranslation("_Line_is_not_covered_by_boundary_of_any_polygon") |
|
265 |
); |
|
266 |
} |
|
267 | 252 |
} else { |
268 | 253 |
if (theTolerance == 0) { |
269 | 254 |
this.expression.setPhrase( |
... | ... | |
293 | 278 |
); |
294 | 279 |
} |
295 | 280 |
FeatureSet features = store2.getFeatureSet(this.expression); |
296 |
if (features.isEmpty()) { |
|
297 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
298 |
report.addLine(this, |
|
299 |
this.getDataSet1(), |
|
300 |
this.getDataSet2(), |
|
301 |
line, |
|
302 |
line, |
|
303 |
feature1.getReference(), |
|
304 |
null, |
|
305 |
false, |
|
306 |
i18n.getTranslation("_Line_is_not_covered_by_boundary_of_any_polygon") |
|
307 |
); |
|
308 |
} |
|
309 | 281 |
|
310 | 282 |
for (Feature feature2 : features) { |
311 | 283 |
if (feature2 != null) { |
... | ... | |
334 | 306 |
} |
335 | 307 |
} |
336 | 308 |
} |
309 |
|
|
310 |
if (multipolygon.isEmpty()) { |
|
311 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
312 |
report.addLine(this, |
|
313 |
this.getDataSet1(), |
|
314 |
this.getDataSet2(), |
|
315 |
line, |
|
316 |
line, |
|
317 |
feature1.getReference(), |
|
318 |
null, |
|
319 |
false, |
|
320 |
i18n.getTranslation("_Line_is_not_covered_by_boundary_of_any_polygon") |
|
321 |
); |
|
322 |
return; |
|
323 |
} |
|
337 | 324 |
|
325 |
|
|
338 | 326 |
Geometry boundary = multipolygon.boundary(); |
339 | 327 |
if (boundary != null) { |
340 | 328 |
if (theTolerance != 0) { |
... | ... | |
359 | 347 |
|
360 | 348 |
} catch (Exception ex) { |
361 | 349 |
LOGGER.warn("Can't check feature.", ex); |
350 |
addCodeException(report, feature1, ex); |
|
362 | 351 |
} finally { |
363 | 352 |
if (set != null) { |
364 | 353 |
set.dispose(); |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PolygonMustNotOverlapWithPolygonRule.java | ||
---|---|---|
239 | 239 |
} |
240 | 240 |
} catch (Exception ex) { |
241 | 241 |
LOGGER.warn("Can't check feature.", ex); |
242 |
addCodeException(report, feature1, ex); |
|
242 | 243 |
} finally { |
243 | 244 |
} |
244 | 245 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PolygonMustBeCoveredByPolygonRule.java | ||
---|---|---|
178 | 178 |
} |
179 | 179 |
} catch (Exception ex) { |
180 | 180 |
LOGGER.warn("Can't check feature.", ex); |
181 |
addCodeException(report, feature1, ex); |
|
181 | 182 |
} finally { |
182 | 183 |
if (set != null) { |
183 | 184 |
set.dispose(); |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PolygonMustNotOverlapPolygonRule.java | ||
---|---|---|
295 | 295 |
} |
296 | 296 |
} catch (Exception ex) { |
297 | 297 |
LOGGER.warn("Can't check feature.", ex); |
298 |
addCodeException(report, feature1, ex); |
|
298 | 299 |
} finally { |
299 | 300 |
} |
300 | 301 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/GeometryMustNotBeNullRule.java | ||
---|---|---|
69 | 69 |
} |
70 | 70 |
} catch(Exception ex) { |
71 | 71 |
LOGGER.warn("Can't check feature.", ex); |
72 |
addCodeException(report, feature1, ex); |
|
72 | 73 |
} finally { |
73 | 74 |
if( set!=null ) { |
74 | 75 |
set.dispose(); |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/AbstractTopologyRule.java | ||
---|---|---|
70 | 70 |
|
71 | 71 |
protected List<TopologyRuleAction> actions; |
72 | 72 |
private DynObject parameters; |
73 |
private int codeExceptionCount; |
|
73 | 74 |
|
74 | 75 |
protected AbstractTopologyRule( |
75 | 76 |
TopologyPlan plan, |
... | ... | |
184 | 185 |
@Override |
185 | 186 |
public void execute(final SimpleTaskStatus taskStatus, final TopologyReport report) { |
186 | 187 |
try { |
187 |
this.getDataSet1().accept(new Visitor() { |
|
188 |
@Override |
|
189 |
public void visit(final Object o1) throws VisitCanceledException, BaseException { |
|
190 |
if( taskStatus.isCancellationRequested() ) { |
|
191 |
throw new VisitCanceledException(); |
|
192 |
} |
|
193 |
taskStatus.incrementCurrentValue(); |
|
194 |
try { |
|
195 |
check(taskStatus, report, (Feature) o1); |
|
196 |
} catch (Exception ex) { |
|
197 |
throw new RuntimeException(ex); |
|
198 |
} |
|
188 |
this.codeExceptionCount = 0; |
|
189 |
this.getDataSet1().accept((final Object o1) -> { |
|
190 |
if( taskStatus.isCancellationRequested() ) { |
|
191 |
throw new VisitCanceledException(); |
|
199 | 192 |
} |
193 |
taskStatus.incrementCurrentValue(); |
|
194 |
try { |
|
195 |
check(taskStatus, report, (Feature) o1); |
|
196 |
} catch (Exception ex) { |
|
197 |
addCodeException(report, (Feature)o1, ex); |
|
198 |
} |
|
200 | 199 |
}); |
201 | 200 |
} catch(VisitCanceledException ex) { |
202 | 201 |
// return; |
... | ... | |
284 | 283 |
targetFeature.copyFrom(featureToCopyFrom); |
285 | 284 |
targetFeature.setDefaultGeometry(newGeom); |
286 | 285 |
dataSet.insert(targetFeature); |
287 |
} |
|
286 |
} |
|
287 |
|
|
288 |
protected void addCodeException(TopologyReport report, Feature feature1, Exception ex) { |
|
289 |
if(codeExceptionCount++ > 10){ |
|
290 |
return; |
|
291 |
} |
|
292 |
report.addCodeException(this, getDataSet1(), feature1, ex); |
|
293 |
} |
|
288 | 294 |
|
289 | 295 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyReport.java | ||
---|---|---|
24 | 24 |
package org.gvsig.topology.lib.api; |
25 | 25 |
|
26 | 26 |
import java.util.List; |
27 |
import org.gvsig.fmap.dal.feature.Feature; |
|
27 | 28 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
28 | 29 |
import org.gvsig.fmap.geom.Geometry; |
29 | 30 |
|
... | ... | |
74 | 75 |
public List<TopologyReportLine> getLines(String filter); |
75 | 76 |
|
76 | 77 |
public TopologyReportLineSet getLineSet(String filter); |
77 |
|
|
78 |
|
|
78 | 79 |
public int getStatus(); |
79 | 80 |
|
81 |
public TopologyReportLine addCodeException( |
|
82 |
TopologyRule rule, |
|
83 |
TopologyDataSet dataSet1, |
|
84 |
Feature feature1, |
|
85 |
Throwable exception |
|
86 |
); |
|
87 |
|
|
80 | 88 |
} |
Also available in: Unified diff