Revision 4482
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/PolygonMustNotOverlapWithPolygon.json | ||
---|---|---|
1 |
{ |
|
2 |
"id": "PolygonMustNotOverlapWithPolygon", |
|
3 |
"name": "Must Not Overlap With", |
|
4 |
"description": [ |
|
5 |
"<img src=\"@@@_d/PolygonMustNotOverlapWithPolygon.png\">\n", |
|
6 |
"Requires that the interior of polygons in one feature class (or subtype) must not overlap with the interior of polygons in another feature class (or subtype). Polygons of the two feature classes can share edges or vertices or be completely disjointed. This rule is used when an area cannot belong to two separate feature classes. It is useful for combining two mutually exclusive systems of area classification, such as zoning and water body type, where areas defined within the zoning class cannot also be defined in the water body class and vice versa." |
|
7 |
], |
|
8 |
"actions" : { |
|
9 |
"Subtract": { |
|
10 |
"name" : "Subtract", |
|
11 |
"description": [ |
|
12 |
"The Subtract fix removes the overlapping portion of each feature that is causing the error and leaves a gap or void in its place. This fix can be applied to one or more selected Must Not Overlap With errors." |
|
13 |
] |
|
14 |
}, |
|
15 |
"Merge": { |
|
16 |
"name" : "Merge", |
|
17 |
"description": [ |
|
18 |
"The Merge fix adds the portion of overlap from one feature and subtracts it from the others that are violating the rule. You need to pick the feature that receives the portion of overlap using the Merge dialog box. This fix can be applied to one Must Not Overlap With error only." |
|
19 |
] |
|
20 |
} |
|
21 |
} |
|
22 |
} |
|
23 |
|
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/PolygonMustNotOverlapWithPolygon.json | ||
---|---|---|
1 |
{ |
|
2 |
"id": "PolygonMustNotOverlapWithPolygon", |
|
3 |
"name": "No debe superponerse con", |
|
4 |
"description": [ |
|
5 |
"<img src=\"@@@_d/PolygonMustNotOverlapWithPolygon.png\">\n", |
|
6 |
"Requiere que el interior de los pol?gonos en una clase (o subtipo) de entidad no se deba superponer con el interior de los pol?gonos en otra clase (o subtipo) de entidad. Los pol?gonos de las dos clases de entidad pueden compartir ejes o v?rtices o estar completamente inconexos. Esta regla se utiliza cuando un ?rea no puede pertenecer a dos clases de entidad separadas. Resulta ?til para combinar dos sistemas mutuamente exclusivos de clasificaci?n de ?rea, tales como zonificaci?n y tipos de masa de agua, en las que las ?reas definidas en la clase de zonificaci?n tampoco se pueden definir en la clase de masa de agua y viceversa." |
|
7 |
], |
|
8 |
"actions" : { |
|
9 |
"Subtract": { |
|
10 |
"name" : "Subtract", |
|
11 |
"description": [ |
|
12 |
"La soluci?n Sustraer quita la parte de superposici?n de cada entidad que causa el error y deja un espacio o vac?o en su lugar. Esta soluci?n se puede aplicar a uno o m?s errores seleccionados del tipo No debe superponerse con." |
|
13 |
] |
|
14 |
}, |
|
15 |
"Merge": { |
|
16 |
"name" : "Merge", |
|
17 |
"description": [ |
|
18 |
"La soluci?n Fusionar agrega la parte de superposici?n de una entidad y la sustrae del resto que infringen la regla. Es necesario elegir la entidad que recibe la parte de superposici?n utilizando el cuadro de di?logo Fusionar. Esta soluci?n se puede aplicar ?nicamente a un error de tipo No debe superponerse con." |
|
19 |
] |
|
20 |
} |
|
21 |
} |
|
22 |
} |
|
23 |
|
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/TopologyImplLibrary.java | ||
---|---|---|
40 | 40 |
import org.gvsig.topology.rule.PolygonContainsOnePointRuleFactory; |
41 | 41 |
import org.gvsig.topology.rule.PolygonContainsPolygonRuleFactory; |
42 | 42 |
import org.gvsig.topology.rule.PolygonMustBeCoveredByPolygonRuleFactory; |
43 |
import org.gvsig.topology.rule.PolygonMustNotOverlapWithPolygonRuleFactory; |
|
43 | 44 |
|
44 | 45 |
/** |
45 | 46 |
* |
... | ... | |
72 | 73 |
PolygonMustNotOverlapPolygonRuleFactory.selfRegister(); |
73 | 74 |
PolygonContainsPolygonRuleFactory.selfRegister(); |
74 | 75 |
PolygonContainsOnePointRuleFactory.selfRegister(); |
76 |
PolygonMustNotOverlapWithPolygonRuleFactory.selfRegister(); |
|
75 | 77 |
} |
76 | 78 |
|
77 | 79 |
} |
org.gvsig.topology/trunk/org.gvsig.topology/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/rule/PolygonMustNotOverlapWithPolygonRuleFactory.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.rule; |
|
25 |
|
|
26 |
import org.gvsig.fmap.geom.Geometry; |
|
27 |
import org.gvsig.tools.util.ListBuilder; |
|
28 |
import org.gvsig.topology.lib.api.TopologyLocator; |
|
29 |
import org.gvsig.topology.lib.api.TopologyManager; |
|
30 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
31 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
32 |
import org.gvsig.topology.lib.spi.AbstractTopologyRuleFactory; |
|
33 |
|
|
34 |
/** |
|
35 |
* |
|
36 |
* @author jjdelcerro |
|
37 |
*/ |
|
38 |
@SuppressWarnings("UseSpecificCatch") |
|
39 |
public class PolygonMustNotOverlapWithPolygonRuleFactory extends AbstractTopologyRuleFactory { |
|
40 |
|
|
41 |
public static final String NAME = "PolygonMustNotOverlapWithPolygon"; |
|
42 |
|
|
43 |
public PolygonMustNotOverlapWithPolygonRuleFactory() { |
|
44 |
super( |
|
45 |
NAME, |
|
46 |
"Must Not Overlap With", |
|
47 |
"Requires that the interior of polygons in one feature class (or subtype) must not overlap with the interior of polygons in another feature class (or subtype). Polygons of the two feature classes can share edges or vertices or be completely disjointed. This rule is used when an area cannot belong to two separate feature classes. It is useful for combining two mutually exclusive systems of area classification, such as zoning and water body type, where areas defined within the zoning class cannot also be defined in the water body class and vice versa.", |
|
48 |
new ListBuilder<Integer>() |
|
49 |
.add(Geometry.TYPES.SURFACE) |
|
50 |
.add(Geometry.TYPES.MULTISURFACE) |
|
51 |
.asList(), |
|
52 |
new ListBuilder<Integer>() |
|
53 |
.add(Geometry.TYPES.SURFACE) |
|
54 |
.add(Geometry.TYPES.MULTISURFACE) |
|
55 |
.asList() |
|
56 |
|
|
57 |
|
|
58 |
); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public TopologyRule createRule(TopologyPlan plan, String dataSet1, String dataSet2, double tolerance) { |
|
63 |
TopologyRule rule = new PolygonMustNotOverlapWithPolygonRule(plan, this, tolerance, dataSet1, dataSet2); |
|
64 |
return rule; |
|
65 |
} |
|
66 |
|
|
67 |
public static void selfRegister() { |
|
68 |
try { |
|
69 |
TopologyManager manager = TopologyLocator.getTopologyManager(); |
|
70 |
manager.addRuleFactories(new PolygonMustNotOverlapWithPolygonRuleFactory()); |
|
71 |
} catch(Exception ex) { |
|
72 |
LOGGER.warn("Can't register topology rule from "+PolygonMustNotOverlapWithPolygonRuleFactory.class.getSimpleName(), ex); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
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 | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.topology.rule; |
|
25 |
|
|
26 |
import org.gvsig.expressionevaluator.Expression; |
|
27 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
28 |
import org.gvsig.expressionevaluator.GeometryExpressionBuilder; |
|
29 |
import org.gvsig.expressionevaluator.GeometryExpressionUtils; |
|
30 |
import org.gvsig.fmap.dal.feature.Feature; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
33 |
import org.gvsig.fmap.geom.Geometry; |
|
34 |
import org.gvsig.tools.ToolsLocator; |
|
35 |
import org.gvsig.tools.dynobject.DynObject; |
|
36 |
import org.gvsig.tools.i18n.I18nManager; |
|
37 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
38 |
import org.gvsig.topology.lib.api.ExecuteTopologyRuleActionException; |
|
39 |
import org.gvsig.topology.lib.api.TopologyDataSet; |
|
40 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
41 |
import org.gvsig.topology.lib.api.TopologyReport; |
|
42 |
import org.gvsig.topology.lib.api.TopologyReportLine; |
|
43 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
44 |
import org.gvsig.topology.lib.api.TopologyRuleFactory; |
|
45 |
import org.gvsig.topology.lib.spi.AbstractTopologyRule; |
|
46 |
import org.gvsig.topology.lib.spi.AbstractTopologyRuleAction; |
|
47 |
|
|
48 |
/** |
|
49 |
* |
|
50 |
* @author jjdelcerro |
|
51 |
*/ |
|
52 |
@SuppressWarnings("UseSpecificCatch") |
|
53 |
public class PolygonMustNotOverlapWithPolygonRule extends AbstractTopologyRule { |
|
54 |
|
|
55 |
private class SubtractAction extends AbstractTopologyRuleAction { |
|
56 |
|
|
57 |
public SubtractAction() { |
|
58 |
super( |
|
59 |
PolygonMustNotOverlapWithPolygonRuleFactory.NAME, |
|
60 |
"Subtract", |
|
61 |
"Subtract", |
|
62 |
"The Subtract fix removes the overlapping portion of each feature that is causing the error and leaves a gap or void in its place. This fix can be applied to one or more selected Must Not Overlap With errors." |
|
63 |
); |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) { |
|
68 |
try { |
|
69 |
Geometry errorGeom = line.getError(); |
|
70 |
|
|
71 |
FeatureReference featRef1 = line.getFeature1(); |
|
72 |
Feature feat1 = featRef1.getFeature(); |
|
73 |
Geometry geom1 = feat1.getDefaultGeometry(); |
|
74 |
|
|
75 |
FeatureReference featRef2 = line.getFeature2(); |
|
76 |
Feature feat2 = featRef2.getFeature(); |
|
77 |
Geometry geom2 = feat2.getDefaultGeometry(); |
|
78 |
|
|
79 |
substract(featRef1, geom2, rule.getDataSet1()); |
|
80 |
substract(featRef2, geom1, rule.getDataSet2()); |
|
81 |
return EXECUTE_OK; |
|
82 |
|
|
83 |
} catch (Exception ex) { |
|
84 |
throw new ExecuteTopologyRuleActionException(ex); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
private class MergeAction extends AbstractTopologyRuleAction { |
|
91 |
|
|
92 |
public MergeAction() { |
|
93 |
super( |
|
94 |
PolygonMustNotOverlapWithPolygonRuleFactory.NAME, |
|
95 |
"Merge", |
|
96 |
"Merge", |
|
97 |
"The Merge fix adds the portion of overlap from one feature and subtracts it from the others that are violating the rule. You need to pick the feature that receives the portion of overlap using the Merge dialog box. This fix can be applied to one Must Not Overlap With error only." |
|
98 |
); |
|
99 |
} |
|
100 |
|
|
101 |
@Override |
|
102 |
public int execute(TopologyRule rule, TopologyReportLine line, DynObject parameters) { |
|
103 |
try { |
|
104 |
Geometry errorGeom = line.getError(); |
|
105 |
|
|
106 |
FeatureReference featRef1 = line.getFeature1(); |
|
107 |
Feature feat1 = featRef1.getFeature(); |
|
108 |
Geometry geom1 = feat1.getDefaultGeometry(); |
|
109 |
|
|
110 |
FeatureReference featRef2 = line.getFeature2(); |
|
111 |
|
|
112 |
substract(featRef2, geom1, rule.getDataSet2()); |
|
113 |
return EXECUTE_OK; |
|
114 |
|
|
115 |
} catch (Exception ex) { |
|
116 |
throw new ExecuteTopologyRuleActionException(ex); |
|
117 |
} |
|
118 |
} |
|
119 |
|
|
120 |
} |
|
121 |
|
|
122 |
private String geomName; |
|
123 |
private Expression expression = null; |
|
124 |
private GeometryExpressionBuilder expressionBuilder = null; |
|
125 |
|
|
126 |
public PolygonMustNotOverlapWithPolygonRule( |
|
127 |
TopologyPlan plan, |
|
128 |
TopologyRuleFactory factory, |
|
129 |
double tolerance, |
|
130 |
String dataSet1, |
|
131 |
String dataSet2 |
|
132 |
) { |
|
133 |
super(plan, factory, tolerance, dataSet1, dataSet2); |
|
134 |
this.addAction(new MergeAction()); |
|
135 |
this.addAction(new SubtractAction()); |
|
136 |
} |
|
137 |
|
|
138 |
@Override |
|
139 |
protected void check(SimpleTaskStatus taskStatus, TopologyReport report, Feature feature1) throws Exception { |
|
140 |
try { |
|
141 |
if (this.expression == null) { |
|
142 |
this.expression = ExpressionUtils.createExpression(); |
|
143 |
this.expressionBuilder = GeometryExpressionUtils.createExpressionBuilder(); |
|
144 |
this.geomName = feature1.getType().getDefaultGeometryAttributeName(); |
|
145 |
} |
|
146 |
Geometry polygon = feature1.getDefaultGeometry(); |
|
147 |
if( polygon==null ) { |
|
148 |
return; |
|
149 |
} |
|
150 |
TopologyDataSet thisDataSet = this.getDataSet1(); |
|
151 |
TopologyDataSet otherDataSet = this.getDataSet2(); |
|
152 |
if (otherDataSet.getSpatialIndex() != null) { |
|
153 |
for (FeatureReference otherReference : otherDataSet.query(polygon)) { |
|
154 |
// if (otherReference.equals(feature1.getReference())) { |
|
155 |
// continue; |
|
156 |
// } |
|
157 |
Feature otherFeature = otherReference.getFeature(); |
|
158 |
Geometry otherPolygon = otherFeature.getDefaultGeometry(); |
|
159 |
double halfTolerance = this.getTolerance()/2; |
|
160 |
if (otherPolygon!=null && polygon.buffer(-halfTolerance).overlaps(otherPolygon.buffer(-halfTolerance))) { |
|
161 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
162 |
Geometry error = polygon.intersection(otherPolygon); |
|
163 |
report.addLine(this, |
|
164 |
thisDataSet, |
|
165 |
otherDataSet, |
|
166 |
polygon, |
|
167 |
error, |
|
168 |
feature1.getReference(), |
|
169 |
otherFeature.getReference(), |
|
170 |
false, |
|
171 |
i18n.getTranslation("_The_polygon_overlay_with_other") |
|
172 |
); |
|
173 |
} |
|
174 |
} |
|
175 |
} else { |
|
176 |
this.expression.setPhrase( |
|
177 |
this.expressionBuilder.ifnull( |
|
178 |
this.expressionBuilder.column(this.geomName), |
|
179 |
this.expressionBuilder.constant(false), |
|
180 |
this.expressionBuilder.ST_Overlaps( |
|
181 |
this.expressionBuilder.column(this.geomName), |
|
182 |
this.expressionBuilder.geometry(polygon) |
|
183 |
) |
|
184 |
).toString() |
|
185 |
); |
|
186 |
FeatureSet otherFeatures = otherDataSet.getFeatureStore().getFeatureSet(this.expression); |
|
187 |
for (Feature otherFeature : otherFeatures) { |
|
188 |
if ( otherFeature != null) { |
|
189 |
Geometry otherPolygon = otherFeature.getDefaultGeometry(); |
|
190 |
double halfTolerance = this.getTolerance()/2; |
|
191 |
if (otherPolygon!=null && polygon.buffer(-halfTolerance).overlaps(otherPolygon.buffer(-halfTolerance))) { |
|
192 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
193 |
Geometry error = polygon.intersection(otherPolygon); |
|
194 |
report.addLine(this, |
|
195 |
thisDataSet, |
|
196 |
otherDataSet, |
|
197 |
polygon, |
|
198 |
error, |
|
199 |
feature1.getReference(), |
|
200 |
otherFeature.getReference(), |
|
201 |
false, |
|
202 |
i18n.getTranslation("_The_polygon_overlay_with_other") |
|
203 |
); |
|
204 |
} |
|
205 |
} |
|
206 |
} |
|
207 |
} |
|
208 |
} catch (Exception ex) { |
|
209 |
LOGGER.warn("Can't check feature.", ex); |
|
210 |
} finally { |
|
211 |
} |
|
212 |
} |
|
213 |
|
|
214 |
} |
|
215 |
|
Also available in: Unified diff