Revision 4475

View differences:

org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/LineMustBeCoveredByBoundaryOfPolygon.json
1 1
{
2 2
    "id": "LineMustBeCoveredByBoundaryOfPolygon",
3
    "name": "Must Be Covered By Boundary Of (EN CONSTRUCCION)",
3
    "name": "Must Be Covered By Boundary Of",
4 4
    "description": [ 
5 5
        "<img src=\"@@@_d/LineMustBeCoveredByBoundaryOfPolygon.png\">\n",
6 6
        "Requires that lines be covered by the boundaries of area features. This is useful for modeling lines, such as lot lines, that must coincide with the edge of polygon features, such as lots."
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/LineMustBeCoveredByBoundaryOfPolygon.json
1 1
{
2 2
    "id": "LineMustBeCoveredByBoundaryOfPolygon",
3
    "name": "Debe estar cubierto por el límite de (EN CONSTRUCCION)",
3
    "name": "Debe estar cubierto por el límite de",
4 4
    "description": [ 
5 5
        "<img src=\"@@@_d/LineMustBeCoveredByBoundaryOfPolygon.png\">\n",
6 6
        "Requiere que las líneas estén cubiertas por los límites de las entidades de área. Esto es útil para modelar líneas, tales como líneas de lote, que deben coincidir con el eje de las entidades poligonales, tales como lotes."
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyPlan.java
66 66
    private TopologyServices services;
67 67
    private double tolerance;
68 68
    private SimpleTaskStatus taskStatus;
69
    private boolean useUI;
69 70
    
70 71
    public DefaultTopologyPlan(TopologyManager manager, TopologyServices services) {
71 72
        this.manager = manager;
......
75 76
        this.report = null;
76 77
        this.name = "TopologyPlan-" + String.format("%08X", new Date().getTime());
77 78
        this.tolerance = 0;
79
        this.useUI = true;
78 80
    }
79 81

  
80 82
    @Override
......
340 342
        this.rules.remove(rule);
341 343
    }
342 344

  
345
    @Override
346
    public boolean canUseUI() {
347
        return this.useUI;
348
    }
349

  
350
    @Override
351
    public void setUseUI(boolean useUI) {
352
        this.useUI = useUI;
353
    }
343 354
    
355
    
356

  
357
    
344 358
}
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
68 68
        }
69 69

  
70 70
        @Override
71
        public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
71
        public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
72 72
            try {
73 73
                TopologyDataSet dataSet = rule.getDataSet1();
74 74

  
75 75
                dataSet.delete(line.getFeature1());
76

  
76
                return EXECUTE_OK;
77 77
            } catch (Exception ex) {
78 78
                throw new ExecuteTopologyRuleActionException(ex);
79 79
            }
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
23 23
 */
24 24
package org.gvsig.topology.rule;
25 25

  
26
import javax.swing.JOptionPane;
27
import org.apache.commons.lang3.StringUtils;
26 28
import org.gvsig.expressionevaluator.Expression;
27 29
import org.gvsig.expressionevaluator.ExpressionUtils;
28 30
import org.gvsig.expressionevaluator.GeometryExpressionBuilder;
......
33 35
import org.gvsig.fmap.dal.feature.FeatureSet;
34 36
import org.gvsig.fmap.dal.feature.FeatureStore;
35 37
import org.gvsig.fmap.geom.Geometry;
36
import org.gvsig.fmap.geom.primitive.Point;
38
import org.gvsig.fmap.geom.GeometryLocator;
39
import org.gvsig.fmap.geom.GeometryUtils;
40
import org.gvsig.fmap.geom.aggregate.MultiPolygon;
41
import org.gvsig.fmap.geom.complex.Complex;
42
import org.gvsig.tools.ToolsLocator;
37 43
import org.gvsig.tools.dynobject.DynObject;
44
import org.gvsig.tools.i18n.I18nManager;
45
import org.gvsig.tools.swing.api.ToolsSwingLocator;
46
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
38 47
import org.gvsig.tools.task.SimpleTaskStatus;
39
import org.gvsig.topology.lib.spi.AbstractTopologyRule;
40
import org.gvsig.topology.lib.spi.AbstractTopologyRuleAction;
41 48
import org.gvsig.topology.lib.api.ExecuteTopologyRuleActionException;
42 49
import org.gvsig.topology.lib.api.TopologyDataSet;
43 50
import org.gvsig.topology.lib.api.TopologyPlan;
......
45 52
import org.gvsig.topology.lib.api.TopologyReportLine;
46 53
import org.gvsig.topology.lib.api.TopologyRule;
47 54
import org.gvsig.topology.lib.api.TopologyRuleFactory;
55
import org.gvsig.topology.lib.spi.AbstractTopologyRule;
56
import org.gvsig.topology.lib.spi.AbstractTopologyRuleAction;
48 57

  
49 58
/**
50 59
 *
......
52 61
 */
53 62
@SuppressWarnings("UseSpecificCatch")
54 63
public class LineMustBeCoveredByBoundaryOfPolygonRule extends AbstractTopologyRule {
64
    
65
    private static final String MANY_CROSSING_POLYGONS="Many crossing polygons";
55 66

  
67
    private class SubtractAction extends AbstractTopologyRuleAction {
68

  
69
        public SubtractAction() {
70
            super(
71
                    LineMustBeCoveredByBoundaryOfPolygonRuleFactory.NAME,
72
                    "Subtract",
73
                    "Subtract",
74
                    "The Subtract fix removes line segments that are not coincident with the boundary of polygon features. If the line feature does not share any segments in common with the boundary of a polygon feature, the feature will be deleted. This fix can be applied to one or more Must Be Covered By Boundary Of errors."
75
            );
76
        }
77

  
78
        @Override
79
        public int execute(TopologyRule rule, TopologyReportLine reportLine, DynObject parameters) {
80
            try {
81
                
82
                if(StringUtils.endsWithIgnoreCase(reportLine.getData(), MANY_CROSSING_POLYGONS)){
83
                    if(rule.getPlan().canUseUI()) {
84
                        ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
85
                        I18nManager i18n = ToolsLocator.getI18nManager();
86
                        dialogs.messageDialog(
87
                                i18n.getTranslation("The_solution_cannot_be_automated_because_the_line_crosses_too_many_polygons"), 
88
                                i18n.getTranslation("Subtract"), 
89
                                JOptionPane.INFORMATION_MESSAGE
90
                        );
91
                    }
92
                    return EXECUTE_FAIL;
93
                }
94
                
95
                Geometry errorGeom = reportLine.getError();
96
                TopologyDataSet dataSet = rule.getDataSet1();
97

  
98
                FeatureReference featRef1 = reportLine.getFeature1();
99

  
100
                Feature feat1 = featRef1.getFeature();
101
                Geometry line = feat1.getDefaultGeometry();
102
                
103
                if (line == errorGeom) {
104
                    dataSet.delete(featRef1);
105
                    return EXECUTE_OK;
106
                }
107

  
108
                TopologyDataSet theDataSet2 = rule.getDataSet2();
109

  
110
                FeatureStore store2 = theDataSet2.getFeatureStore();
111
                int subtype = store2.getDefaultFeatureType().getDefaultGeometryAttribute().getGeomType().getSubType();
112
                MultiPolygon multipolygon = GeometryLocator.getGeometryManager().createMultiPolygon(subtype);
113

  
114
                if (theDataSet2.getSpatialIndex() != null) {
115
                    Iterable<FeatureReference> feats = theDataSet2.query(line);
116
                    for (FeatureReference featureReference : feats) {
117
                        Feature feature2 = featureReference.getFeature();
118
                        Geometry otherPolygon = feature2.getDefaultGeometry();
119
                        if (otherPolygon != null) {
120
                            Geometry boundary = otherPolygon.boundary();
121
                            if (boundary != null && boundary.intersects(line)) {
122
                                multipolygon.addPrimitives(otherPolygon);
123
                            }
124
                        }
125
                    }
126
                } else {
127
                    Expression theExpression = ExpressionUtils.createExpression();
128
                    GeometryExpressionBuilder theExpressionBuilder = GeometryExpressionUtils.createExpressionBuilder();
129
                    String theGeomName = store2.getDefaultFeatureType().getDefaultGeometryAttributeName();
130

  
131
                    theExpression.setPhrase(
132
                            theExpressionBuilder.ifnull(
133
                                    theExpressionBuilder.column(theGeomName),
134
                                    theExpressionBuilder.constant(false),
135
                                    theExpressionBuilder.ST_Intersects(
136
                                            theExpressionBuilder.function("ST_Boundary", theExpressionBuilder.column(theGeomName)),
137
                                            theExpressionBuilder.geometry(line)
138
                                    )
139
                            ).toString()
140
                    );
141
                    FeatureSet features = store2.getFeatureSet(theExpression);
142
                    for (Feature feature2 : features) {
143
                        if (feature2 != null) {
144
                            Geometry otherPolygon = feature2.getDefaultGeometry();
145
                            if (otherPolygon != null) {
146
                                multipolygon.addPrimitives(otherPolygon);
147
                            }
148
                        }
149
                    }
150
                }
151

  
152
                if (multipolygon.getPrimitivesNumber() == 0) {
153
                    dataSet.delete(featRef1);
154
                    return EXECUTE_OK;
155
                }
156

  
157
                Geometry boundary = multipolygon.boundary();
158
                if (boundary != null) {
159
                    Geometry intersection = line.intersection(boundary);
160
                    if (intersection != null) {
161
                        EditableFeature editFeat = feat1.getEditable();
162
                        if(intersection instanceof Complex){
163
                            intersection = ((Complex) intersection).createAggregate(
164
                                    Geometry.TYPES.MULTILINE,
165
                                    (Geometry g) -> GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, g.getGeometryType().getType()) || GeometryUtils.isSubtype(Geometry.TYPES.CURVE, g.getGeometryType().getType())
166
                            );
167
                        }
168
                        if(GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, intersection.getGeometryType().getType()) || GeometryUtils.isSubtype(Geometry.TYPES.CURVE, intersection.getGeometryType().getType())){
169
                            editFeat.setDefaultGeometry(intersection);
170
                            dataSet.update(editFeat);
171
                        } else {
172
                            dataSet.delete(featRef1);
173
                            return EXECUTE_OK;
174
                        }
175
                    }
176
                }
177
            } catch (Exception ex) {
178
                throw new ExecuteTopologyRuleActionException(ex);
179
            }
180
            return EXECUTE_OK;
181
        }
182

  
183
    }
184

  
56 185
    private String geomName;
57 186
    private Expression expression = null;
58 187
    private GeometryExpressionBuilder expressionBuilder = null;
......
65 194
            String dataSet2
66 195
    ) {
67 196
        super(plan, factory, tolerance, dataSet1, dataSet2);
68

  
197
        addAction(new SubtractAction());
69 198
    }
70 199

  
71 200
    @Override
72 201
    protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature1) throws Exception {
73
        //FIXME:
74
        
75 202
        FeatureSet set = null;
76 203
        try {
204
            int maxCrossingPolygons = 100;
77 205
            FeatureStore store2 = this.getDataSet2().getFeatureStore();
78 206
            if (this.expression == null) {
79 207
                this.expression = ExpressionUtils.createExpression();
80 208
                this.expressionBuilder = GeometryExpressionUtils.createExpressionBuilder();
81 209
                this.geomName = store2.getDefaultFeatureType().getDefaultGeometryAttributeName();
82 210
            }
83
            Geometry polygon = feature1.getDefaultGeometry();
84
            TopologyDataSet theDataSet = this.getDataSet2();
85
            if (theDataSet.getSpatialIndex() != null) {
86
                boolean contains = false;
87
                for (FeatureReference featureReference : theDataSet.query(polygon)) {
211
            Geometry line = feature1.getDefaultGeometry();
212
            TopologyDataSet theDataSet2 = this.getDataSet2();
213
            double theTolerance = getTolerance();
214
            int subtype = store2.getDefaultFeatureType().getDefaultGeometryAttribute().getGeomType().getSubType();
215
            MultiPolygon multipolygon = GeometryLocator.getGeometryManager().createMultiPolygon(subtype);
216
            int count = 0;
217

  
218
            if (theDataSet2.getSpatialIndex() != null) {
219
                boolean overlaps = false;
220
                Iterable<FeatureReference> feats = theDataSet2.query(line);
221
                for (FeatureReference featureReference : feats) {
88 222
                    Feature feature2 = featureReference.getFeature();
89
                    Geometry otherGeometry = feature2.getDefaultGeometry();
90
                    if( otherGeometry!=null && polygon.contains(otherGeometry) ) {
91
                        contains = true;
92
                        break;
223
                    Geometry otherPolygon = feature2.getDefaultGeometry();
224
                    if (otherPolygon != null) {
225
                        Geometry boundary = otherPolygon.boundary();
226
                        if (boundary != null && theTolerance != 0) {
227
                            boundary = boundary.buffer(theTolerance);
228
                        }
229

  
230
                        if (boundary != null && boundary.intersects(line)) {
231
                            overlaps = true;
232
                            multipolygon.addPrimitives(otherPolygon);
233
                            if(count > maxCrossingPolygons) {
234
                                I18nManager i18n = ToolsLocator.getI18nManager();
235
                                report.addLine(this,
236
                                        this.getDataSet1(),
237
                                        this.getDataSet2(),
238
                                        line,
239
                                        line,
240
                                        feature1.getReference(),
241
                                        null,
242
                                        -1,
243
                                        -1,
244
                                        false,
245
                                        i18n.getTranslation("_Line_crosses_too_many_polygons"),
246
                                        MANY_CROSSING_POLYGONS
247
                                );
248
                                return;
249
                            }
250
                            count++;
251
                        }
93 252
                    }
94 253
                }
95
                if( !contains ) {
254
                if (!overlaps) {
255
                    I18nManager i18n = ToolsLocator.getI18nManager();
96 256
                    report.addLine(this,
97 257
                            this.getDataSet1(),
98 258
                            this.getDataSet2(),
99
                            polygon,
100
                            polygon,
259
                            line,
260
                            line,
101 261
                            feature1.getReference(),
102 262
                            null,
103 263
                            false,
104
                            "The polygon is an error because it does not contain a point."
264
                            i18n.getTranslation("_Line_is_not_covered_by_boundary_of_any_polygon")
105 265
                    );
106 266
                }
107 267
            } else {
108
                this.expression.setPhrase(
109
                        this.expressionBuilder.ifnull(
110
                                this.expressionBuilder.column(this.geomName),
111
                                this.expressionBuilder.constant(false),
112
                                this.expressionBuilder.ST_Contains(
113
                                        this.expressionBuilder.geometry(polygon),
114
                                        this.expressionBuilder.column(this.geomName)
115
                                )
116
                        ).toString()
117
                );
118
                if (theDataSet.findFirst(this.expression) == null) {
268
                if (theTolerance == 0) {
269
                    this.expression.setPhrase(
270
                            this.expressionBuilder.ifnull(
271
                                    this.expressionBuilder.column(this.geomName),
272
                                    this.expressionBuilder.constant(false),
273
                                    this.expressionBuilder.ST_Intersects(
274
                                            this.expressionBuilder.function("ST_Boundary", this.expressionBuilder.column(this.geomName)),
275
                                            this.expressionBuilder.geometry(line)
276
                                    )
277
                            ).toString()
278
                    );
279

  
280
                } else {
281
                    this.expression.setPhrase(
282
                            this.expressionBuilder.ifnull(
283
                                    this.expressionBuilder.column(this.geomName),
284
                                    this.expressionBuilder.constant(false),
285
                                    this.expressionBuilder.ST_Intersects(
286
                                            this.expressionBuilder.ST_Buffer(
287
                                                    this.expressionBuilder.function("ST_Boundary", this.expressionBuilder.column(this.geomName)),
288
                                                    this.expressionBuilder.constant(theTolerance)
289
                                            ),
290
                                            this.expressionBuilder.geometry(line)
291
                                    )
292
                            ).toString()
293
                    );
294
                }
295
                FeatureSet features = store2.getFeatureSet(this.expression);
296
                if (features.isEmpty()) {
297
                    I18nManager i18n = ToolsLocator.getI18nManager();
119 298
                    report.addLine(this,
120 299
                            this.getDataSet1(),
121 300
                            this.getDataSet2(),
122
                            polygon,
123
                            polygon,
301
                            line,
302
                            line,
124 303
                            feature1.getReference(),
125 304
                            null,
126 305
                            false,
127
                            "The polygon is an error because it does not contain a point."
306
                            i18n.getTranslation("_Line_is_not_covered_by_boundary_of_any_polygon")
128 307
                    );
129 308
                }
309

  
310
                for (Feature feature2 : features) {
311
                    if (feature2 != null) {
312
                        Geometry otherPolygon = feature2.getDefaultGeometry();
313
                        if (otherPolygon != null) {
314
                            multipolygon.addPrimitives(otherPolygon);
315
                            if(count > maxCrossingPolygons) {
316
                                I18nManager i18n = ToolsLocator.getI18nManager();
317
                                report.addLine(this,
318
                                        this.getDataSet1(),
319
                                        this.getDataSet2(),
320
                                        line,
321
                                        line,
322
                                        feature1.getReference(),
323
                                        null,
324
                                        -1,
325
                                        -1,
326
                                        false,
327
                                        i18n.getTranslation("_Line_crosses_too_many_polygons"),
328
                                        MANY_CROSSING_POLYGONS
329
                                );
330
                                return;
331
                            }
332
                            count++;
333
                        }
334
                    }
335
                }
130 336
            }
337

  
338
            Geometry boundary = multipolygon.boundary();
339
            if (boundary != null) {
340
                if (theTolerance != 0) {
341
                    boundary = boundary.buffer(theTolerance);
342
                }
343

  
344
                Geometry difference = line.difference(boundary);
345
                if (difference != null) {
346
                    I18nManager i18n = ToolsLocator.getI18nManager();
347
                    report.addLine(this,
348
                            this.getDataSet1(),
349
                            this.getDataSet2(),
350
                            line,
351
                            difference,
352
                            feature1.getReference(),
353
                            null,
354
                            false,
355
                            i18n.getTranslation("_Line_is_not_covered_by_boundary_of_the_polygon")
356
                    );
357
                }
358
            }
359

  
131 360
        } catch (Exception ex) {
132 361
            LOGGER.warn("Can't check feature.", ex);
133 362
        } finally {
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/LineMustBeLargerThanToleranceRule.java
58 58
        }
59 59
        
60 60
        @Override
61
        public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
61
        public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
62 62
            try {
63 63
                TopologyDataSet dataset = line.getDataSet1();
64 64
                dataset.delete(line.getFeature1());
65
                return EXECUTE_OK;
65 66
            } catch (Exception ex) {
66 67
                throw new ExecuteTopologyRuleActionException(ex);
67 68
            }
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
67 67
        }
68 68

  
69 69
        @Override
70
        public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
70
        public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
71 71
            try {
72 72
                Geometry polygon = line.getGeometry();
73 73
                Point point = polygon.centroid();
......
79 79
                EditableFeature feature = dataSet.createNewFeature();
80 80
                feature.setDefaultGeometry(point);
81 81
                dataSet.insert(feature);
82
                return EXECUTE_OK;
82 83

  
83 84
            } catch (Exception ex) {
84 85
                throw new ExecuteTopologyRuleActionException(ex);
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
66 66
        }
67 67

  
68 68
        @Override
69
        public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
69
        public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
70 70
            try {
71 71
                Geometry polygon = line.getGeometry();
72 72
                TopologyDataSet dataSet = rule.getDataSet2();
......
74 74
                EditableFeature feature = dataSet.createNewFeature();
75 75
                feature.setDefaultGeometry(polygon);
76 76
                dataSet.insert(feature);
77

  
77
                return EXECUTE_OK;
78 78
            } catch (Exception ex) {
79 79
                throw new ExecuteTopologyRuleActionException(ex);
80 80
            }
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
73 73
        }
74 74

  
75 75
        @Override
76
        public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
76
        public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
77 77
            try {
78 78
                Geometry errorGeom = line.getError();
79 79
                TopologyDataSet dataSet = rule.getDataSet1();
......
91 91
                substract(featRef1, geom2, rule.getDataSet1());
92 92
                substract(featRef2, geom1, rule.getDataSet1());
93 93

  
94
                return EXECUTE_OK;
94 95
            } catch (Exception ex) {
95 96
                throw new ExecuteTopologyRuleActionException(ex);
96 97
            }
......
114 115
        }
115 116

  
116 117
        @Override
117
        public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
118
        public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
118 119
            try {
119 120
                Geometry errorGeom = line.getError();
120 121
                TopologyDataSet dataSet = rule.getDataSet1();
......
130 131
                
131 132
                substract(featRef1, geom2, rule.getDataSet1());
132 133
                substract(featRef2, geom1, rule.getDataSet1());
134
                return EXECUTE_OK;
133 135
                
134 136
            } catch (Exception ex) {
135 137
                throw new ExecuteTopologyRuleActionException(ex);
......
155 157
        }
156 158

  
157 159
        @Override
158
        public void execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
160
        public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) {
159 161
            try {
160 162
                Geometry errorGeom = line.getError();
161 163
                TopologyDataSet dataSet = rule.getDataSet1();
......
167 169
                FeatureReference featRef2 = line.getFeature2();
168 170
                
169 171
                substract(featRef2, geom1, rule.getDataSet1());
172
                return EXECUTE_OK;
170 173

  
171 174
            } catch (Exception ex) {
172 175
                throw new ExecuteTopologyRuleActionException(ex);
......
266 269
        }
267 270
    }
268 271
    
269
    private void substract(FeatureReference featRef, Geometry geomToSubstract, TopologyDataSet dataSet) throws DataException, GeometryOperationException, GeometryOperationNotSupportedException {
270
        Feature feat = featRef.getFeature();
271
        EditableFeature editFeat = feat.getEditable();
272
        Geometry geom = editFeat.getDefaultGeometry();
273
        Geometry diff = geom.difference(geomToSubstract);
274
        editFeat.setDefaultGeometry(diff);
275
        dataSet.update(editFeat);
276
    }
277

  
278
    private void createNewFeature(FeatureReference featRef, TopologyDataSet dataSet, Geometry errorGeom) throws DataException {
279
        Feature featureToCopyFrom = featRef.getFeature();
280
        EditableFeature targetFeature = dataSet.createNewFeature();
281
        targetFeature.copyFrom(featureToCopyFrom);
282
        targetFeature.setDefaultGeometry(errorGeom);
283
        dataSet.insert(targetFeature);
284
     }
285

  
286 272
}
287 273

  
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/LineMustBeCoveredByBoundaryOfPolygonRuleFactory.java
43 43
    public LineMustBeCoveredByBoundaryOfPolygonRuleFactory() {
44 44
        super(
45 45
                NAME, 
46
                "Must Be Covered By Boundary Of (EN CONSTRUCCION)", 
46
                "Must Be Covered By Boundary Of", 
47 47
                "Requires that lines be covered by the boundaries of area features. This is useful for modeling lines, such as lot lines, that must coincide with the edge of polygon features, such as lots.", 
48 48
                new ListBuilder<Integer>()
49
                        .add(Geometry.TYPES.SURFACE)
50
                        .add(Geometry.TYPES.MULTISURFACE)
49
                        .add(Geometry.TYPES.CURVE)
50
                        .add(Geometry.TYPES.MULTICURVE)
51 51
                        .asList(),
52 52
                new ListBuilder<Integer>()
53 53
                        .add(Geometry.TYPES.SURFACE)
......
58 58
    
59 59
    @Override
60 60
    public TopologyRule createRule(TopologyPlan plan, String dataSet1, String dataSet2, double tolerance) {
61
        TopologyRule rule = new PolygonMustBeCoveredByPolygonRule(plan, this, tolerance, dataSet1, dataSet2);
61
        TopologyRule rule = new LineMustBeCoveredByBoundaryOfPolygonRule(plan, this, tolerance, dataSet1, dataSet2);
62 62
        return rule;
63 63
    }    
64 64

  
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyRuleAction.java
31 31
 */
32 32
public interface TopologyRuleAction {
33 33
    
34
    public static final int EXECUTE_OK = 0;
35
    public static final int EXECUTE_FAIL = 1;
36
    
34 37
    public String getId();
35 38
    
36 39
    public String getName();
......
43 46
    
44 47
    public DynObject createParameters();
45 48
    
46
    public void execute(
49
    public int execute(
47 50
            TopologyRule rule,
48 51
            TopologyReportLine line, 
49 52
            DynObject parameters
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyRule.java
39 39
    
40 40
    public String getId();
41 41
    
42
    public TopologyPlan getPlan();
43

  
42 44
    public TopologyRuleFactory getFactory();
43 45
    
44 46
    public TopologyDataSet getDataSet1();
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyPlan.java
78 78
    public boolean hasRules();
79 79
    
80 80
    public TopologyReport getReport();
81
    
82
    public boolean canUseUI();
83
    
84
    public void  setUseUI(boolean useUI);
81 85

  
82 86
}
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
26 26
import java.util.ArrayList;
27 27
import java.util.Collections;
28 28
import java.util.List;
29
import java.util.function.Predicate;
29 30
import org.apache.commons.lang3.StringUtils;
31
import org.gvsig.fmap.dal.exception.DataException;
32
import org.gvsig.fmap.dal.feature.EditableFeature;
30 33
import org.gvsig.fmap.dal.feature.Feature;
34
import org.gvsig.fmap.dal.feature.FeatureReference;
35
import org.gvsig.fmap.geom.Geometry;
36
import org.gvsig.fmap.geom.complex.Complex;
37
import org.gvsig.fmap.geom.exception.CreateGeometryException;
38
import org.gvsig.fmap.geom.operation.GeometryOperationException;
39
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
31 40
import org.gvsig.tools.dynobject.DynClass;
32 41
import org.gvsig.tools.dynobject.DynField;
33 42
import org.gvsig.tools.dynobject.DynObject;
......
86 95
        this(plan, factory, tolerance, dataSet1, null);
87 96
    }
88 97

  
89
    protected TopologyPlan getPlan() {
98
    @Override
99
    public TopologyPlan getPlan() {
90 100
        return this.plan;
91 101
    }
92 102

  
......
259 269
        return this.parameters;
260 270
    }
261 271

  
272
    protected void substract(FeatureReference featRef, Geometry geomToSubstract, TopologyDataSet dataSet) throws DataException, GeometryOperationException, GeometryOperationNotSupportedException {
273
        Feature feat = featRef.getFeature();
274
        EditableFeature editFeat = feat.getEditable();
275
        Geometry geom = editFeat.getDefaultGeometry();
276
        Geometry diff = geom.difference(geomToSubstract);
277
        editFeat.setDefaultGeometry(diff);
278
        dataSet.update(editFeat);
279
    }
280

  
281
    protected void createNewFeature(FeatureReference featRef, TopologyDataSet dataSet, Geometry newGeom) throws DataException {
282
        Feature featureToCopyFrom = featRef.getFeature();
283
        EditableFeature targetFeature = dataSet.createNewFeature();
284
        targetFeature.copyFrom(featureToCopyFrom);
285
        targetFeature.setDefaultGeometry(newGeom);
286
        dataSet.insert(targetFeature);
287
     }
288

  
262 289
}
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/resources-plugin/i18n/text.properties
45 45
_Point_is_not_contained_in_a_polygon=El punto no est\u00e1 contenido en un pol\u00edgono
46 46
_The_polygon_does_not_contain_any_points=El  pol\u00edgono  no  contiene ning\u00fan punto
47 47
_The_length_of_the_line_is_less_than_the_specified_tolerance=La longitud de la l\u00ednea es menore que la tolerancia dada
48
_Polygon_is_not_covered_by_any_other_polygon=El pol\u00edgono no est\u00e1 cubierto por ning\u00fan otro pol\u00edgono
48
_Polygon_is_not_covered_by_any_other_polygon=El pol\u00edgono no est\u00e1 cubierto por ning\u00fan otro pol\u00edgono
49
_Line_is_not_covered_by_boundary_of_any_polygon=La l\u00ednea no est\u00e1 cubierta por el l\u00edmite de ning\u00fan pol\u00edgono
50
_Line_is_not_covered_by_boundary_of_the_polygon=La l\u00ednea no est\u00e1 cubierta por el l\u00edmite del pol\u00edgono
51
_Line_crosses_too_many_polygons=La l\u00ednea cruza por demasiados pol\u00edgonos
52
The_solution_cannot_be_automated_because_the_line_crosses_too_many_polygons=No se puede automatizar la soluci\u00f3n porque la l\u00ednea cruza por demasiados pol\u00edgonos
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.app/org.gvsig.topology.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
44 44
_Point_is_not_contained_in_a_polygon=Point is not contained in a polygon
45 45
_The_polygon_does_not_contain_any_points=The polygon does not contain any points
46 46
_The_length_of_the_line_is_less_than_the_specified_tolerance=The length of the line is less than the specified tolerance
47
_Polygon_is_not_covered_by_any_other_polygon=The polygon is not covered by any other polygon
47
_Polygon_is_not_covered_by_any_other_polygon=The polygon is not covered by any other polygon
48
_Line_is_not_covered_by_boundary_of_any_polygon=Line is not covered by boundary of any polygon
49
_Line_is_not_covered_by_boundary_of_the_polygon=Line is not covered by boundary of thes polygon
50
_Line_crosses_too_many_polygons=Line crosses too many polygons
51
The_solution_cannot_be_automated_because_the_line_crosses_too_many_polygons=The solution cannot be automated because the line crosses too many polygons 

Also available in: Unified diff