Revision 510 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.trimline/src/main/java/org/gvsig/vectorediting/lib/prov/trimline/operation/CurveTrimLineOperation.java
CurveTrimLineOperation.java | ||
---|---|---|
74 | 74 |
Geometry tmpDifference = segmentedLine.difference(geometry); |
75 | 75 |
if (tmpDifference instanceof MultiCurve) { |
76 | 76 |
segmentedLine = (MultiCurve) tmpDifference; |
77 |
} else if(tmpDifference instanceof Curve) { |
|
78 |
// Sometimes line to split and splitter are so close ( distance |
|
79 |
// between geometries < 0.00000000001 ). In this cases, we try |
|
80 |
// to do an enhance difference. |
|
81 |
// If the result is instance of Curve, it is considered that |
|
82 |
// lines don't intersect. |
|
83 |
// If the result is instance of Multicurve, lines are so close |
|
84 |
// and it is considered that lines intersect. |
|
85 |
Geometry enchancedGeometry = enhancedDifference(geometry, (Curve) tmpDifference); |
|
86 |
if(enchancedGeometry instanceof MultiCurve){ |
|
87 |
segmentedLine = (MultiCurve) enchancedGeometry; |
|
88 |
} |
|
77 | 89 |
} |
78 | 90 |
} |
79 | 91 |
|
... | ... | |
155 | 167 |
} |
156 | 168 |
return null; |
157 | 169 |
} |
170 |
|
|
171 |
private Geometry enhancedDifference(Geometry splitter, Curve curve) |
|
172 |
throws GeometryOperationNotSupportedException, |
|
173 |
GeometryOperationException { |
|
174 |
Geometry snapTo = curve.snapTo(splitter, 0.1); |
|
175 |
return snapTo.difference(splitter); |
|
176 |
} |
|
158 | 177 |
} |
Also available in: Unified diff