Revision 18995
trunk/libraries/libTopology/src/org/gvsig/topology/ITopologyErrorContainer.java | ||
---|---|---|
168 | 168 |
public XMLEntity getXMLEntity() throws XMLException; |
169 | 169 |
|
170 | 170 |
public Object clone(); |
171 |
|
|
172 |
|
|
173 |
public FLyrVect getAsFMapLayer(String name, IProjection projection); |
|
174 |
|
|
175 |
public void setTopology(Topology topology); |
|
176 |
|
|
177 |
public Topology getTopology(); |
|
171 | 178 |
} |
172 | 179 |
|
trunk/libraries/libTopology/src/org/gvsig/topology/SimpleTopologyErrorContainer.java | ||
---|---|---|
48 | 48 |
*/ |
49 | 49 |
package org.gvsig.topology; |
50 | 50 |
|
51 |
import java.awt.Color; |
|
52 |
import java.sql.Types; |
|
51 | 53 |
import java.util.ArrayList; |
52 | 54 |
import java.util.Iterator; |
53 | 55 |
import java.util.List; |
56 |
import java.util.Random; |
|
54 | 57 |
|
55 | 58 |
import org.cresques.cts.ICoordTrans; |
56 | 59 |
import org.cresques.cts.IProjection; |
57 | 60 |
|
61 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
62 |
import com.iver.cit.gvsig.drivers.TopologyErrorMemoryDriver; |
|
63 |
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException; |
|
64 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
65 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
|
66 |
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol; |
|
67 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
|
68 |
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
|
69 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
70 |
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial; |
|
58 | 71 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
72 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
|
73 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
|
59 | 74 |
import com.iver.utiles.XMLEntity; |
60 | 75 |
|
61 | 76 |
/** |
... | ... | |
73 | 88 |
|
74 | 89 |
private List<TopologyError> topologyErrors; |
75 | 90 |
|
91 |
private Topology topology; |
|
92 |
|
|
76 | 93 |
/** |
77 | 94 |
* Number of errors that has been marked as exceptions |
78 | 95 |
*/ |
... | ... | |
83 | 100 |
topologyErrors = new ArrayList<TopologyError>(); |
84 | 101 |
} |
85 | 102 |
|
103 |
public void setTopology(Topology topology){ |
|
104 |
this.topology = topology; |
|
105 |
} |
|
106 |
|
|
107 |
public Topology getTopology(){ |
|
108 |
return this.topology; |
|
109 |
} |
|
110 |
|
|
86 | 111 |
public Object clone(){ |
87 | 112 |
SimpleTopologyErrorContainer newContainer = new SimpleTopologyErrorContainer(); |
88 | 113 |
for(int i = 0; i < topologyErrors.size(); i++){ |
89 | 114 |
newContainer.addTopologyError(topologyErrors.get(i)); |
90 | 115 |
} |
116 |
newContainer.setTopology(this.topology); |
|
91 | 117 |
return newContainer; |
92 | 118 |
} |
93 | 119 |
|
... | ... | |
347 | 373 |
int numberOfErrors = xml.getIntProperty("numberOfErrors"); |
348 | 374 |
for(int i = 0; i < numberOfErrors; i++){ |
349 | 375 |
XMLEntity errorXML = xml.getChild(i); |
350 |
TopologyError error = new TopologyError(); |
|
376 |
TopologyError error = new TopologyError(topology);
|
|
351 | 377 |
error.setXMLEntity(errorXML); |
352 | 378 |
topologyErrors.add(error); |
353 | 379 |
}//for |
... | ... | |
381 | 407 |
} |
382 | 408 |
} |
383 | 409 |
} |
410 |
|
|
411 |
|
|
412 |
private Color getRandomColor(){ |
|
413 |
//This code is copied from LegendFactory |
|
414 |
Random rand = new Random(); |
|
415 |
int numreg = rand.nextInt(255/2); |
|
416 |
double div = (1-rand.nextDouble()*0.66)*0.9; |
|
417 |
return new Color( |
|
418 |
((int) (255*div + (numreg * rand.nextDouble()))) % 255, |
|
419 |
((int) (255*div + (numreg * rand.nextDouble()))) % 255, |
|
420 |
((int) (255*div + (numreg * rand.nextDouble()))) % 255); |
|
421 |
} |
|
422 |
|
|
423 |
/** |
|
424 |
* Returns a representation of the topology errors contained in as a fmap |
|
425 |
* layer. |
|
426 |
* |
|
427 |
* @param name name of the layer |
|
428 |
* @projection projection of the layer |
|
429 |
*/ |
|
430 |
public FLyrVect getAsFMapLayer(String name, IProjection projection) { |
|
431 |
FLayerGenericVectorial solution = new |
|
432 |
FLayerGenericVectorial(); |
|
433 |
solution.setName(name); |
|
434 |
solution.setProjection(projection); |
|
435 |
solution.setDriver(new TopologyErrorMemoryDriver(name, this)); |
|
436 |
try { |
|
437 |
solution.load(); |
|
438 |
VectorialUniqueValueLegend defaultLegend = |
|
439 |
LegendFactory.createVectorialUniqueValueLegend(FShape.MULTI); |
|
440 |
defaultLegend.setClassifyingFieldNames(new String[] {TopologyErrorMemoryDriver.LEGEND_FIELD}); |
|
441 |
defaultLegend.setClassifyingFieldTypes(new int[]{Types.VARCHAR}); |
|
442 |
defaultLegend.setDefaultSymbol(SymbologyFactory. |
|
443 |
createDefaultSymbolByShapeType(FShape.MULTI, Color.BLACK)); |
|
444 |
|
|
445 |
List<ITopologyRule> rules = topology.getAllRules(); |
|
446 |
|
|
447 |
//Now we are going to set a symbol for each kind of topology rule |
|
448 |
ISymbol theSymbol = null; |
|
449 |
Color c = null; |
|
450 |
|
|
451 |
for(int i = 0; i < rules.size(); i++){ |
|
452 |
ITopologyRule rule = rules.get(i); |
|
453 |
c = getRandomColor(); |
|
454 |
theSymbol = SymbologyFactory. |
|
455 |
createDefaultSymbolByShapeType(FShape.MULTI, c); |
|
456 |
theSymbol.setDescription(rule.getName()); |
|
457 |
|
|
458 |
if (theSymbol instanceof IMarkerSymbol) { |
|
459 |
((IMarkerSymbol) theSymbol).setSize(1); |
|
460 |
} |
|
461 |
|
|
462 |
if (theSymbol instanceof ILineSymbol) { |
|
463 |
((ILineSymbol) theSymbol).setLineWidth(1); |
|
464 |
} |
|
465 |
|
|
466 |
if (theSymbol instanceof IFillSymbol) { |
|
467 |
((IFillSymbol) theSymbol).getOutline().setLineColor(c); |
|
468 |
((IFillSymbol) theSymbol).getOutline().setLineWidth(1); |
|
469 |
((IFillSymbol) theSymbol).setFillColor(c); |
|
470 |
} |
|
471 |
|
|
472 |
defaultLegend.addSymbol(ValueFactory.createValue(rule.getName()), theSymbol); |
|
473 |
}//for |
|
474 |
|
|
475 |
solution.setLegend(defaultLegend); |
|
476 |
|
|
477 |
} catch (LoadLayerException e) { |
|
478 |
e.printStackTrace(); |
|
479 |
} |
|
480 |
|
|
481 |
|
|
482 |
return solution; |
|
483 |
} |
|
484 |
|
|
384 | 485 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/MustNotHaveRepeatedPoints.java | ||
---|---|---|
137 | 137 |
y[count] = coord.y; |
138 | 138 |
count++; |
139 | 139 |
} |
140 |
FMultiPoint2D multiPoint = new FMultiPoint2D(x, y); |
|
141 |
|
|
140 |
|
|
141 |
// FMultiPoint2D multiPoint = new FMultiPoint2D(x, y); |
|
142 |
//FIXME URGENTE, PASAR A MULTIPOINT CUANDO SE IMPLEMENTEN LOS METODOS DE DIBUJO. |
|
143 |
com.iver.cit.gvsig.fmap.core.FPoint2D point = new com.iver.cit.gvsig.fmap.core.FPoint2D(x[0], y[0]); |
|
144 |
com.iver.cit.gvsig.fmap.core.FGeometry multiPoint = com.iver.cit.gvsig.fmap.core.ShapeFactory.createGeometry(point); |
|
142 | 145 |
//FIXME Create a TopologyErrorFactory |
143 | 146 |
TopologyError topologyError = |
144 | 147 |
new TopologyError(multiPoint, |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/GeometryMustHaveValidCoordinates.java | ||
---|---|---|
55 | 55 |
import org.gvsig.topology.Topology; |
56 | 56 |
import org.gvsig.topology.TopologyError; |
57 | 57 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
58 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
58 | 59 |
|
59 | 60 |
import com.iver.cit.gvsig.fmap.core.Handler; |
60 | 61 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
... | ... | |
68 | 69 |
* |
69 | 70 |
*/ |
70 | 71 |
public class GeometryMustHaveValidCoordinates extends AbstractTopologyRule{ |
72 |
|
|
73 |
private JtsValidRule parentRule; |
|
74 |
|
|
75 |
|
|
71 | 76 |
/** |
72 | 77 |
* Constructor |
73 | 78 |
* @param topology |
... | ... | |
97 | 102 |
Point2D pt = handlers[i].getPoint(); |
98 | 103 |
if(! isValid(pt)){ |
99 | 104 |
IGeometry fgeo = feature.getGeometry(); |
100 |
TopologyError topologyError = |
|
101 |
new TopologyError(fgeo, this, feature, topology); |
|
105 |
AbstractTopologyRule violatedRule = null; |
|
106 |
if(this.parentRule != null) |
|
107 |
violatedRule = parentRule; |
|
108 |
else |
|
109 |
violatedRule = this; |
|
110 |
TopologyError topologyError = |
|
111 |
new TopologyError(fgeo, violatedRule, feature, topology); |
|
112 |
|
|
102 | 113 |
errorContainer.addTopologyError(topologyError); |
103 | 114 |
} |
104 | 115 |
}//for |
... | ... | |
111 | 122 |
if (Double.isInfinite(coord.getY())) return false; |
112 | 123 |
return true; |
113 | 124 |
} |
125 |
|
|
126 |
public JtsValidRule getParentRule() { |
|
127 |
return parentRule; |
|
128 |
} |
|
129 |
|
|
130 |
public void setParentRule(JtsValidRule parentRule) { |
|
131 |
this.parentRule = parentRule; |
|
132 |
} |
|
114 | 133 |
} |
115 | 134 |
|
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/PolygonMustHaveConnectedInterior.java | ||
---|---|---|
56 | 56 |
import org.gvsig.topology.TopologyError; |
57 | 57 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
58 | 58 |
import org.gvsig.topology.WrongLyrForTopologyException; |
59 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
59 | 60 |
|
60 | 61 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
61 | 62 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
... | ... | |
85 | 86 |
*/ |
86 | 87 |
public class PolygonMustHaveConnectedInterior extends AbstractTopologyRule { |
87 | 88 |
|
89 |
JtsValidRule parentRule; |
|
90 |
|
|
88 | 91 |
public PolygonMustHaveConnectedInterior(Topology topology, |
89 | 92 |
FLyrVect originLyr) { |
90 | 93 |
super(topology, originLyr); |
... | ... | |
145 | 148 |
Coordinate coord = cit.getCoordinate(); |
146 | 149 |
FPoint2D pt = new FPoint2D(coord.x, coord.y); |
147 | 150 |
IGeometry geometry = ShapeFactory.createGeometry(pt); |
151 |
AbstractTopologyRule violatedRule = null; |
|
152 |
if(this.parentRule != null) |
|
153 |
violatedRule = parentRule; |
|
154 |
else |
|
155 |
violatedRule = this; |
|
148 | 156 |
TopologyError error = |
149 |
new TopologyError(geometry, this, feature, topology);
|
|
157 |
new TopologyError(geometry, violatedRule, feature, topology);
|
|
150 | 158 |
addTopologyError(error); |
151 | 159 |
} |
152 | 160 |
}catch(TopologyException e){ |
153 | 161 |
//In unit tests JTS has throwed this exception POLYGON ((440 260, 500 300, 660 300, 600 200, 440 260, 440 260), (440 260, 600 200, 660 300, 500 300, 440 260)) |
154 | 162 |
e.printStackTrace(); |
163 |
AbstractTopologyRule violatedRule = null; |
|
164 |
if(this.parentRule != null) |
|
165 |
violatedRule = parentRule; |
|
166 |
else |
|
167 |
violatedRule = this; |
|
155 | 168 |
TopologyError error = |
156 |
new TopologyError(feature.getGeometry(), this, feature, topology);
|
|
169 |
new TopologyError(feature.getGeometry(), violatedRule, feature, topology);
|
|
157 | 170 |
addTopologyError(error); |
158 | 171 |
|
159 | 172 |
} |
160 | 173 |
} |
174 |
|
|
175 |
public JtsValidRule getParentRule() { |
|
176 |
return parentRule; |
|
177 |
} |
|
178 |
|
|
179 |
public void setParentRule(JtsValidRule parentRule) { |
|
180 |
this.parentRule = parentRule; |
|
181 |
} |
|
161 | 182 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/PolygonHolesMustNotBeNested.java | ||
---|---|---|
60 | 60 |
import org.gvsig.topology.Topology; |
61 | 61 |
import org.gvsig.topology.TopologyError; |
62 | 62 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
63 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
63 | 64 |
|
64 | 65 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
65 | 66 |
import com.iver.cit.gvsig.fmap.core.FShape; |
... | ... | |
78 | 79 |
|
79 | 80 |
public class PolygonHolesMustNotBeNested extends AbstractTopologyRule { |
80 | 81 |
|
82 |
private JtsValidRule parentRule; |
|
83 |
|
|
81 | 84 |
public PolygonHolesMustNotBeNested(FLyrVect originLyr){ |
82 | 85 |
super(originLyr); |
83 | 86 |
} |
... | ... | |
233 | 236 |
|
234 | 237 |
|
235 | 238 |
private void addError(IGeometry geo, IFeature feature){ |
239 |
AbstractTopologyRule violatedRule = null; |
|
240 |
if(this.parentRule != null) |
|
241 |
violatedRule = parentRule; |
|
242 |
else |
|
243 |
violatedRule = this; |
|
236 | 244 |
TopologyError error = |
237 |
new TopologyError(geo, this, feature, topology);
|
|
245 |
new TopologyError(geo, violatedRule, feature, topology);
|
|
238 | 246 |
addTopologyError(error); |
239 | 247 |
} |
248 |
|
|
249 |
public JtsValidRule getParentRule() { |
|
250 |
return parentRule; |
|
251 |
} |
|
252 |
|
|
253 |
public void setParentRule(JtsValidRule parentRule) { |
|
254 |
this.parentRule = parentRule; |
|
255 |
} |
|
240 | 256 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/PolygonMustNotHaveDuplicatedRings.java | ||
---|---|---|
55 | 55 |
import org.gvsig.topology.Topology; |
56 | 56 |
import org.gvsig.topology.TopologyError; |
57 | 57 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
58 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
58 | 59 |
|
59 | 60 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
60 | 61 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
... | ... | |
77 | 78 |
public class PolygonMustNotHaveDuplicatedRings extends AbstractTopologyRule { |
78 | 79 |
|
79 | 80 |
private double snapTolerance; |
81 |
|
|
82 |
private JtsValidRule parentRule; |
|
80 | 83 |
|
81 | 84 |
public PolygonMustNotHaveDuplicatedRings(Topology topology, FLyrVect lyr, double tolerance){ |
82 | 85 |
super(topology, lyr); |
... | ... | |
133 | 136 |
LineString hole = polygon.getInteriorRingN(i); |
134 | 137 |
if(shell.equalsExact(hole, snapTolerance)){ |
135 | 138 |
IGeometry geometry = FConverter.jts_to_igeometry(hole); |
139 |
AbstractTopologyRule violatedRule = null; |
|
140 |
if(this.parentRule != null) |
|
141 |
violatedRule = parentRule; |
|
142 |
else |
|
143 |
violatedRule = this; |
|
136 | 144 |
TopologyError error = new TopologyError(geometry, |
137 |
this,
|
|
145 |
violatedRule,
|
|
138 | 146 |
feature, |
139 | 147 |
topology); |
140 | 148 |
addTopologyError(error); |
... | ... | |
147 | 155 |
LineString hole2 = polygon.getInteriorRingN(j); |
148 | 156 |
if(hole.equalsExact(hole2)){ |
149 | 157 |
IGeometry geometry = FConverter.jts_to_igeometry(hole); |
158 |
AbstractTopologyRule violatedRule = null; |
|
159 |
if(this.parentRule != null) |
|
160 |
violatedRule = parentRule; |
|
161 |
else |
|
162 |
violatedRule = this; |
|
150 | 163 |
TopologyError error = new TopologyError(geometry, |
151 |
this,
|
|
164 |
violatedRule,
|
|
152 | 165 |
feature, |
153 | 166 |
topology); |
154 | 167 |
addTopologyError(error); |
... | ... | |
170 | 183 |
snapTolerance = xml.getDoubleProperty("snapTolerance"); |
171 | 184 |
} |
172 | 185 |
} |
186 |
|
|
187 |
public JtsValidRule getParentRule() { |
|
188 |
return parentRule; |
|
189 |
} |
|
190 |
|
|
191 |
public void setParentRule(JtsValidRule parentRule) { |
|
192 |
this.parentRule = parentRule; |
|
193 |
} |
|
173 | 194 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/GeometryMustNotHaveFewPoints.java | ||
---|---|---|
53 | 53 |
import org.gvsig.topology.Topology; |
54 | 54 |
import org.gvsig.topology.TopologyError; |
55 | 55 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
56 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
56 | 57 |
|
57 | 58 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
58 | 59 |
import com.iver.cit.gvsig.fmap.core.FShape; |
... | ... | |
76 | 77 |
*/ |
77 | 78 |
public class GeometryMustNotHaveFewPoints extends AbstractTopologyRule{ |
78 | 79 |
|
80 |
private JtsValidRule parentRule; |
|
79 | 81 |
|
82 |
|
|
83 |
public JtsValidRule getParentRule() { |
|
84 |
return parentRule; |
|
85 |
} |
|
86 |
|
|
87 |
public void setParentRule(JtsValidRule parentRule) { |
|
88 |
this.parentRule = parentRule; |
|
89 |
} |
|
90 |
|
|
80 | 91 |
public GeometryMustNotHaveFewPoints(FLyrVect originLyr) { |
81 | 92 |
super(originLyr); |
82 | 93 |
} |
... | ... | |
114 | 125 |
return; |
115 | 126 |
GeometryGraph graph = new GeometryGraph(0, jtsGeo ); |
116 | 127 |
if (graph.hasTooFewPoints()) {//TODO JTS NO CONTEMPLA CURVAS....VER SI ES MEJOR DEFINIR ESTO CON FMAP |
117 |
TopologyError error = new TopologyError(geometry, this, feature, topology ); |
|
128 |
AbstractTopologyRule violatedRule = null; |
|
129 |
if(this.parentRule != null) |
|
130 |
violatedRule = parentRule; |
|
131 |
else |
|
132 |
violatedRule = this; |
|
133 |
TopologyError error = new TopologyError(geometry, violatedRule, feature, topology ); |
|
118 | 134 |
this.errorContainer.addTopologyError(error); |
119 | 135 |
}//if |
120 | 136 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/PolygonMustNotHaveSelfIntersectedRings.java | ||
---|---|---|
57 | 57 |
import org.gvsig.topology.TopologyError; |
58 | 58 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
59 | 59 |
import org.gvsig.topology.WrongLyrForTopologyException; |
60 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
60 | 61 |
|
61 | 62 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
62 | 63 |
import com.iver.cit.gvsig.fmap.core.FMultiPoint2D; |
... | ... | |
74 | 75 |
|
75 | 76 |
private double snapTolerance; |
76 | 77 |
|
78 |
private JtsValidRule parentRule; |
|
79 |
|
|
77 | 80 |
public PolygonMustNotHaveSelfIntersectedRings(Topology topology, FLyrVect lyr, double snapTolerance){ |
78 | 81 |
super(topology, lyr); |
79 | 82 |
this.snapTolerance = snapTolerance; |
... | ... | |
151 | 154 |
x[i] = selfIntersections[i].x; |
152 | 155 |
y[i] = selfIntersections[i].y; |
153 | 156 |
} |
154 |
FMultiPoint2D errorGeo = new FMultiPoint2D(x, y); |
|
155 |
TopologyError error = new TopologyError(errorGeo, this, feature, topology ); |
|
157 |
// FMultiPoint2D errorGeo = new FMultiPoint2D(x, y); |
|
158 |
|
|
159 |
//FIXME USAR MULTIPOINT CUANDO FUNCIONE |
|
160 |
com.iver.cit.gvsig.fmap.core.FPoint2D point = |
|
161 |
new com.iver.cit.gvsig.fmap.core.FPoint2D(x[0], y[0]); |
|
162 |
com.iver.cit.gvsig.fmap.core.IGeometry errorGeo = com.iver.cit.gvsig.fmap.core.ShapeFactory.createGeometry(point); |
|
163 |
|
|
164 |
AbstractTopologyRule violatedRule = null; |
|
165 |
if(this.parentRule != null) |
|
166 |
violatedRule = parentRule; |
|
167 |
else |
|
168 |
violatedRule = this; |
|
169 |
TopologyError error = new TopologyError(errorGeo, violatedRule, feature, topology ); |
|
156 | 170 |
addTopologyError(error); |
157 | 171 |
} |
158 | 172 |
|
... | ... | |
169 | 183 |
snapTolerance = xml.getDoubleProperty("snapTolerance"); |
170 | 184 |
} |
171 | 185 |
} |
186 |
|
|
187 |
public JtsValidRule getParentRule() { |
|
188 |
return parentRule; |
|
189 |
} |
|
190 |
|
|
191 |
public void setParentRule(JtsValidRule parentRule) { |
|
192 |
this.parentRule = parentRule; |
|
193 |
} |
|
172 | 194 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/IGeometryMustBeClosed.java | ||
---|---|---|
54 | 54 |
import org.gvsig.topology.Topology; |
55 | 55 |
import org.gvsig.topology.TopologyError; |
56 | 56 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
57 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
57 | 58 |
|
58 | 59 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
59 | 60 |
import com.iver.cit.gvsig.fmap.core.FShape; |
... | ... | |
79 | 80 |
|
80 | 81 |
private double snapTolerance; |
81 | 82 |
|
83 |
private JtsValidRule parentRule; |
|
84 |
|
|
82 | 85 |
public IGeometryMustBeClosed(Topology topology, FLyrVect originLyr, double snapTolerance) { |
83 | 86 |
super(topology, originLyr); |
84 | 87 |
this.snapTolerance = snapTolerance; |
... | ... | |
118 | 121 |
|
119 | 122 |
|
120 | 123 |
private void addTopologyError(IFeature errorFeature, IGeometry errorGeometry) { |
124 |
AbstractTopologyRule violatedRule = null; |
|
125 |
if(this.parentRule != null) |
|
126 |
violatedRule = parentRule; |
|
127 |
else |
|
128 |
violatedRule = this; |
|
121 | 129 |
TopologyError error = |
122 |
new TopologyError(errorGeometry, this, errorFeature, topology);
|
|
130 |
new TopologyError(errorGeometry, violatedRule, errorFeature, topology);
|
|
123 | 131 |
addTopologyError(error); |
124 | 132 |
} |
125 | 133 |
|
... | ... | |
137 | 145 |
} |
138 | 146 |
} |
139 | 147 |
|
148 |
public JtsValidRule getParentRule() { |
|
149 |
return parentRule; |
|
150 |
} |
|
151 |
|
|
152 |
public void setParentRule(JtsValidRule parentRule) { |
|
153 |
this.parentRule = parentRule; |
|
154 |
} |
|
155 |
|
|
140 | 156 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/MultiPolygonMustNotHaveNestedShells.java | ||
---|---|---|
54 | 54 |
import org.gvsig.topology.Topology; |
55 | 55 |
import org.gvsig.topology.TopologyError; |
56 | 56 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
57 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
57 | 58 |
|
58 | 59 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
59 | 60 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
... | ... | |
73 | 74 |
|
74 | 75 |
public class MultiPolygonMustNotHaveNestedShells extends AbstractTopologyRule { |
75 | 76 |
|
77 |
JtsValidRule parentRule; |
|
78 |
|
|
79 |
public JtsValidRule getParentRule() { |
|
80 |
return parentRule; |
|
81 |
} |
|
82 |
|
|
83 |
public void setParentRule(JtsValidRule parentRule) { |
|
84 |
this.parentRule = parentRule; |
|
85 |
} |
|
86 |
|
|
76 | 87 |
public MultiPolygonMustNotHaveNestedShells(Topology topology, |
77 | 88 |
FLyrVect originLyr) { |
78 | 89 |
super(topology, originLyr); |
... | ... | |
144 | 155 |
if (p.getNumInteriorRing() <= 0) { |
145 | 156 |
FPoint2D point = new FPoint2D(shellPt.x, shellPt.y); |
146 | 157 |
IGeometry errorGeometry = ShapeFactory.createGeometry(point); |
158 |
AbstractTopologyRule violatedRule = null; |
|
159 |
if(this.parentRule != null) |
|
160 |
violatedRule = parentRule; |
|
161 |
else |
|
162 |
violatedRule = this; |
|
147 | 163 |
TopologyError topologyError = |
148 |
new TopologyError(errorGeometry,this, feature, topology);
|
|
164 |
new TopologyError(errorGeometry,violatedRule, feature, topology);
|
|
149 | 165 |
addTopologyError(topologyError); |
150 | 166 |
} |
151 | 167 |
|
... | ... | |
164 | 180 |
} |
165 | 181 |
FPoint2D point = new FPoint2D(badNestedPt.x, badNestedPt.y); |
166 | 182 |
IGeometry errorGeometry = ShapeFactory.createGeometry(point); |
183 |
AbstractTopologyRule violatedRule = null; |
|
184 |
if(this.parentRule != null) |
|
185 |
violatedRule = parentRule; |
|
186 |
else |
|
187 |
violatedRule = this; |
|
167 | 188 |
TopologyError error = |
168 |
new TopologyError(errorGeometry, this, feature, topology);
|
|
189 |
new TopologyError(errorGeometry, violatedRule, feature, topology);
|
|
169 | 190 |
addTopologyError(error); |
170 | 191 |
} |
171 | 192 |
|
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/PolygonMustNotHaveHoles.java | ||
---|---|---|
56 | 56 |
import org.gvsig.topology.TopologyError; |
57 | 57 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
58 | 58 |
import org.gvsig.topology.WrongLyrForTopologyException; |
59 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
59 | 60 |
|
60 | 61 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
61 | 62 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
... | ... | |
67 | 68 |
|
68 | 69 |
public class PolygonMustNotHaveHoles extends AbstractTopologyRule { |
69 | 70 |
|
71 |
JtsValidRule parentRule; |
|
72 |
|
|
70 | 73 |
public PolygonMustNotHaveHoles(Topology topology, FLyrVect lyr) { |
71 | 74 |
super(topology, lyr); |
72 | 75 |
} |
... | ... | |
123 | 126 |
} |
124 | 127 |
|
125 | 128 |
private void createTopologyError(IFeature feature) { |
129 |
AbstractTopologyRule violatedRule = null; |
|
130 |
if(this.parentRule == null) |
|
131 |
violatedRule = parentRule; |
|
132 |
else |
|
133 |
violatedRule = this; |
|
126 | 134 |
TopologyError error = |
127 |
new TopologyError(feature.getGeometry(), this, feature, topology);
|
|
135 |
new TopologyError(feature.getGeometry(), violatedRule, feature, topology);
|
|
128 | 136 |
addTopologyError(error); |
129 | 137 |
} |
138 |
|
|
139 |
public JtsValidRule getParentRule() { |
|
140 |
return parentRule; |
|
141 |
} |
|
142 |
|
|
143 |
public void setParentRule(JtsValidRule parentRule) { |
|
144 |
this.parentRule = parentRule; |
|
145 |
} |
|
130 | 146 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/jtsisvalidrules/PolygonHolesMustBeInShell.java | ||
---|---|---|
57 | 57 |
import org.gvsig.topology.Topology; |
58 | 58 |
import org.gvsig.topology.TopologyError; |
59 | 59 |
import org.gvsig.topology.TopologyRuleDefinitionException; |
60 |
import org.gvsig.topology.topologyrules.JtsValidRule; |
|
60 | 61 |
|
61 | 62 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
62 | 63 |
import com.iver.cit.gvsig.fmap.core.FShape; |
... | ... | |
88 | 89 |
|
89 | 90 |
private double snapTolerance; |
90 | 91 |
|
92 |
private JtsValidRule parentRule; |
|
93 |
|
|
91 | 94 |
/** |
92 | 95 |
* Implementation of PointInRing that applies snap tolerance |
93 | 96 |
* |
... | ... | |
220 | 223 |
Polygon holeAsPoly = JtsUtil.geomFactory.createPolygon(hole, null); |
221 | 224 |
Geometry errorGeometry = EnhancedPrecisionOp.difference(shellAsPoly, holeAsPoly); |
222 | 225 |
IGeometry errorGeo = FConverter.jts_to_igeometry(errorGeometry); |
226 |
AbstractTopologyRule violatedRule = null; |
|
227 |
if(this.parentRule != null) |
|
228 |
violatedRule = parentRule; |
|
229 |
else |
|
230 |
violatedRule = this; |
|
223 | 231 |
TopologyError topologyError = |
224 |
new TopologyError(errorGeo, this, feature, topology);
|
|
232 |
new TopologyError(errorGeo, violatedRule, feature, topology);
|
|
225 | 233 |
addTopologyError(topologyError); |
226 | 234 |
|
227 | 235 |
}//for holes |
... | ... | |
264 | 272 |
snapTolerance = xml.getDoubleProperty("snapTolerance"); |
265 | 273 |
} |
266 | 274 |
} |
275 |
|
|
276 |
public JtsValidRule getParentRule() { |
|
277 |
return parentRule; |
|
278 |
} |
|
279 |
|
|
280 |
public void setParentRule(JtsValidRule parentRule) { |
|
281 |
this.parentRule = parentRule; |
|
282 |
} |
|
267 | 283 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/topologyrules/JtsValidRule.java | ||
---|---|---|
128 | 128 |
initialize(); |
129 | 129 |
} |
130 | 130 |
|
131 |
public void setTopology(Topology topology) { |
|
132 |
this.topology = topology; |
|
133 |
for(int i = 0; i < jtsRules.size(); i++){ |
|
134 |
jtsRules.get(i).setTopology(topology); |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
131 | 138 |
public void setTopologyErrorContainer(ITopologyErrorContainer errorContainer){ |
132 | 139 |
super.setTopologyErrorContainer(errorContainer); |
133 | 140 |
Iterator<ITopologyRule> iterator = jtsRules.iterator(); |
... | ... | |
196 | 203 |
private GeometryMustHaveValidCoordinates getValidCoordsRule(){ |
197 | 204 |
GeometryMustHaveValidCoordinates rule = new GeometryMustHaveValidCoordinates(topology, originLyr); |
198 | 205 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
206 |
rule.setParentRule(this); |
|
199 | 207 |
return rule; |
200 | 208 |
} |
201 | 209 |
|
202 | 210 |
private GeometryMustNotHaveFewPoints getFewPointsRule(){ |
203 | 211 |
GeometryMustNotHaveFewPoints rule = new GeometryMustNotHaveFewPoints(topology, originLyr); |
204 | 212 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
213 |
rule.setParentRule(this); |
|
205 | 214 |
return rule; |
206 | 215 |
|
207 | 216 |
} |
... | ... | |
209 | 218 |
private IGeometryMustBeClosed getClosedRingsRule(){ |
210 | 219 |
IGeometryMustBeClosed rule = new IGeometryMustBeClosed(topology, originLyr, snapTolerance); |
211 | 220 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
221 |
rule.setParentRule(this); |
|
212 | 222 |
return rule; |
213 | 223 |
} |
214 | 224 |
|
... | ... | |
216 | 226 |
MultiPolygonMustNotHaveNestedShells rule = |
217 | 227 |
new MultiPolygonMustNotHaveNestedShells(topology, originLyr); |
218 | 228 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
229 |
rule.setParentRule(this); |
|
219 | 230 |
return rule; |
220 | 231 |
|
221 | 232 |
} |
... | ... | |
223 | 234 |
private PolygonHolesMustBeInShell getHolesInShellRule(){ |
224 | 235 |
PolygonHolesMustBeInShell rule = new PolygonHolesMustBeInShell(topology, originLyr, snapTolerance); |
225 | 236 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
237 |
rule.setParentRule(this); |
|
226 | 238 |
return rule; |
227 | 239 |
} |
228 | 240 |
|
229 | 241 |
private PolygonHolesMustNotBeNested getHolesNotNestedRule(){ |
230 | 242 |
PolygonHolesMustNotBeNested rule = new PolygonHolesMustNotBeNested(topology, originLyr); |
231 | 243 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
244 |
rule.setParentRule(this); |
|
232 | 245 |
return rule; |
233 | 246 |
} |
234 | 247 |
|
... | ... | |
236 | 249 |
PolygonMustNotHaveDuplicatedRings rule = |
237 | 250 |
new PolygonMustNotHaveDuplicatedRings(topology, originLyr, snapTolerance); |
238 | 251 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
252 |
rule.setParentRule(this); |
|
239 | 253 |
return rule; |
240 | 254 |
} |
241 | 255 |
|
242 | 256 |
private PolygonMustHaveConnectedInterior getIntersectingRingsRule(){ |
243 | 257 |
PolygonMustHaveConnectedInterior rule = new PolygonMustHaveConnectedInterior(topology, originLyr); |
244 | 258 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
259 |
rule.setParentRule(this); |
|
245 | 260 |
return rule; |
246 | 261 |
} |
247 | 262 |
|
248 | 263 |
private PolygonMustNotHaveSelfIntersectedRings getSelfIntersectingRingRule(){ |
249 | 264 |
PolygonMustNotHaveSelfIntersectedRings rule = new PolygonMustNotHaveSelfIntersectedRings(topology, originLyr, snapTolerance); |
250 | 265 |
rule.setTopologyErrorContainer(this.getTopologyErrorContainer()); |
266 |
rule.setParentRule(this); |
|
251 | 267 |
return rule; |
252 | 268 |
} |
253 | 269 |
|
trunk/libraries/libTopology/src/org/gvsig/topology/Topology.java | ||
---|---|---|
68 | 68 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
69 | 69 |
import com.iver.cit.gvsig.fmap.MapContext; |
70 | 70 |
import com.iver.cit.gvsig.fmap.core.FShape; |
71 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
72 |
import com.iver.cit.gvsig.fmap.core.IRow; |
|
73 |
import com.iver.cit.gvsig.fmap.edition.AfterFieldEditEvent; |
|
74 |
import com.iver.cit.gvsig.fmap.edition.AfterRowEditEvent; |
|
75 |
import com.iver.cit.gvsig.fmap.edition.BeforeFieldEditEvent; |
|
76 |
import com.iver.cit.gvsig.fmap.edition.BeforeRowEditEvent; |
|
77 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
|
78 |
import com.iver.cit.gvsig.fmap.edition.IEditionListener; |
|
79 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
|
71 | 80 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
72 | 81 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
73 | 82 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
74 | 83 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
75 | 84 |
import com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent; |
85 |
import com.iver.cit.gvsig.fmap.layers.LayerEvent; |
|
86 |
import com.iver.cit.gvsig.fmap.layers.LayerListener; |
|
87 |
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial; |
|
76 | 88 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
77 | 89 |
import com.iver.utiles.IPersistence; |
78 | 90 |
import com.iver.utiles.XMLEntity; |
... | ... | |
166 | 178 |
private ITopologyErrorContainer errorContainer; |
167 | 179 |
|
168 | 180 |
/** |
181 |
* Collection of error layers created from topology errors in topology |
|
182 |
* error container. |
|
183 |
*/ |
|
184 |
private FLayer errorLayer; |
|
185 |
|
|
186 |
/** |
|
169 | 187 |
* Registered class to listen for change status events. |
170 | 188 |
*/ |
171 | 189 |
private List<ITopologyStatusListener> statusListeners; |
... | ... | |
217 | 235 |
this.clusterTolerance = clusterTolerance; |
218 | 236 |
this.maxNumberOfErrors = numberOfErrors; |
219 | 237 |
this.errorContainer = errorContainer; |
238 |
this.errorContainer.setTopology(this); |
|
220 | 239 |
|
221 | 240 |
rules = new ArrayList<ITopologyRule>(); |
222 | 241 |
clusterToleranceRules = new ArrayList<MustBeLargerThanClusterTolerance>(); |
... | ... | |
368 | 387 |
|
369 | 388 |
// before to add the rule we check if it verifies preconditions |
370 | 389 |
rule.checkPreconditions(); |
390 |
rule.setTopology(this); |
|
371 | 391 |
rules.add(rule); |
372 | 392 |
|
373 | 393 |
// Si se a?ade una nueva regla, no es posible conservar los errores |
... | ... | |
438 | 458 |
rule.setTopologyErrorContainer(this); |
439 | 459 |
clusterToleranceRules.add(rule); |
440 | 460 |
|
461 |
//finally, we connect edition with topology |
|
462 |
layer.addLayerListener(new LayerListener(){ |
|
463 |
|
|
464 |
public void activationChanged(LayerEvent e) { |
|
465 |
} |
|
466 |
|
|
467 |
public void editionChanged(LayerEvent e) { |
|
468 |
FLayer editionLyr = e.getSource(); |
|
469 |
|
|
470 |
if (editionLyr instanceof FLyrVect){ |
|
471 |
|
|
472 |
final ArrayList<Rectangle2D> dirtyZones = new ArrayList<Rectangle2D>(); |
|
473 |
|
|
474 |
FLyrVect fLyrVect = (FLyrVect)editionLyr; |
|
475 |
|
|
476 |
ReadableVectorial rv = fLyrVect.getSource(); |
|
477 |
if(! (rv instanceof VectorialEditableAdapter)) |
|
478 |
return; |
|
479 |
final VectorialEditableAdapter vea = |
|
480 |
(VectorialEditableAdapter)rv; |
|
481 |
|
|
482 |
vea.addEditionListener(new IEditionListener(){ |
|
483 |
|
|
484 |
public void afterFieldEditEvent( |
|
485 |
AfterFieldEditEvent e) { |
|
486 |
} |
|
487 |
|
|
488 |
public void afterRowEditEvent(IRow row, |
|
489 |
AfterRowEditEvent e) { |
|
490 |
//If we include alphanumeric rules to a topology as a |
|
491 |
//integrity rule, we'll add a new dirty zone for this too |
|
492 |
if(e.getChangeType() == EditionEvent.ALPHANUMERIC) |
|
493 |
return; |
|
494 |
int numRow = (int) e.getNumRow(); |
|
495 |
|
|
496 |
IGeometry geom; |
|
497 |
try { |
|
498 |
geom = vea.getShape(numRow); |
|
499 |
dirtyZones.add(geom.getBounds2D()); |
|
500 |
} catch (ExpansionFileReadException e1) { |
|
501 |
e1.printStackTrace(); |
|
502 |
} catch (ReadDriverException e1) { |
|
503 |
e1.printStackTrace(); |
|
504 |
} |
|
505 |
} |
|
506 |
|
|
507 |
public void beforeFieldEditEvent( |
|
508 |
BeforeFieldEditEvent e) { |
|
509 |
} |
|
510 |
|
|
511 |
public void beforeRowEditEvent(IRow feat, |
|
512 |
BeforeRowEditEvent e) { |
|
513 |
} |
|
514 |
|
|
515 |
public void processEvent(EditionEvent e) { |
|
516 |
if(e.getChangeType() == EditionEvent.STOP_EDITION){ |
|
517 |
for(int i = 0; i < dirtyZones.size(); i++){ |
|
518 |
Rectangle2D dirtyZone = dirtyZones.get(i); |
|
519 |
Topology.this.addDirtyZone(dirtyZone); |
|
520 |
}//for |
|
521 |
}//if |
|
522 |
}}); |
|
523 |
} |
|
524 |
} |
|
525 |
|
|
526 |
public void nameChanged(LayerEvent e) { |
|
527 |
} |
|
528 |
|
|
529 |
public void visibilityChanged(LayerEvent e) { |
|
530 |
}}); |
|
531 |
|
|
532 |
|
|
441 | 533 |
} catch (ExpansionFileReadException e) { |
442 | 534 |
e.printStackTrace(); |
443 | 535 |
throw new WrongLyrForTopologyException("No es posible acceder all FullExtent de la capa", e); |
... | ... | |
479 | 571 |
setRank(layer, xyRank, zRank); |
480 | 572 |
} |
481 | 573 |
|
574 |
|
|
482 | 575 |
/** |
483 | 576 |
* Remove a layer from a topology. |
484 | 577 |
* |
... | ... | |
776 | 869 |
}//while |
777 | 870 |
}//else |
778 | 871 |
}//while |
779 |
if(this.errorContainer.getNumberOfErrors() > 0) |
|
872 |
if(this.errorContainer.getNumberOfErrors() > 0){
|
|
780 | 873 |
setStatus(VALIDATED_WITH_ERRORS); |
781 |
else |
|
874 |
addErrorLyr(); |
|
875 |
}else |
|
782 | 876 |
setStatus(VALIDATED); |
783 | 877 |
} |
784 | 878 |
else if (this.status == VALIDATED_WITH_ERRORS || |
... | ... | |
840 | 934 |
|
841 | 935 |
|
842 | 936 |
}//while |
843 |
if(this.errorContainer.getNumberOfErrors() > 0) |
|
937 |
if(this.errorContainer.getNumberOfErrors() > 0){
|
|
844 | 938 |
setStatus(VALIDATED_WITH_ERRORS); |
845 |
else |
|
939 |
addErrorLyr(); |
|
940 |
}else |
|
846 | 941 |
setStatus(VALIDATED); |
847 | 942 |
}//if |
848 | 943 |
} |
849 | 944 |
|
945 |
private void addErrorLyr() { |
|
946 |
IProjection proj = this.getProjection(); |
|
947 |
int idx = 0; |
|
948 |
while(proj == null && idx < this.getLayerCount()){ |
|
949 |
proj = this.getLayer(idx).getProjection(); |
|
950 |
idx++; |
|
951 |
} |
|
952 |
errorLayer = this.errorContainer.getAsFMapLayer(this.name+"_error", proj); |
|
953 |
} |
|
954 |
|
|
850 | 955 |
public int getLayerCount() { |
851 | 956 |
return super.getLayersCount(); |
852 | 957 |
} |
... | ... | |
1226 | 1331 |
return this.errorContainer; |
1227 | 1332 |
} |
1228 | 1333 |
|
1334 |
|
|
1335 |
public FLayer getErrorLayer(){ |
|
1336 |
return this.errorLayer; |
|
1337 |
} |
|
1338 |
|
|
1229 | 1339 |
public void setErrorContainer(ITopologyErrorContainer errorContainer){ |
1230 | 1340 |
this.errorContainer = errorContainer; |
1341 |
this.errorContainer.setTopology(this); |
|
1231 | 1342 |
} |
1232 | 1343 |
|
1233 | 1344 |
private void fireStatusChange(TopologyStatusEvent event){ |
... | ... | |
1302 | 1413 |
// to.layers = from.layers; |
1303 | 1414 |
} |
1304 | 1415 |
|
1416 |
public FLyrVect getAsFMapLayer(String name, IProjection proj) { |
|
1417 |
return errorContainer.getAsFMapLayer(name, proj); |
|
1418 |
} |
|
1419 |
|
|
1420 |
/* |
|
1421 |
* Implementation of ITopologyErrorContanier |
|
1422 |
* |
|
1423 |
*/ |
|
1424 |
public Topology getTopology() { |
|
1425 |
return this; |
|
1426 |
} |
|
1427 |
|
|
1428 |
//FIXME See if Topology must implement ITopologyErrorContainer |
|
1429 |
public void setTopology(Topology topology) { |
|
1430 |
} |
|
1431 |
|
|
1305 | 1432 |
} |
trunk/libraries/libTopology/src/org/gvsig/topology/TopologyError.java | ||
---|---|---|
52 | 52 |
import org.gvsig.fmap.core.FeatureUtil; |
53 | 53 |
|
54 | 54 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
55 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
55 | 56 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
56 | 57 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
57 | 58 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
... | ... | |
131 | 132 |
} |
132 | 133 |
|
133 | 134 |
|
134 |
public TopologyError(){ |
|
135 |
public TopologyError(Topology parentTopology){
|
|
135 | 136 |
super(null, null, null); |
136 | 137 |
} |
137 | 138 |
|
... | ... | |
165 | 166 |
public int getShapeType() { |
166 | 167 |
return getGeometry().getGeometryType(); |
167 | 168 |
} |
169 |
|
|
170 |
public String getShapeTypeAsText(){ |
|
171 |
String solution = ""; |
|
172 |
int shapeType = getShapeType(); |
|
173 |
switch (shapeType) { |
|
174 |
case FShape.POINT: |
|
175 |
case FShape.TEXT: |
|
176 |
solution = Messages.getText("POINT"); |
|
177 |
break; |
|
178 |
case FShape.POLYGON: |
|
179 |
solution = Messages.getText("POLYGON"); |
|
180 |
break; |
|
181 |
case FShape.LINE: |
|
182 |
case FShape.ARC: |
|
183 |
case FShape.CIRCLE: |
|
184 |
case FShape.ELLIPSE: |
|
185 |
solution = Messages.getText("LINE"); |
|
186 |
break; |
|
187 |
case FShape.MULTI: |
|
188 |
solution = Messages.getText("MULTI"); |
|
189 |
break; |
|
190 |
case FShape.MULTIPOINT: |
|
191 |
solution = Messages.getText("MULTIPOINT"); |
|
192 |
break; |
|
193 |
} |
|
194 |
return solution; |
|
195 |
} |
|
168 | 196 |
|
169 | 197 |
public void setException(boolean exception) { |
170 | 198 |
this.exception = exception; |
... | ... | |
189 | 217 |
public String getClassName() { |
190 | 218 |
return this.getClass().getName(); |
191 | 219 |
} |
220 |
|
|
221 |
public Topology getTopology(){ |
|
222 |
return this.topology; |
|
223 |
} |
|
192 | 224 |
|
193 | 225 |
public XMLEntity getXMLEntity() { |
194 | 226 |
XMLEntity solution = FeatureUtil.getAsXmlEntity(this); |
trunk/libraries/libTopology/src/org/gvsig/topology/TopologyRuleFactory.java | ||
---|---|---|
130 | 130 |
throw new TopologyRuleDefinitionException("Regla que aplica a dos capas no ha especificado la segunda capa"); |
131 | 131 |
((ITwoLyrRule)rule).setDestinationLyr(destinationLyr); |
132 | 132 |
} |
133 |
|
|
134 |
rule.setTopology(ruleOwner); |
|
135 | 133 |
return rule; |
136 | 134 |
} catch (InstantiationException e) { |
137 | 135 |
throw new TopologyRuleDefinitionException( |
trunk/libraries/libTopology/src/com/iver/utiles/swing/threads/TopologyValidationTask.java | ||
---|---|---|
51 | 51 |
import org.gvsig.topology.Messages; |
52 | 52 |
import org.gvsig.topology.Topology; |
53 | 53 |
|
54 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
55 |
|
|
54 | 56 |
public class TopologyValidationTask extends CancellableProgressTask { |
55 | 57 |
|
56 | 58 |
static final String NOTE_PREFIX = Messages.getText("VALIDANDO_REGLA"); |
57 | 59 |
Topology topology; |
60 |
MapContext mapContext; |
|
58 | 61 |
|
59 |
public TopologyValidationTask(Topology topology) { |
|
62 |
public TopologyValidationTask(Topology topology, MapContext mapContext) {
|
|
60 | 63 |
this.topology = topology; |
64 |
this.mapContext = mapContext; |
|
61 | 65 |
super.statusMessage = Messages.getText("VALIDANDO_TOPOLOGIA"); |
62 | 66 |
super.currentNote = NOTE_PREFIX |
63 | 67 |
+ Messages.getText(topology.getRule(0).getName()); |
... | ... | |
65 | 69 |
|
66 | 70 |
public void run() throws Exception { |
67 | 71 |
topology.validate(this); |
72 |
if(topology.getNumberOfErrors() > 0) |
|
73 |
mapContext.getLayers().addLayer(topology.getErrorLayer()); |
|
68 | 74 |
finished = true; |
69 | 75 |
} |
70 | 76 |
|
Also available in: Unified diff