Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix find banking line process #1118

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -124,18 +124,27 @@ private void addBankingForContainer(
}
for (final Ueberhoehungslinie line : container
.getUeberhoehungslinie()) {
final BankingInformation bankingInformation = findTOPBanking(line);
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedException();
}
if (bankingInformation == null) {
logger.debug("Can't find TopPath for Ueberhoehungslinie: {}", //$NON-NLS-1$
line.getIdentitaet().getWert());
bankingInformations.put(line, Optional.empty());
} else {
logger.debug("Found TopPath for Ueberhoehungslinie: {}", //$NON-NLS-1$
line.getIdentitaet().getWert());
bankingInformations.put(line, Optional.of(bankingInformation));

try {
final BankingInformation bankingInformation = findTOPBanking(
line);

if (bankingInformation == null) {
logger.debug(
"Can't find TopPath for Ueberhoehungslinie: {}", //$NON-NLS-1$
line.getIdentitaet().getWert());
bankingInformations.put(line, Optional.empty());
} else {
logger.debug("Found TopPath for Ueberhoehungslinie: {}", //$NON-NLS-1$
line.getIdentitaet().getWert());
bankingInformations.put(line,
Optional.of(bankingInformation));
}
} catch (final NullPointerException e) {
logger.error(e.getMessage());
}
}

Expand Down Expand Up @@ -165,6 +174,9 @@ public BankingInformation findTOPBanking(

final Ueberhoehung begin = bankingLine.getIDUeberhoehungA().getValue();
final Ueberhoehung end = bankingLine.getIDUeberhoehungB().getValue();
if (begin == null || end == null) {
return null;
}
final BigDecimal bankingLineLength = bankingLine
.getUeberhoehungslinieAllg().getUeberhoehungslinieLaenge()
.getWert();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public Optional<TopPath> findShortestPath(final TopPoint from,
.map(p -> new TopPath(
p.getEdgeList().stream().map(Edge::edge).distinct()
.toList(),
getPathWeight(p), fromNode.point().distance()));
getPathWeight(p),
p.getEdgeList().getFirst().getWeight()));
}

private static BigDecimal getPathWeight(final GraphPath<Node, Edge> path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class TopPath {
private final List<TOP_Kante> edges;
private final BigDecimal length;
private final BigDecimal offset; // offset from start of first edge
private final BigDecimal firstEdgeLength;

/**
* @param edges
Expand All @@ -32,14 +32,14 @@ public class TopPath {
* the total length of the path. may be less than the total
* length of the edges if the path does not cover the full extent
* of the edges
* @param offset
* starting offset from the first TOP_Kante in edges
* @param firstEdgeLength
* the length of the first edge
*/
public TopPath(final List<TOP_Kante> edges, final BigDecimal length,
final BigDecimal offset) {
final BigDecimal firstEdgeLength) {
mariusheine marked this conversation as resolved.
Show resolved Hide resolved
this.edges = edges;
this.length = length;
this.offset = offset;
this.firstEdgeLength = firstEdgeLength;
}

/**
Expand All @@ -59,12 +59,10 @@ public BigDecimal length() {
}

/**
* @return the total length of the path. may be less than the total length
* of the edges if the path does not cover the full extent of the
* edges
* @return the length off the first Edges
*/
public BigDecimal offset() {
return offset;
public BigDecimal firstEdgeLength() {
return firstEdgeLength;
}

/**
Expand All @@ -74,7 +72,7 @@ public BigDecimal offset() {
* on the path
*/
public Optional<BigDecimal> getDistance(final TopPoint point) {
BigDecimal pathOffset = this.offset.negate();
BigDecimal pathOffset = this.firstEdgeLength;

TOP_Kante previousEdge = null;
for (final TOP_Kante edge : edges()) {
Expand All @@ -83,7 +81,7 @@ public Optional<BigDecimal> getDistance(final TopPoint point) {

// If the point is on the current edge, check which direction to add
if (point.edge().equals(edge)) {
// in top direction?
// In top direction
if (previousEdge == null
|| previousEdge.getIDTOPKnotenB().getValue() == edge
.getIDTOPKnotenA().getValue()
Expand All @@ -108,15 +106,15 @@ public Optional<BigDecimal> getDistance(final TopPoint point) {
}

return Optional.of(pointDistance);

}

// Point not on this edge, check next edge
if (previousEdge != null) {
pathOffset = pathOffset.add(edgeLength);
}
previousEdge = edge;
pathOffset = pathOffset.add(edgeLength);

}
return Optional.empty();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class BankValues extends AbstractPlazContainerCheck implements PlazCheck, EventH
].map [
val bankLength = ueberhoehungslinieAllg.
ueberhoehungslinieLaenge.wert
if (IDUeberhoehungA?.value === null ||
IDUeberhoehungB?.value === null) {
return createError(
"Die Überhöhungslinie {GUID} fehlt Ueberhoehung_A oder Ueberhoehung_B.",
TruongQuangSB marked this conversation as resolved.
Show resolved Hide resolved
Map.of("GUID", it.identitaet.wert))
}
val begin = new TopPoint(IDUeberhoehungA.value)
val end = new TopPoint(IDUeberhoehungB.value)
val paths = topologicalService.findAllPathsBetween(begin, end,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.function.Predicate;

import org.eclipse.set.basis.graph.TopPath;
Expand Down Expand Up @@ -303,23 +304,30 @@ private static List<DirectedTOPEdge<Edge>> findRelevantEdgesFromTarget(

// Check whether the incoming edges of this node are correctly
// decorated
for (final DirectedTOPEdge<Edge> edge : graph
.incomingEdgesOf(vertex)) {
final Set<DirectedTOPEdge<Edge>> incomingEdgesOf = graph
.incomingEdgesOf(vertex);
for (final DirectedTOPEdge<Edge> edge : incomingEdgesOf) {
// Mark the edge if needed
final BigDecimal weight = edge.edge().getWeight();
final BigDecimal remainingWeight = currentRemaining
.subtract(weight);

final Node edgeSource = graph.getEdgeSource(edge);
if (remainingWeight.compareTo(BigDecimal.ZERO) < 1) {
continue;
}
edgesDistance.add(edge);
// Mark the edge's source vertex if needed
final Node edgeSource = graph.getEdgeSource(edge);
mariusheine marked this conversation as resolved.
Show resolved Hide resolved
remainingWeigthFromEnd.computeIfAbsent(edgeSource, v -> {
nodesToProcess.add(edgeSource);
return remainingWeight;
});

// When exist another Edge, which shorter als founded Edge, then
// replace the weight
TruongQuangSB marked this conversation as resolved.
Show resolved Hide resolved
remainingWeigthFromEnd.computeIfPresent(edgeSource,
(k, v) -> remainingWeight.compareTo(v) > 0
? remainingWeight
: v);
}
}
assert nodesToProcess.isEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,13 @@ public Node splitGraphAt(final TopPoint at) {
*/
public Node splitGraphAt(final TopPoint at, final Boolean inTopDirection) {
final TOP_Kante edge = at.edge();

final List<Edge> pointEdgeList = pointEdgeGraph.edgeSet().stream()
.filter(c -> c.edge == edge)
.filter(c -> c.offset.compareTo(at.distance()) <= 0)
.filter(c -> c.offset.add(c.length)
.compareTo(at.distance()) >= 0)
.toList();
final Optional<Edge> pointGraphEdge = pointEdgeList.stream()

.max((e1, e2) -> e1.offset.compareTo(e2.offset));
if (pointGraphEdge.isPresent()) {
return splitGraphAt(pointEdgeGraph, at, pointGraphEdge.get(),
Expand Down
Loading