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

core: stdcm: fix Offset<Path> conversion when route has previous blocks #10380

Merged
merged 1 commit into from
Jan 15, 2025
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 @@ -291,7 +291,7 @@ private fun findConflictOffsets(
edges: List<STDCMEdge>,
updatedTimeData: TimeData,
): Offset<TravelledPath>? {
val startOffset = edges[0].envelopeStartOffset
val startOffset = edges[0].fromTravelledOffset(Offset(0.meters))
val endOffset =
startOffset +
Distance(
Expand Down
19 changes: 19 additions & 0 deletions core/src/main/kotlin/fr/sncf/osrd/stdcm/graph/STDCMEdge.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<Block>,
// Index of the last waypoint passed by this train
val waypointIndex: Int,
Expand Down Expand Up @@ -143,4 +146,20 @@ data class STDCMEdge(
fun blockOffsetFromEdge(edgeOffset: Offset<STDCMEdge>): Offset<Block> {
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<Path>): Offset<TravelledPath> {
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<TravelledPath>): Offset<Path> {
return infraExplorer.getIncrementalPath().fromTravelledPath(travelledPathOffset)
}
}
Loading