Skip to content

Commit 6337fd7

Browse files
committed
front: fix stdcm passages
Signed-off-by: Clara Ni <clara.ni@outlook.fr>
1 parent b4a69f6 commit 6337fd7

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

front/src/applications/stdcm/utils/formatStdcmConf.ts

+20-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { kmhToMs, tToKg } from 'utils/physics';
1616
import { ISO8601Duration2sec, sec2ms } from 'utils/timeManipulation';
1717

1818
import createMargin from './createMargin';
19+
import { StdcmStopTypes } from '../types';
1920

2021
type ValidStdcmConfig = {
2122
rollingStockId: number;
@@ -139,15 +140,25 @@ export const checkStdcmConf = (
139140
const { arrival, tolerances, stopFor, arrivalType } = step;
140141
const location = getStepLocation(step);
141142

142-
const duration = stopFor ? sec2ms(ISO8601Duration2sec(stopFor) || Number(stopFor)) : 0;
143-
const timingData =
144-
arrivalType === 'preciseTime' && arrival
145-
? {
146-
arrival_time: arrival,
147-
arrival_time_tolerance_before: sec2ms(tolerances?.before ?? 0),
148-
arrival_time_tolerance_after: sec2ms(tolerances?.after ?? 0),
149-
}
150-
: undefined;
143+
let timingData: PathfindingItem['timing_data'] | undefined;
144+
let duration: number | undefined;
145+
if (step.isVia) {
146+
if (step.stopType !== StdcmStopTypes.PASSAGE_TIME) {
147+
duration = stopFor ? sec2ms(ISO8601Duration2sec(stopFor) || Number(stopFor)) : 0;
148+
}
149+
} else {
150+
// if the step is either the origin or the destination,
151+
// it must have a duration
152+
duration = 0;
153+
if (arrivalType === 'preciseTime' && arrival) {
154+
timingData = {
155+
arrival_time: arrival,
156+
arrival_time_tolerance_before: sec2ms(tolerances?.before ?? 0),
157+
arrival_time_tolerance_after: sec2ms(tolerances?.after ?? 0),
158+
};
159+
}
160+
}
161+
151162
return {
152163
duration,
153164
location,

0 commit comments

Comments
 (0)