diff --git a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/pathfinding/PathfindingBlocksEndpointV2.kt b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/pathfinding/PathfindingBlocksEndpointV2.kt index a750736b1d8..ca2428bca6f 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/pathfinding/PathfindingBlocksEndpointV2.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/pathfinding/PathfindingBlocksEndpointV2.kt @@ -86,7 +86,15 @@ fun runPathfinding( for (waypoint in step) { val waypointBlocks = findWaypointBlocks(infra, waypoint, direction) if (request.stopAtNextSignal && stepIndex != 0) { - allStarts.addAll(waypointBlocks.map { findNextSignalBlockOnWaypointBlock(it, infra, request.rollingStockLength) }) + allStarts.addAll( + waypointBlocks.map { + findNextSignalBlockOnWaypointBlock( + it, + infra, + request.rollingStockLength + ) + } + ) } else { allStarts.addAll(waypointBlocks) } @@ -377,26 +385,33 @@ private fun getBlockOffset( ) } -public fun findNextSignalBlockOnWaypointBlock( +fun findNextSignalBlockOnWaypointBlock( waypointBlock: PathfindingEdgeLocationId, infra: FullInfra, rollingStockLength: Double ): PathfindingEdgeLocationId { - val nextSignalOffset = getNextSignalOffset(waypointBlock.edge, waypointBlock.offset, infra, rollingStockLength) + val nextSignalOffset = + getNextSignalOffset(waypointBlock.edge, waypointBlock.offset, infra, rollingStockLength) return PathfindingEdgeLocationId(waypointBlock.edge, nextSignalOffset) } -private fun getNextSignalOffset(blockId: BlockId, blockOffset: Offset, infra: FullInfra, rollingStockLength: Double): Offset { +private fun getNextSignalOffset( + blockId: BlockId, + blockOffset: Offset, + infra: FullInfra, + rollingStockLength: Double +): Offset { val signalsPositions = infra.blockInfra.getSignalsPositions(blockId) val blockLength = infra.blockInfra.getBlockLength(blockId).distance val nextSignalPosition = signalsPositions.firstOrNull { it.distance >= blockOffset.distance } // some blocks are < 1m long (even 0m), we can't get further in the block - val maxHeadOffset = if (blockOffset.distance < 1.meters) { - blockOffset.distance - } else { - (nextSignalPosition?.distance ?: blockLength) - 1.meters - } + val maxHeadOffset = + if (blockOffset.distance < 1.meters) { + blockOffset.distance + } else { + (nextSignalPosition?.distance ?: blockLength) - 1.meters + } val minTailOffset = blockOffset.distance + rollingStockLength.meters val finalOffset = if (minTailOffset <= maxHeadOffset) minTailOffset else maxHeadOffset diff --git a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/stdcm/STDCMEndpointV2.kt b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/stdcm/STDCMEndpointV2.kt index 0b7efc880cc..725ea0ac202 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/stdcm/STDCMEndpointV2.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/api/api_v2/stdcm/STDCMEndpointV2.kt @@ -98,7 +98,13 @@ class STDCMEndpointV2(private val infraManager: InfraManager) : Take { convertWorkScheduleCollection(infra.rawInfra, request.workSchedules) trainsRequirements.add(convertedWorkSchedules) val spacingRequirements = trainsRequirements.flatMap { it.spacingRequirements } - val steps = parseSteps(infra, request.pathItems, request.startTime, request.rollingStock.length.distance.meters) + val steps = + parseSteps( + infra, + request.pathItems, + request.startTime, + request.rollingStock.length.distance.meters + ) // Run the STDCM pathfinding val path =