Skip to content

Commit 95a58bb

Browse files
committed
core: fix bug when starting path at chunk transition
We sometimes looked for a chunk that was just outside of the path, and didn't find it in the block path
1 parent 44360a4 commit 95a58bb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/main/java/fr/sncf/osrd/standalone_sim/ScheduleMetadataExtractor.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,12 @@ fun trainPathBlockOffset(
573573
blockPath: StaticIdxList<Block>,
574574
chunkPath: ChunkPath
575575
): Distance {
576-
val firstChunk = chunkPath.chunks[0]
576+
var firstChunk = chunkPath.chunks[0]
577577
var prevChunksLength = 0.meters
578+
if (infra.getTrackChunkLength(firstChunk.value) == chunkPath.beginOffset) {
579+
firstChunk = chunkPath.chunks[1]
580+
prevChunksLength = -chunkPath.beginOffset.distance
581+
}
578582
for (block in blockPath) {
579583
for (zonePath in blockInfra.getBlockPath(block)) {
580584
for (dirChunk in infra.getZonePathChunks(zonePath)) {

0 commit comments

Comments
 (0)