@@ -40,13 +40,16 @@ public class PathfindingRoutesEndpoint implements Take {
40
40
public static final String PATH_FINDING_ELECTRIFICATION_ERROR =
41
41
"No path could be found after loading Electrification constraints" ;
42
42
43
+ static {
44
+ constraints .put (LoadingGaugeConstraints .class , PATH_FINDING_GAUGE_ERROR );
45
+ constraints .put (ElectrificationConstraints .class , PATH_FINDING_ELECTRIFICATION_ERROR );
46
+ }
47
+
43
48
/**
44
49
* constructor
45
50
*/
46
51
public PathfindingRoutesEndpoint (InfraManager infraHandler ) {
47
52
this .infraManager = infraHandler ;
48
- constraints .put (LoadingGaugeConstraints .class , PATH_FINDING_GAUGE_ERROR );
49
- constraints .put (ElectrificationConstraints .class , PATH_FINDING_ELECTRIFICATION_ERROR );
50
53
}
51
54
52
55
@ Override
@@ -90,7 +93,7 @@ public static Pathfinding.Result<SignalingRoute> runPathfinding(
90
93
SignalingInfra infra ,
91
94
PathfindingWaypoint [][] reqWaypoints ,
92
95
Collection <RollingStock > rollingStocks
93
- ) throws NoPathFoundError {
96
+ ) throws NoPathFoundError {
94
97
// parse the waypoints
95
98
var waypoints = new ArrayList <Collection <Pathfinding .EdgeLocation <SignalingRoute >>>();
96
99
for (var step : reqWaypoints ) {
@@ -138,14 +141,14 @@ private static Pathfinding.Result<SignalingRoute> computePaths(
138
141
// check there is no path without adding constraints
139
142
var possiblePathWithoutErrorNoConstraints =
140
143
new Pathfinding <>(new GraphAdapter <>(infra .getSignalingRouteGraph ()))
141
- .setEdgeToLength (route -> route .getInfraRoute ().getLength ())
142
- .setRemainingDistanceEstimator (remainingDistanceEstimator )
143
- .runPathfinding (waypoints );
144
+ .setEdgeToLength (route -> route .getInfraRoute ().getLength ())
145
+ .setRemainingDistanceEstimator (remainingDistanceEstimator )
146
+ .runPathfinding (waypoints );
144
147
if (possiblePathWithoutErrorNoConstraints == null ) {
145
148
throw new NoPathFoundError (PATH_FINDING_GENERIC_ERROR );
146
149
}
147
150
// handling errors
148
- for (EdgeToRanges <SignalingRoute > currentConstraint : constraintsList ) {
151
+ for (EdgeToRanges <SignalingRoute > currentConstraint : constraintsList ) {
149
152
var possiblePathWithoutError = new Pathfinding <>(new GraphAdapter <>(infra .getSignalingRouteGraph ()))
150
153
.setEdgeToLength (route -> route .getInfraRoute ().getLength ())
151
154
.addBlockedRangeOnEdges (currentConstraint )
0 commit comments