Revision 727 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

View differences:

PointMustBeProperlyInsidePolygonRule.java
82 82

  
83 83
    public PointMustBeProperlyInsidePolygonRule(
84 84
            TopologyPlan plan,
85
            TopologyRuleFactory factory
86
    ) {
87
        super(plan, factory);
88
        this.actions.add(new DeleteAction());
89
    }
90

  
91
    public PointMustBeProperlyInsidePolygonRule(
92
            TopologyPlan plan,
93 85
            TopologyRuleFactory factory,
94 86
            double tolerance,
95 87
            String dataSet1,
......
104 96
    protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature1) throws Exception {
105 97
        FeatureSet set = null;
106 98
        try {
107
            FeatureStore store2 = this.getDataSet2().getStore();
99
            FeatureStore store2 = this.getDataSet2().getFeatureStore();
108 100
            if (this.expression == null) {
109 101
                ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager();
110 102
                this.expression = manager.createExpression();
......
113 105
            }
114 106
            Geometry point = feature1.getDefaultGeometry();
115 107
            TopologyDataSet theDataSet = this.getDataSet2();
116
//            if (theDataSet.getSpatialIndex() != null) {
117
//                boolean ok = false;
118
//                for (FeatureReference featureReference : theDataSet.query(point)) {
119
//                    Feature feature2 = featureReference.getFeature();
120
//                    if( feature2.getDefaultGeometry().overlaps(point) ) {
121
//                        ok = true;
122
//                        break;
123
//                    }
124
//                }
125
//                if( !ok ) {
126
//                    report.addLine(this,
127
//                            this.getDataSet1(),
128
//                            this.getDataSet2(),
129
//                            point,
130
//                            feature1.getReference(),
131
//                            null,
132
//                            false,
133
//                            "The point are error where are not inside a polygon."
134
//                    );
135
//                }
136
//            } else {
108
            if (theDataSet.getSpatialIndex() != null) {
109
                boolean contained = false;
110
                for (FeatureReference featureReference : theDataSet.query(point)) {
111
                    Feature feature2 = featureReference.getFeature();
112
                    Geometry otherPolygon = feature2.getDefaultGeometry();
113
                    if( otherPolygon!=null && otherPolygon.contains(point) ) {
114
                        contained = true;
115
                        break;
116
                    }
117
                }
118
                if( !contained ) {
119
                    report.addLine(this,
120
                            this.getDataSet1(),
121
                            this.getDataSet2(),
122
                            point,
123
                            point,
124
                            feature1.getReference(),
125
                            null,
126
                            false,
127
                            "The point are error where are not inside a polygon."
128
                    );
129
                }
130
            } else {
137 131
                this.expression.setPhrase(
138 132
                        this.expressionBuilder.ifnull(
139 133
                                this.expressionBuilder.column(this.geomName),
140 134
                                this.expressionBuilder.constant(false),
141
                                this.expressionBuilder.ST_Overlaps(
135
                                this.expressionBuilder.ST_Contains(
142 136
                                        this.expressionBuilder.column(this.geomName),
143 137
                                        this.expressionBuilder.geometry(point)
144 138
                                )
......
149 143
                            this.getDataSet1(),
150 144
                            this.getDataSet2(),
151 145
                            point,
146
                            point,
152 147
                            feature1.getReference(),
153 148
                            null,
154 149
                            false,
155 150
                            "The point are error where are not inside a polygon."
156 151
                    );
157 152
                }
158
//            }
153
            }
159 154
        } catch (Exception ex) {
160 155
            LOGGER.warn("Can't check feature.", ex);
161 156
        } finally {

Also available in: Unified diff