Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public Optional<BigDecimal> findShortestDistanceInDirection(
@Override
public Optional<TopPath> findShortestPath(final TopPoint from,
final TopPoint to) {
if (from.equalLocation(to)) {
return Optional.of(
new TopPath(List.of(from.edge()), BigDecimal.ZERO, from));
}
final MultiContainer_AttributeGroup container = getContainer(
from.edge());
final PlanPro_Schnittstelle planProSchnittstelle = getPlanProSchnittstelle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ public Node splitGraphAt(final TopPoint at) {
* @return a node at the point where the graph was split
*/
public Node splitGraphAt(final TopPoint at, final Boolean inTopDirection) {
// When already split at the point
final Optional<Node> existedNode = existedSplitNodeAt(at);
if (existedNode.isPresent()) {
return existedNode.get();
}
final TOP_Kante edge = at.edge();
final List<Edge> pointEdgeList = pointEdgeGraph.edgeSet()
.stream()
Expand Down Expand Up @@ -211,6 +216,26 @@ public Node splitGraphAt(final TopPoint at, final Boolean inTopDirection) {
"Cannot split graph on a point outside the graph"); //$NON-NLS-1$
}

private Optional<Node> existedSplitNodeAt(final TopPoint at) {
if (isTopKnoten(at)) {
final TOP_Knoten atKnote = at.distance()
.compareTo(BigDecimal.ZERO) == 0
? at.edge().getIDTOPKnotenA().getValue()
: at.edge().getIDTOPKnotenB().getValue();
return pointEdgeGraph.vertexSet()
.stream()
.filter(n -> n.node != null)
.filter(n -> n.node == atKnote)
.findFirst();
}
return pointEdgeGraph.vertexSet()
.stream()
.filter(n -> n.point != null)
.filter(n -> n.point.edge() == at.edge()
&& n.point.distance().compareTo(at.distance()) == 0)
.findFirst();
}

private static boolean isTopKnoten(final TopPoint point) {
return point.distance().compareTo(BigDecimal.ZERO) == 0
|| point.distance()
Expand Down
Loading