Skip to content

Commit 9e29593

Browse files
committed
front: fix stdcm passages
Signed-off-by: Clara Ni <[email protected]>
1 parent 57c96f7 commit 9e29593

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
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,

front/tests/assets/stdcm/stdcmAllStops.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"operationalPoint": "Mid_West_station",
1515
"code": "BV",
1616
"endStop": "",
17-
"passageStop": "01:17",
17+
"passageStop": "01:16",
1818
"startStop": "",
1919
"weight": "=",
2020
"refEngine": "="
@@ -23,9 +23,9 @@
2323
"index": 3,
2424
"operationalPoint": "Mid_East_station",
2525
"code": "BV",
26-
"endStop": "01:23",
26+
"endStop": "01:22",
2727
"passageStop": "3 min",
28-
"startStop": "01:26",
28+
"startStop": "01:25",
2929
"weight": "=",
3030
"refEngine": "="
3131
},
@@ -43,7 +43,7 @@
4343
"index": 5,
4444
"operationalPoint": "South_station",
4545
"code": "BV",
46-
"endStop": "01:41",
46+
"endStop": "01:40",
4747
"passageStop": "",
4848
"startStop": "",
4949
"weight": "400t",

front/tests/assets/stdcm/stdcmWithAllVia.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"operationalPoint": "Mid_West_station",
1515
"code": "BV",
1616
"endStop": "",
17-
"passageStop": "20:42",
17+
"passageStop": "20:41",
1818
"startStop": "",
1919
"weight": "=",
2020
"refEngine": "="
@@ -24,7 +24,7 @@
2424
"operationalPoint": "Mid_East_station",
2525
"code": "BV",
2626
"endStop": "",
27-
"passageStop": "20:47",
27+
"passageStop": "20:46",
2828
"startStop": "",
2929
"weight": "=",
3030
"refEngine": "="
@@ -34,7 +34,7 @@
3434
"operationalPoint": "North_station",
3535
"code": "BV",
3636
"endStop": "",
37-
"passageStop": "20:53",
37+
"passageStop": "20:52",
3838
"startStop": "",
3939
"weight": "=",
4040
"refEngine": "="
@@ -43,7 +43,7 @@
4343
"index": 5,
4444
"operationalPoint": "South_station",
4545
"code": "BV",
46-
"endStop": "20:57",
46+
"endStop": "20:55",
4747
"passageStop": "",
4848
"startStop": "",
4949
"weight": "400t",

front/tests/assets/stdcm/stdcmWithoutAllVia.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"operationalPoint": "Mid_West_station",
1515
"code": "BV",
1616
"endStop": "",
17-
"passageStop": "20:42",
17+
"passageStop": "20:41",
1818
"startStop": "",
1919
"weight": "=",
2020
"refEngine": "="
@@ -23,7 +23,7 @@
2323
"index": 3,
2424
"operationalPoint": "South_station",
2525
"code": "BV",
26-
"endStop": "20:57",
26+
"endStop": "20:56",
2727
"passageStop": "",
2828
"startStop": "",
2929
"weight": "400t",

0 commit comments

Comments
 (0)