diff --git a/core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/PostProcessingSimulation.kt b/core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/PostProcessingSimulation.kt index 2b8a751135a..97b5a4ca87a 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/PostProcessingSimulation.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/PostProcessingSimulation.kt @@ -291,7 +291,7 @@ private fun findConflictOffsets( edges: List, updatedTimeData: TimeData, ): Offset? { - val startOffset = edges[0].envelopeStartOffset + val startOffset = edges[0].fromTravelledOffset(Offset(0.meters)) val endOffset = startOffset + Distance( diff --git a/core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/STDCMEdge.kt b/core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/STDCMEdge.kt index 55f34080c3c..f654a6c71c2 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/STDCMEdge.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/STDCMEdge.kt @@ -1,6 +1,8 @@ package fr.sncf.osrd.stdcm.graph import fr.sncf.osrd.sim_infra.api.Block +import fr.sncf.osrd.sim_infra.api.Path +import fr.sncf.osrd.sim_infra.api.TravelledPath import fr.sncf.osrd.stdcm.infra_exploration.InfraExplorerWithEnvelope import fr.sncf.osrd.utils.units.Length import fr.sncf.osrd.utils.units.Offset @@ -17,6 +19,7 @@ data class STDCMEdge( // Node located at the start of this edge val previousNode: STDCMNode, // Offset of the envelope if it doesn't start at the beginning of the edge + // This can *not* be used to convert Path / TravelledPath (should reference start of 1st route) val envelopeStartOffset: Offset, // Index of the last waypoint passed by this train val waypointIndex: Int, @@ -143,4 +146,20 @@ data class STDCMEdge( fun blockOffsetFromEdge(edgeOffset: Offset): Offset { return envelopeStartOffset + edgeOffset.distance } + + /** + * Converts from Path Offset (references start of first route) to Travelled path offset + * (references train departure point) + */ + fun toTravelledOffset(pathOffset: Offset): Offset { + return infraExplorer.getIncrementalPath().toTravelledPath(pathOffset) + } + + /** + * Converts from Travelled path offset (references train departure point) to Path Offset + * (references start of first route) + */ + fun fromTravelledOffset(travelledPathOffset: Offset): Offset { + return infraExplorer.getIncrementalPath().fromTravelledPath(travelledPathOffset) + } }