Revision 3278
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.topology.lib.impl.TopologyImplLibrary |
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/ContainsPoint.json | ||
---|---|---|
1 |
{ |
|
2 |
"id": "ContainsPoint", |
|
3 |
"name": "Contains Point", |
|
4 |
"description": [ |
|
5 |
"<img src=\"@@@.d/contains_point2.png\">\n", |
|
6 |
"The top polygon is an error because it does not contain a point.\n\n", |
|
7 |
"Requires that a polygon in the primary dataset contain at least one", |
|
8 |
"point from the secondary dataset.\n", |
|
9 |
"Points must be within the polygon, not on the boundary.\n", |
|
10 |
"This is useful when every polygon should have at least one associated", |
|
11 |
"point, such as when parcels must have an address point." |
|
12 |
], |
|
13 |
"actions" : { |
|
14 |
"CreateFeature": { |
|
15 |
"name" : "Create feature", |
|
16 |
"description": [ |
|
17 |
"The Create Feature fix creates a new point feature at the centroid", |
|
18 |
"of the polygon feature that is causing the error.\n", |
|
19 |
"The point feature that is created is guaranteed to be within the polygon feature." |
|
20 |
] |
|
21 |
} |
|
22 |
} |
|
23 |
} |
|
24 |
|
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/MustNotOverlapPolygon.json | ||
---|---|---|
1 |
{ |
|
2 |
"id": "MustNotOverlapPolygon", |
|
3 |
"name": "Must Not Overlap", |
|
4 |
"description": [ |
|
5 |
"<img src=\"@@@.d/must_not_overlap.png\">\n", |
|
6 |
"Requires that the interior of polygons in the dataset not overlap.", |
|
7 |
"The polygons can share edges or vertices.", |
|
8 |
"This rule is used when an area cannot belong to two or more polygons.", |
|
9 |
"The polygons overlaps when the geometries have some points in common;", |
|
10 |
"but not all points in common (so if one geometry is inside the other", |
|
11 |
"overlaps would be false).", |
|
12 |
"The overlapping section must be the same kind of shape as the two geometries;", |
|
13 |
"so two polygons that touch on a point are not considered to be overlapping.", |
|
14 |
"It is useful for modeling administrative boundaries, such as ZIP Codes", |
|
15 |
"or voting districts, and mutually exclusive area classifications,", |
|
16 |
"such as land cover or landform type." |
|
17 |
], |
|
18 |
"actions" : { |
|
19 |
"CreateFeature": { |
|
20 |
"name" : "Create feature", |
|
21 |
"description": [ |
|
22 |
"The Create Feature fix creates a new polygon feature out of", |
|
23 |
"the error shape and removes the portion of overlap from each", |
|
24 |
"of the features, causing the error to create a planar", |
|
25 |
"representation of the feature geometry.\n", |
|
26 |
"This fix can be applied to one or more selected Must Not Overlap errors." |
|
27 |
] |
|
28 |
}, |
|
29 |
"Subtract": { |
|
30 |
"name" : "Subtract", |
|
31 |
"description": [ |
|
32 |
"The Subtract fix removes the overlapping portion of geometry", |
|
33 |
"from each feature that is causing the error and leaves a gap", |
|
34 |
"or void in its place. This fix can be applied to one or more", |
|
35 |
"selected Must Not Overlap errors." |
|
36 |
] |
|
37 |
}, |
|
38 |
"Merge": { |
|
39 |
"name" : "Merge", |
|
40 |
"description": [ |
|
41 |
"The Merge fix adds the portion of overlap from one feature", |
|
42 |
"and subtracts it from the others that are violating the rule.", |
|
43 |
"You need to pick the feature that receives the portion of", |
|
44 |
"overlap using the Merge dialog box.", |
|
45 |
"This fix can be applied to one Must Not Overlap error only." |
|
46 |
] |
|
47 |
} |
|
48 |
} |
|
49 |
} |
|
50 |
|
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/en/MustBeLargerThanToleranceLine.json | ||
---|---|---|
1 |
{ |
|
2 |
"id": "MustBeLargerThanToleranceLine", |
|
3 |
"name": "Must Be Larger Than Tolerance", |
|
4 |
"description": [ |
|
5 |
"<img src=\"@@@.d/MustBeLargerThanToleranceLine.png\">\n", |
|
6 |
"Requires that a feature does not collapse during a validate process.\n", |
|
7 |
"This rule is mandatory for a topology and applies to all line feature classes.\n", |
|
8 |
"In instances where this rule is violated, the original geometry is left unchanged.\n" |
|
9 |
], |
|
10 |
"actions" : { |
|
11 |
"delete": { |
|
12 |
"name" : "Delete", |
|
13 |
"description": [ |
|
14 |
"Removes line features that would collapse during the validate", |
|
15 |
"process based on the topology's tolerance." |
|
16 |
] |
|
17 |
} |
|
18 |
} |
|
19 |
} |
|
20 |
|
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/MustBeLargerThanToleranceLine.json | ||
---|---|---|
1 |
{ |
|
2 |
"id": "MustBeLargerThanToleranceLine", |
|
3 |
"name": "Debe ser mayor que la tolerancia", |
|
4 |
"description": [ |
|
5 |
"<img src=\"@@@.d/MustBeLargerThanToleranceLine.png\">\n", |
|
6 |
"Requiere que una feature no colapse durante el proceso de validacion.\n", |
|
7 |
"Esta regla es obligatoria para una topologia y aplica a todas las features de typo linea.\n", |
|
8 |
"En instancias donde esta regla es violada, la geometria original permanece sin cambios.\n" |
|
9 |
], |
|
10 |
"actions" : { |
|
11 |
"delete": { |
|
12 |
"name" : "Eliminar", |
|
13 |
"description": [ |
|
14 |
"Elimina las Removes features que colapsaran durante el proceso", |
|
15 |
"de validacion basado en la tolerancia topologica." |
|
16 |
] |
|
17 |
} |
|
18 |
} |
|
19 |
} |
|
20 |
|
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/resources/org/gvsig/topology/rules/es/ContainsPoint.json | ||
---|---|---|
1 |
{ |
|
2 |
"id": "ContainsPoint", |
|
3 |
"name": "Contiene un punto", |
|
4 |
"description": [ |
|
5 |
"<img src=\"@@@.d/contains_point2.png\">\n", |
|
6 |
"El poligono superior es un error porque no contiene ningun punto.\n\n", |
|
7 |
"Requiere que cada poligono del conjunto de datos contenga al menos un punto del otro conjunto de datos.\n", |
|
8 |
"Los puntos deben estar contenidos en el poligono, no en su perimetro,\n" |
|
9 |
], |
|
10 |
"actions" : { |
|
11 |
"CreateFeature": { |
|
12 |
"name" : "Crear feature", |
|
13 |
"description": [ |
|
14 |
"<i>Crear feature</i> realiza la correccion creando un nuevo punto en", |
|
15 |
"la feature, en el centroide del poligono que ha causado el error.\n", |
|
16 |
"El punto creado en la feature se garantiza que estara dentro del polygono de la feature." |
|
17 |
] |
|
18 |
} |
|
19 |
} |
|
20 |
} |
|
21 |
|
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyManager.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.lib.impl; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Collections; |
|
28 |
import java.util.HashMap; |
|
29 |
import java.util.List; |
|
30 |
import java.util.Map; |
|
31 |
import org.gvsig.fmap.dal.DataStore; |
|
32 |
import org.gvsig.topology.lib.api.TopologyDataSet; |
|
33 |
import org.gvsig.topology.lib.api.TopologyManager; |
|
34 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
35 |
import org.gvsig.topology.lib.api.TopologyRuleFactory; |
|
36 |
import org.gvsig.topology.lib.api.TopologyServices; |
|
37 |
|
|
38 |
/** |
|
39 |
* |
|
40 |
* @author jjdelcerro |
|
41 |
*/ |
|
42 |
public class DefaultTopologyManager implements TopologyManager { |
|
43 |
|
|
44 |
private final Map<String,TopologyRuleFactory> factories; |
|
45 |
private TopologyServices services; |
|
46 |
|
|
47 |
public DefaultTopologyManager() { |
|
48 |
this.factories = new HashMap<>(); |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public TopologyPlan createTopologyPlan() { |
|
53 |
TopologyPlan plan = new DefaultTopologyPlan(this, this.services); |
|
54 |
return plan; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public List<TopologyRuleFactory> getRuleFactories() { |
|
59 |
List<TopologyRuleFactory> l = new ArrayList<>(this.factories.values()); |
|
60 |
return Collections.unmodifiableList(l); |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public List<TopologyRuleFactory> getRuleFactories(TopologyDataSet dataSet) { |
|
65 |
List<TopologyRuleFactory> f = new ArrayList<>(); |
|
66 |
for (TopologyRuleFactory factory : this.factories.values()) { |
|
67 |
if( factory.canApplyToDataSet(dataSet) ) { |
|
68 |
f.add(factory); |
|
69 |
} |
|
70 |
} |
|
71 |
return f; |
|
72 |
} |
|
73 |
|
|
74 |
@Override |
|
75 |
public TopologyRuleFactory getRulefactory(String id) { |
|
76 |
if( id==null ) { |
|
77 |
return null; |
|
78 |
} |
|
79 |
TopologyRuleFactory factory = this.factories.get(id.toLowerCase()); |
|
80 |
return factory; |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public void addRuleFactories(TopologyRuleFactory factory) { |
|
85 |
if( factory==null ) { |
|
86 |
throw new IllegalArgumentException("Invalid null value."); |
|
87 |
} |
|
88 |
this.factories.put(factory.getId().toLowerCase(), factory); |
|
89 |
} |
|
90 |
|
|
91 |
@Override |
|
92 |
public TopologyDataSet createDataSet(String name, DataStore store) { |
|
93 |
TopologyDataSet dataSet = new DefaultTopologyDataSet(this.services, name, store); |
|
94 |
return dataSet; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public void setDefaultServices(TopologyServices services) { |
|
99 |
this.services = services; |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public TopologyServices getDefaultServices() { |
|
104 |
return this.services; |
|
105 |
} |
|
106 |
|
|
107 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyPlan.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.lib.impl; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Collection; |
|
28 |
import java.util.Collections; |
|
29 |
import java.util.Date; |
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.List; |
|
32 |
import java.util.Map; |
|
33 |
import org.gvsig.fmap.dal.DataStore; |
|
34 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
35 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
36 |
import org.gvsig.fmap.geom.GeometryManager; |
|
37 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
38 |
import org.gvsig.tools.ToolsLocator; |
|
39 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
40 |
import org.gvsig.topology.lib.api.TopologyDataSet; |
|
41 |
import org.gvsig.topology.lib.api.TopologyManager; |
|
42 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
43 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
44 |
import org.gvsig.topology.lib.api.TopologyRuleFactory; |
|
45 |
import org.gvsig.topology.lib.api.TopologyServices; |
|
46 |
import org.json.JSONArray; |
|
47 |
import org.json.JSONObject; |
|
48 |
import org.slf4j.Logger; |
|
49 |
import org.slf4j.LoggerFactory; |
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
* @author jjdelcerro |
|
54 |
*/ |
|
55 |
@SuppressWarnings("UseSpecificCatch") |
|
56 |
public class DefaultTopologyPlan implements TopologyPlan { |
|
57 |
|
|
58 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultTopologyPlan.class); |
|
59 |
|
|
60 |
private final TopologyManager manager; |
|
61 |
private final Map<String,TopologyDataSet> dataSets; |
|
62 |
private final List<TopologyRule> rules; |
|
63 |
|
|
64 |
private String name; |
|
65 |
private DefaultTopologyReport report; |
|
66 |
private TopologyServices services; |
|
67 |
private double tolerance; |
|
68 |
private SimpleTaskStatus taskStatus; |
|
69 |
|
|
70 |
public DefaultTopologyPlan(TopologyManager manager, TopologyServices services) { |
|
71 |
this.manager = manager; |
|
72 |
this.services = services; |
|
73 |
this.dataSets = new HashMap<>(); |
|
74 |
this.rules = new ArrayList<>(); |
|
75 |
this.report = null; |
|
76 |
this.name = "TopologyPlan-" + String.format("%08X", new Date().getTime()); |
|
77 |
this.tolerance = 0; |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public void setName(String name) { |
|
82 |
this.name = name; |
|
83 |
} |
|
84 |
|
|
85 |
@Override |
|
86 |
public String getName() { |
|
87 |
return this.name; |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public void clear() { |
|
92 |
this.name = ""; |
|
93 |
this.tolerance = 0; |
|
94 |
this.services = null; |
|
95 |
this.report = null; |
|
96 |
this.dataSets.clear(); |
|
97 |
this.rules.clear(); |
|
98 |
} |
|
99 |
|
|
100 |
@Override |
|
101 |
public double getTolerance() { |
|
102 |
return tolerance; |
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public void setTolerance(double tolerance) { |
|
107 |
this.tolerance = tolerance; |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public void setTopologyServices(TopologyServices services) { |
|
112 |
this.services = services; |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public TopologyServices getTopologyServices() { |
|
117 |
return this.services; |
|
118 |
} |
|
119 |
|
|
120 |
public SimpleTaskStatus getTaskStatus() { |
|
121 |
if( this.taskStatus == null ) { |
|
122 |
this.taskStatus = ToolsLocator.getTaskStatusManager() |
|
123 |
.createDefaultSimpleTaskStatus(this.getName()); |
|
124 |
} |
|
125 |
return this.taskStatus; |
|
126 |
} |
|
127 |
|
|
128 |
@Override |
|
129 |
public void execute() { |
|
130 |
SimpleTaskStatus theTaskStatus = this.getTaskStatus(); |
|
131 |
try { |
|
132 |
theTaskStatus.restart(); |
|
133 |
theTaskStatus.message("Preparing the execution of the plan"); |
|
134 |
theTaskStatus.setAutoremove(true); |
|
135 |
theTaskStatus.setIndeterminate(); |
|
136 |
for (TopologyDataSet dataSet : this.dataSets.values()) { |
|
137 |
dataSet.restart(); |
|
138 |
} |
|
139 |
this.getReport().removeAllLines(); |
|
140 |
long steps = 0; |
|
141 |
for (TopologyRule rule : this.rules) { |
|
142 |
steps += rule.getSteps(); |
|
143 |
steps++; |
|
144 |
} |
|
145 |
|
|
146 |
theTaskStatus.setRangeOfValues(0, steps); |
|
147 |
theTaskStatus.setCurValue(0); |
|
148 |
for (TopologyRule rule : this.rules) { |
|
149 |
if( theTaskStatus.isCancellationRequested() ) { |
|
150 |
theTaskStatus.cancel(); |
|
151 |
break; |
|
152 |
} |
|
153 |
theTaskStatus.message(rule.getName()); |
|
154 |
rule.execute(theTaskStatus, this.getReport()); |
|
155 |
theTaskStatus.incrementCurrentValue(); |
|
156 |
} |
|
157 |
} catch(Exception ex) { |
|
158 |
LOGGER.warn("Problems executing topology plan '"+this.getName()+"'.", ex); |
|
159 |
theTaskStatus.abort(); |
|
160 |
} finally { |
|
161 |
if( theTaskStatus.isRunning() ) { |
|
162 |
theTaskStatus.terminate(); |
|
163 |
} |
|
164 |
this.getReport().setCompleted(true); |
|
165 |
} |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
public TopologyDataSet addDataSet(String name, DataStore store) { |
|
170 |
TopologyDataSet dataSet = manager.createDataSet(name, store); |
|
171 |
return this.addDataSet(dataSet); |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
public TopologyDataSet addDataSet(TopologyDataSet dataSet) { |
|
176 |
if( this.dataSets.containsKey(dataSet.getName()) ) { |
|
177 |
throw new IllegalArgumentException("Already exists a dataSet with this name ("+dataSet.getName()+")."); |
|
178 |
} |
|
179 |
this.dataSets.put(dataSet.getName(), dataSet); |
|
180 |
return dataSet; |
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
184 |
public TopologyDataSet getDataSet(String name) { |
|
185 |
return this.dataSets.get(name); |
|
186 |
} |
|
187 |
|
|
188 |
@Override |
|
189 |
public boolean containsDataSet(String name) { |
|
190 |
return this.dataSets.containsKey(name); |
|
191 |
} |
|
192 |
|
|
193 |
@Override |
|
194 |
public Collection<TopologyDataSet> getDataSets() { |
|
195 |
Collection<TopologyDataSet> x = dataSets.values(); |
|
196 |
return Collections.unmodifiableCollection(x); |
|
197 |
} |
|
198 |
|
|
199 |
@Override |
|
200 |
public Collection<TopologyDataSet> getSecondaryDataSets(TopologyRuleFactory ruleFactory) { |
|
201 |
List<TopologyDataSet> secondaryDataSets = new ArrayList<>(); |
|
202 |
for (TopologyDataSet dataSet : dataSets.values()) { |
|
203 |
if( ruleFactory.canApplyToSecondaryDataSet(dataSet) ) { |
|
204 |
secondaryDataSets.add(dataSet); |
|
205 |
} |
|
206 |
} |
|
207 |
return secondaryDataSets; |
|
208 |
} |
|
209 |
|
|
210 |
@Override |
|
211 |
public TopologyRule addRule(String id, String dataSet1, String dataSet2, double tolerance) { |
|
212 |
TopologyRuleFactory factory = this.manager.getRulefactory(id); |
|
213 |
if( factory == null ) { |
|
214 |
throw new IllegalArgumentException("Can't locate factory for rule '"+id+"'."); |
|
215 |
} |
|
216 |
if( ! this.canApplyRule(factory, dataSet1, dataSet2) ) { |
|
217 |
throw new IllegalArgumentException( |
|
218 |
"Can't apply rule '"+factory.getName()+"' to the datasets '"+dataSet1+"/"+dataSet2+"'." |
|
219 |
); |
|
220 |
} |
|
221 |
TopologyRule rule = factory.createRule(this, dataSet1, dataSet2, tolerance); |
|
222 |
return this.addRule(rule); |
|
223 |
} |
|
224 |
|
|
225 |
@Override |
|
226 |
public TopologyRule addRule(TopologyRule rule) { |
|
227 |
this.rules.add(rule); |
|
228 |
return rule; |
|
229 |
} |
|
230 |
|
|
231 |
private boolean canApplyRule(TopologyRuleFactory factory, String dataSet1, String dataSet2) { |
|
232 |
try { |
|
233 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
234 |
TopologyDataSet dataset = this.getDataSet(dataSet1); |
|
235 |
FeatureStore store = (FeatureStore) dataset.getStore(); |
|
236 |
GeometryType gt = store.getDefaultFeatureType().getDefaultGeometryAttribute().getGeomType(); |
|
237 |
for (Integer geometryType1 : factory.getGeometryTypeDataSet1()) { |
|
238 |
if( gt.isTypeOf(geometryType1) ) { |
|
239 |
if( factory.getGeometryTypeDataSet2()==null ) { |
|
240 |
return true; |
|
241 |
} |
|
242 |
dataset = this.getDataSet(dataSet2); |
|
243 |
store = (FeatureStore) dataset.getStore(); |
|
244 |
gt = store.getDefaultFeatureType().getDefaultGeometryAttribute().getGeomType(); |
|
245 |
for (Integer geometryType2 : factory.getGeometryTypeDataSet2()) { |
|
246 |
if( gt.isTypeOf(geometryType2) ) { |
|
247 |
return true; |
|
248 |
} |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
return false; |
|
253 |
} catch(Exception ex) { |
|
254 |
return false; |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
@Override |
|
259 |
public Collection<TopologyRule> getRules() { |
|
260 |
return Collections.unmodifiableList(rules); |
|
261 |
} |
|
262 |
|
|
263 |
@Override |
|
264 |
public DefaultTopologyReport getReport() { |
|
265 |
if( this.report == null ) { |
|
266 |
this.report = new DefaultTopologyReport(this); |
|
267 |
} |
|
268 |
return this.report; |
|
269 |
} |
|
270 |
|
|
271 |
@Override |
|
272 |
public JSONObject toJSON() { |
|
273 |
JSONObject me = new JSONObject(); |
|
274 |
|
|
275 |
me.put("name", this.name); |
|
276 |
me.put("tolerance", this.tolerance); |
|
277 |
|
|
278 |
JSONArray jsonDataSets= new JSONArray(); |
|
279 |
for (TopologyDataSet dataSet : this.dataSets.values()) { |
|
280 |
jsonDataSets.put(((DefaultTopologyDataSet)dataSet).toJSON()); |
|
281 |
} |
|
282 |
me.put("dataSets", jsonDataSets); |
|
283 |
|
|
284 |
JSONArray jsonRules = new JSONArray(); |
|
285 |
for (TopologyRule rule : this.rules) { |
|
286 |
JSONObject jsonRule = rule.toJSON(); |
|
287 |
jsonRule.put("__factoryId", rule.getFactory().getId()); |
|
288 |
jsonRules.put(jsonRule); |
|
289 |
} |
|
290 |
me.put("rules", jsonRules); |
|
291 |
|
|
292 |
return me; |
|
293 |
} |
|
294 |
|
|
295 |
@Override |
|
296 |
public void fromJSON(String json) { |
|
297 |
this.fromJSON(new JSONObject(json)); |
|
298 |
} |
|
299 |
|
|
300 |
@Override |
|
301 |
public void fromJSON(JSONObject jsonPlan) { |
|
302 |
|
|
303 |
this.name = jsonPlan.getString("name"); |
|
304 |
this.tolerance = jsonPlan.getDouble("tolerance"); |
|
305 |
|
|
306 |
JSONArray jsonDataSets = jsonPlan.getJSONArray("dataSets"); |
|
307 |
for (Object o : jsonDataSets) { |
|
308 |
TopologyDataSet dataSet = new DefaultTopologyDataSet(); |
|
309 |
dataSet.fromJSON((JSONObject) o); |
|
310 |
this.dataSets.put(dataSet.getName(),dataSet); |
|
311 |
} |
|
312 |
|
|
313 |
JSONArray jsonRules = jsonPlan.getJSONArray("rules"); |
|
314 |
for (Object o : jsonRules) { |
|
315 |
JSONObject jsonRule = (JSONObject) o; |
|
316 |
TopologyRuleFactory factory = this.manager.getRulefactory(jsonRule.getString("__factoryId")); |
|
317 |
TopologyRule rule = factory.createRule(this,null, null, -1); |
|
318 |
rule.fromJSON(jsonRule); |
|
319 |
this.addRule(rule); |
|
320 |
} |
|
321 |
} |
|
322 |
|
|
323 |
@Override |
|
324 |
public void removeDataSet(TopologyDataSet dataSet) { |
|
325 |
this.dataSets.remove(dataSet.getName()); |
|
326 |
} |
|
327 |
|
|
328 |
@Override |
|
329 |
public void removeRule(TopologyRule rule) { |
|
330 |
this.rules.remove(rule); |
|
331 |
} |
|
332 |
|
|
333 |
|
|
334 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyReport.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.lib.impl; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Collections; |
|
28 |
import java.util.List; |
|
29 |
import org.gvsig.expressionevaluator.Code; |
|
30 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
|
31 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
|
32 |
import org.gvsig.expressionevaluator.MutableSymbolTable; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
34 |
import org.gvsig.fmap.geom.Geometry; |
|
35 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
36 |
import org.gvsig.topology.lib.api.TopologyDataSet; |
|
37 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
38 |
import org.gvsig.topology.lib.api.TopologyReport; |
|
39 |
import org.gvsig.topology.lib.api.TopologyReportLine; |
|
40 |
import org.gvsig.topology.lib.api.TopologyReportLineSet; |
|
41 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
42 |
import org.slf4j.Logger; |
|
43 |
import org.slf4j.LoggerFactory; |
|
44 |
|
|
45 |
/** |
|
46 |
* |
|
47 |
* @author jjdelcerro |
|
48 |
*/ |
|
49 |
@SuppressWarnings("UseSpecificCatch") |
|
50 |
public class DefaultTopologyReport |
|
51 |
extends AbstractTopologyReportLineSet |
|
52 |
implements TopologyReport |
|
53 |
{ |
|
54 |
|
|
55 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultTopologyReport.class); |
|
56 |
|
|
57 |
private class DefaultTopologyReportLineSet extends AbstractTopologyReportLineSet { |
|
58 |
|
|
59 |
public DefaultTopologyReportLineSet() { |
|
60 |
super(); |
|
61 |
} |
|
62 |
|
|
63 |
public void polulate(List<TopologyReportLine> allLines, String filter) { |
|
64 |
this.lines.clear(); |
|
65 |
if (filter == null) { |
|
66 |
this.lines.addAll(allLines); |
|
67 |
this.completed = true; |
|
68 |
return; |
|
69 |
} |
|
70 |
SimpleTaskStatus theTaskStatus = plan.getTaskStatus(); |
|
71 |
try { |
|
72 |
theTaskStatus.push(); |
|
73 |
theTaskStatus.restart(); |
|
74 |
theTaskStatus.message("Preparing filter"); |
|
75 |
theTaskStatus.setAutoremove(true); |
|
76 |
theTaskStatus.setIndeterminate(); |
|
77 |
|
|
78 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
|
79 |
|
|
80 |
TopologyReportLineSymbolTable lineSymbolTable = new TopologyReportLineSymbolTable(); |
|
81 |
MutableSymbolTable symbolTable = manager.createSymbolTable(); |
|
82 |
symbolTable.addSymbolTable(lineSymbolTable); |
|
83 |
|
|
84 |
Code code = manager.compile(filter); |
|
85 |
code = manager.optimize(symbolTable, code); |
|
86 |
|
|
87 |
theTaskStatus.setRangeOfValues(0, allLines.size()); |
|
88 |
theTaskStatus.setCurValue(0); |
|
89 |
for (TopologyReportLine line : allLines) { |
|
90 |
lineSymbolTable.setLine(line); |
|
91 |
Object value = manager.evaluate(symbolTable, code); |
|
92 |
if (value instanceof Boolean && ((Boolean) value)) { |
|
93 |
this.lines.add(line); |
|
94 |
this.changeListenerHelper.fireEvent(); |
|
95 |
} |
|
96 |
theTaskStatus.incrementCurrentValue(); |
|
97 |
} |
|
98 |
|
|
99 |
} catch (Exception ex) { |
|
100 |
LOGGER.warn("Problems filtering.", ex); |
|
101 |
theTaskStatus.abort(); |
|
102 |
} finally { |
|
103 |
if (theTaskStatus.isRunning()) { |
|
104 |
theTaskStatus.terminate(); |
|
105 |
} |
|
106 |
theTaskStatus.pop(); |
|
107 |
this.completed = true; |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
// TODO: Habria que meter las lineas del report en disco |
|
115 |
private final TopologyPlan plan; |
|
116 |
|
|
117 |
public DefaultTopologyReport(TopologyPlan plan) { |
|
118 |
this.plan = plan; |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
122 |
public TopologyReportLine addLine(TopologyRule rule, TopologyDataSet dataSet1, |
|
123 |
TopologyDataSet dataSet2, Geometry geometry, Geometry error, |
|
124 |
FeatureReference feature1, FeatureReference feature2, |
|
125 |
boolean exception, String description |
|
126 |
) { |
|
127 |
TopologyReportLine line = new DefaultTopologyReportLine( |
|
128 |
this, rule, dataSet1, dataSet2, geometry, error, feature1, |
|
129 |
feature2, -1, -1, exception, description, null |
|
130 |
); |
|
131 |
this.lines.add(line); |
|
132 |
this.fireChangeEvent(); |
|
133 |
return line; |
|
134 |
} |
|
135 |
|
|
136 |
@Override |
|
137 |
public TopologyReportLine addLine(TopologyRule rule, |
|
138 |
TopologyDataSet dataSet1,TopologyDataSet dataSet2, |
|
139 |
Geometry geometry, Geometry error, |
|
140 |
FeatureReference feature1, FeatureReference feature2, |
|
141 |
int primitive1, int primitive2, |
|
142 |
boolean exception, |
|
143 |
String description, |
|
144 |
String data |
|
145 |
) { |
|
146 |
TopologyReportLine line = new DefaultTopologyReportLine( |
|
147 |
this, rule, dataSet1, dataSet2, geometry, error, feature1, |
|
148 |
feature2, primitive1, primitive2, exception, description, data |
|
149 |
); |
|
150 |
this.lines.add(line); |
|
151 |
this.fireChangeEvent(); |
|
152 |
return line; |
|
153 |
} |
|
154 |
|
|
155 |
@Override |
|
156 |
public void removeAllLines() { |
|
157 |
this.lines.clear(); |
|
158 |
this.fireChangeEvent(); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public TopologyReportLineSet getLineSet(final String filter) { |
|
163 |
final DefaultTopologyReportLineSet set = new DefaultTopologyReportLineSet(); |
|
164 |
Thread th = new Thread(new Runnable() { |
|
165 |
@Override |
|
166 |
public void run() { |
|
167 |
set.polulate(lines, filter); |
|
168 |
} |
|
169 |
}); |
|
170 |
th.start(); |
|
171 |
return set; |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
public List<TopologyReportLine> getLines(String filter) { |
|
176 |
if (filter == null) { |
|
177 |
return Collections.unmodifiableList(this.lines); |
|
178 |
} |
|
179 |
List<TopologyReportLine> ll = new ArrayList<>(); |
|
180 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
|
181 |
|
|
182 |
TopologyReportLineSymbolTable lineSymbolTable = new TopologyReportLineSymbolTable(); |
|
183 |
MutableSymbolTable symbolTable = manager.createSymbolTable(); |
|
184 |
symbolTable.addSymbolTable(lineSymbolTable); |
|
185 |
|
|
186 |
Code code = manager.compile(filter); |
|
187 |
code = manager.optimize(symbolTable, code); |
|
188 |
|
|
189 |
for (TopologyReportLine line : this.lines) { |
|
190 |
lineSymbolTable.setLine(line); |
|
191 |
Object value = manager.evaluate(symbolTable, code); |
|
192 |
if (value instanceof Boolean && ((Boolean) value)) { |
|
193 |
ll.add(line); |
|
194 |
} |
|
195 |
} |
|
196 |
return Collections.unmodifiableList(ll); |
|
197 |
} |
|
198 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/TopologyReportLineSymbolTable.java | ||
---|---|---|
1 |
package org.gvsig.topology.lib.impl; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
import org.gvsig.expressionevaluator.spi.AbstractSymbolTable; |
|
6 |
import org.gvsig.topology.lib.api.TopologyReport; |
|
7 |
import org.gvsig.topology.lib.api.TopologyReportLine; |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
* @author jjdelcerro |
|
12 |
*/ |
|
13 |
class TopologyReportLineSymbolTable extends AbstractSymbolTable { |
|
14 |
|
|
15 |
private TopologyReportLine line = null; |
|
16 |
private final List<String> fieldNames; |
|
17 |
|
|
18 |
public TopologyReportLineSymbolTable() { |
|
19 |
this.fieldNames = new ArrayList<>(); |
|
20 |
this.fieldNames.add(TopologyReport.RULE_ID); |
|
21 |
this.fieldNames.add(TopologyReport.IS_ERROR); |
|
22 |
this.fieldNames.add(TopologyReport.IS_EXCEPTION); |
|
23 |
this.fieldNames.add(TopologyReport.GEOMETRY); |
|
24 |
} |
|
25 |
|
|
26 |
public void setLine(TopologyReportLine line) { |
|
27 |
this.line = line; |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
public boolean exists(String name) { |
|
32 |
if (name == null) { |
|
33 |
return false; |
|
34 |
} |
|
35 |
return this.fieldNames.contains(name.toUpperCase()); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public Object value(String name) { |
|
40 |
switch (name.toUpperCase()) { |
|
41 |
case TopologyReport.RULE_ID: |
|
42 |
return this.line.getRule().getId(); |
|
43 |
case TopologyReport.IS_ERROR: |
|
44 |
return !this.line.isException(); |
|
45 |
case TopologyReport.IS_EXCEPTION: |
|
46 |
return this.line.isException(); |
|
47 |
case TopologyReport.GEOMETRY: |
|
48 |
return this.line.getGeometry(); |
|
49 |
default: |
|
50 |
return null; |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/AbstractTopologyReportLineSet.java | ||
---|---|---|
1 |
package org.gvsig.topology.lib.impl; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collections; |
|
5 |
import java.util.List; |
|
6 |
import javax.swing.event.ChangeListener; |
|
7 |
import org.gvsig.tools.swing.api.ChangeListenerHelper; |
|
8 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
9 |
import org.gvsig.topology.lib.api.TopologyReportLine; |
|
10 |
import org.gvsig.topology.lib.api.TopologyReportLineSet; |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
* @author jjdelcerro |
|
15 |
*/ |
|
16 |
public abstract class AbstractTopologyReportLineSet implements TopologyReportLineSet { |
|
17 |
|
|
18 |
protected final List<TopologyReportLine> lines; |
|
19 |
protected final ChangeListenerHelper changeListenerHelper; |
|
20 |
protected boolean completed = false; |
|
21 |
|
|
22 |
public AbstractTopologyReportLineSet() { |
|
23 |
this.lines = new ArrayList<>(); |
|
24 |
this.changeListenerHelper = ToolsSwingLocator.getToolsSwingManager().createChangeListenerHelper(); |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public List<TopologyReportLine> getLines() { |
|
29 |
return Collections.unmodifiableList(this.lines); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public void addChangeListener(ChangeListener cl) { |
|
34 |
this.changeListenerHelper.addChangeListener(cl); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public ChangeListener[] getChangeListeners() { |
|
39 |
return this.changeListenerHelper.getChangeListeners(); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void removeChangeListener(ChangeListener cl) { |
|
44 |
this.changeListenerHelper.removeChangeListener(cl); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public void removeAllChangeListener() { |
|
49 |
this.changeListenerHelper.removeAllChangeListener(); |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public boolean hasChangeListeners() { |
|
54 |
return this.changeListenerHelper.hasChangeListeners(); |
|
55 |
} |
|
56 |
|
|
57 |
protected void fireChangeEvent() { |
|
58 |
this.changeListenerHelper.fireEvent(); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public boolean isComplete() { |
|
63 |
return this.completed; |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public int size() { |
|
68 |
return this.lines.size(); |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public TopologyReportLine get(int index) { |
|
73 |
return this.lines.get(index); |
|
74 |
} |
|
75 |
|
|
76 |
public void setCompleted(boolean completed) { |
|
77 |
this.completed = completed; |
|
78 |
} |
|
79 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/TopologyImplLibrary.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.lib.impl; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.DALLibrary; |
|
27 |
import org.gvsig.fmap.geom.GeometryLibrary; |
|
28 |
import org.gvsig.tools.ToolsLibrary; |
|
29 |
import org.gvsig.tools.library.AbstractLibrary; |
|
30 |
import org.gvsig.tools.library.LibraryException; |
|
31 |
import org.gvsig.topology.lib.api.TopologyLibrary; |
|
32 |
import org.gvsig.topology.lib.api.TopologyLocator; |
|
33 |
import org.gvsig.topology.lib.api.TopologyManager; |
|
34 |
import org.gvsig.topology.rule.ContainsNullRuleFactory; |
|
35 |
import org.gvsig.topology.rule.ContainsPointRuleFactory; |
|
36 |
import org.gvsig.topology.rule.MustBeLargerThanToleranceLineRuleFactory; |
|
37 |
import org.gvsig.topology.rule.MustNotOverlapPolygonRuleFactory; |
|
38 |
import org.gvsig.topology.rule.PointMustBeProperlyInsidePolygonRuleFactory; |
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
* @author jjdelcerro |
|
43 |
*/ |
|
44 |
public class TopologyImplLibrary extends AbstractLibrary { |
|
45 |
|
|
46 |
@Override |
|
47 |
public void doRegistration() { |
|
48 |
super.doRegistration(); |
|
49 |
registerAsImplementationOf(TopologyLibrary.class); |
|
50 |
this.require(ToolsLibrary.class); |
|
51 |
this.require(DALLibrary.class); |
|
52 |
this.require(GeometryLibrary.class); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
protected void doInitialize() throws LibraryException { |
|
57 |
TopologyLocator.registerDefaultTopologyManager(DefaultTopologyManager.class); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
protected void doPostInitialize() throws LibraryException { |
|
62 |
ContainsNullRuleFactory.selfRegister(); |
|
63 |
ContainsPointRuleFactory.selfRegister(); |
|
64 |
MustBeLargerThanToleranceLineRuleFactory.selfRegister(); |
|
65 |
MustNotOverlapPolygonRuleFactory.selfRegister(); |
|
66 |
PointMustBeProperlyInsidePolygonRuleFactory.selfRegister(); |
|
67 |
} |
|
68 |
|
|
69 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyReportLine.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.lib.impl; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
27 |
import org.gvsig.fmap.geom.Geometry; |
|
28 |
import org.gvsig.topology.lib.api.TopologyDataSet; |
|
29 |
import org.gvsig.topology.lib.api.TopologyReport; |
|
30 |
import org.gvsig.topology.lib.api.TopologyReportLine; |
|
31 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
* @author jjdelcerro |
|
36 |
*/ |
|
37 |
public class DefaultTopologyReportLine implements TopologyReportLine { |
|
38 |
|
|
39 |
private final TopologyReport report; |
|
40 |
private final TopologyRule rule; |
|
41 |
private final TopologyDataSet dataSet1; |
|
42 |
private final TopologyDataSet dataSet2; |
|
43 |
private final Geometry geometry; |
|
44 |
private final FeatureReference feature1; |
|
45 |
private final FeatureReference feature2; |
|
46 |
private final int primitive1; |
|
47 |
private final int primitive2; |
|
48 |
private boolean exception; |
|
49 |
private final String description; |
|
50 |
private final String data; |
|
51 |
private final Geometry errorGeometry; |
|
52 |
|
|
53 |
DefaultTopologyReportLine(DefaultTopologyReport report, |
|
54 |
TopologyRule rule, |
|
55 |
TopologyDataSet dataSet1, |
|
56 |
TopologyDataSet dataSet2, |
|
57 |
Geometry geometry, |
|
58 |
Geometry error, |
|
59 |
FeatureReference feature1, |
|
60 |
FeatureReference feature2, |
|
61 |
int primitive1, |
|
62 |
int primitive2, |
|
63 |
boolean exception, |
|
64 |
String description, |
|
65 |
String data |
|
66 |
) { |
|
67 |
this.report = report; |
|
68 |
this.rule = rule; |
|
69 |
this.dataSet1 = dataSet1; |
|
70 |
this.dataSet2 = dataSet2; |
|
71 |
this.geometry = geometry; |
|
72 |
this.feature1 = feature1; |
|
73 |
this.feature2 = feature2; |
|
74 |
this.primitive1 = primitive1; |
|
75 |
this.primitive2 = primitive2; |
|
76 |
this.exception = exception; |
|
77 |
this.description = description; |
|
78 |
this.errorGeometry = error; |
|
79 |
this.data = data; |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public TopologyRule getRule() { |
|
84 |
return this.rule; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public TopologyDataSet getDataSet1() { |
|
89 |
return this.dataSet1; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public TopologyDataSet getDataSet2() { |
|
94 |
return this.dataSet2; |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public Geometry getGeometry() { |
|
99 |
return this.geometry; |
|
100 |
} |
|
101 |
|
|
102 |
@Override |
|
103 |
public FeatureReference getFeature1() { |
|
104 |
return this.feature1; |
|
105 |
} |
|
106 |
|
|
107 |
@Override |
|
108 |
public FeatureReference getFeature2() { |
|
109 |
return this.feature2; |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public boolean isException() { |
|
114 |
return this.exception; |
|
115 |
} |
|
116 |
|
|
117 |
public void setException(boolean exception) { |
|
118 |
this.exception = exception; |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
122 |
public String getDescription() { |
|
123 |
return description; |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public Geometry getError() { |
|
128 |
return this.errorGeometry; |
|
129 |
} |
|
130 |
|
|
131 |
@Override |
|
132 |
public int getPrimitiveNumber1() { |
|
133 |
return this.primitive1; |
|
134 |
} |
|
135 |
|
|
136 |
@Override |
|
137 |
public int getPrimitiveNumber2() { |
|
138 |
return this.primitive2; |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public String getData() { |
|
143 |
return this.data; |
|
144 |
} |
|
145 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.54/org.gvsig.topology.lib/org.gvsig.topology.lib.impl/src/main/java/org/gvsig/topology/lib/impl/DefaultTopologyDataSet.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.lib.impl; |
|
25 |
|
|
26 |
import java.util.Iterator; |
|
27 |
import java.util.Map; |
|
28 |
import org.apache.commons.collections.IteratorUtils; |
|
29 |
import org.apache.commons.lang3.StringUtils; |
|
30 |
import org.apache.commons.lang3.mutable.MutableObject; |
|
31 |
import org.gvsig.expressionevaluator.Expression; |
|
32 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
33 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
|
34 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
|
35 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
36 |
import org.gvsig.expressionevaluator.GeometryExpressionBuilder; |
|
37 |
import org.gvsig.expressionevaluator.GeometryExpressionUtils; |
|
38 |
import org.gvsig.fmap.dal.DataStore; |
|
39 |
import org.gvsig.fmap.dal.EditingNotification; |
|
40 |
import org.gvsig.fmap.dal.EditingNotificationManager; |
|
41 |
import org.gvsig.fmap.dal.exception.DataException; |
|
42 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
43 |
import org.gvsig.fmap.dal.feature.Feature; |
|
44 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
45 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
46 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
47 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
48 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
|
49 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
50 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
51 |
import org.gvsig.fmap.geom.Geometry; |
|
52 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
53 |
import org.gvsig.fmap.geom.GeometryManager; |
|
54 |
import org.gvsig.fmap.geom.GeometryUtils; |
|
55 |
import org.gvsig.fmap.geom.SpatialIndex; |
|
56 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
57 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
58 |
import org.gvsig.tools.exception.BaseException; |
|
59 |
import org.gvsig.tools.util.PropertiesSupportHelper; |
|
60 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
61 |
import org.gvsig.tools.visitor.Visitor; |
|
62 |
import org.gvsig.topology.lib.api.CancelOperationException; |
|
63 |
import org.gvsig.topology.lib.api.PerformOperationException; |
|
64 |
import org.gvsig.topology.lib.api.TopologyDataSet; |
|
65 |
import org.gvsig.topology.lib.api.TopologyLocator; |
|
66 |
import org.gvsig.topology.lib.api.TopologyManager; |
|
67 |
import org.json.JSONObject; |
|
68 |
import org.gvsig.topology.lib.api.TopologyServices; |
|
69 |
import org.slf4j.Logger; |
|
70 |
import org.slf4j.LoggerFactory; |
|
71 |
|
|
72 |
/** |
|
73 |
* |
|
74 |
* @author jjdelcerro |
|
75 |
*/ |
|
76 |
@SuppressWarnings({"EqualsAndHashcode","UseSpecificCatch"}) |
|
77 |
public class DefaultTopologyDataSet implements TopologyDataSet { |
|
78 |
|
|
79 |
private final static Logger LOGGER = LoggerFactory.getLogger(DefaultTopologyDataSet.class); |
|
80 |
|
|
81 |
private TopologyServices services; |
|
82 |
private String name; |
|
83 |
private DataStore store; |
|
84 |
private boolean needFinishEditing; |
|
85 |
private String fullName; |
|
86 |
private PropertiesSupportHelper propertiesHelper; |
|
87 |
private MutableObject<SpatialIndex> spatialIndex = null; |
|
88 |
|
|
89 |
public DefaultTopologyDataSet() { |
|
90 |
this.services = null; |
|
91 |
this.name = null; |
|
92 |
this.store = null; |
|
93 |
this.needFinishEditing = false; |
|
94 |
this.fullName = null; |
|
95 |
this.propertiesHelper = new PropertiesSupportHelper(); |
|
96 |
} |
|
97 |
|
|
98 |
public DefaultTopologyDataSet(TopologyServices services, String name, DataStore store) { |
|
99 |
this.services = services; |
|
100 |
this.name = name; |
|
101 |
this.store = store; |
|
102 |
this.needFinishEditing = false; |
|
103 |
if( store!=null ) { |
|
104 |
this.fullName = store.getFullName(); |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
@Override |
|
109 |
public void restart() { |
|
110 |
this.store = null; |
|
111 |
this.spatialIndex = null; |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public boolean equals(Object obj) { |
|
116 |
if( !(obj instanceof DefaultTopologyDataSet) ) { |
|
117 |
return false; |
|
118 |
} |
|
119 |
DefaultTopologyDataSet other = (DefaultTopologyDataSet)obj; |
|
120 |
if( this.store != other.store ) { |
|
121 |
return false; |
|
122 |
} |
|
123 |
if( !StringUtils.equals(this.getName(), other.getName()) ) { |
|
124 |
return false; |
|
125 |
} |
|
126 |
return true; |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public String getName() { |
|
131 |
return this.name; |
|
132 |
} |
|
133 |
|
|
134 |
@Override |
|
135 |
public void setName(String name) { |
|
136 |
this.name = name; |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public String toString() { |
|
141 |
try { |
|
142 |
FeatureAttributeDescriptor attr = this.getFeatureStore().getDefaultFeatureType().getDefaultGeometryAttribute(); |
|
143 |
String geomType = attr.getGeomType().getName(); |
|
144 |
return this.name + " ("+ geomType + ")"; |
|
145 |
} catch(Exception ex) { |
|
146 |
return this.name ; |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
@Override |
|
151 |
public DataStore getStore() { |
|
152 |
if (this.store == null) { |
|
153 |
this.store = this.services.getFeatureStore(this); |
|
154 |
} |
|
155 |
return this.store; |
|
156 |
} |
|
157 |
|
|
158 |
@Override |
|
159 |
public FeatureStore getFeatureStore() { |
|
160 |
if (this.store == null) { |
|
161 |
this.store = this.services.getFeatureStore(this); |
Also available in: Unified diff