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

front: fix stdcm passage #9653

Merged
merged 1 commit into from
Nov 22, 2024
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
29 changes: 20 additions & 9 deletions front/src/applications/stdcm/utils/formatStdcmConf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { kmhToMs, tToKg } from 'utils/physics';
import { ISO8601Duration2sec, sec2ms } from 'utils/timeManipulation';

import createMargin from './createMargin';
import { StdcmStopTypes } from '../types';

type ValidStdcmConfig = {
rollingStockId: number;
Expand Down Expand Up @@ -139,15 +140,25 @@ export const checkStdcmConf = (
const { arrival, tolerances, stopFor, arrivalType } = step;
const location = getStepLocation(step);

const duration = stopFor ? sec2ms(ISO8601Duration2sec(stopFor) || Number(stopFor)) : 0;
const timingData =
arrivalType === 'preciseTime' && arrival
? {
arrival_time: arrival,
arrival_time_tolerance_before: sec2ms(tolerances?.before ?? 0),
arrival_time_tolerance_after: sec2ms(tolerances?.after ?? 0),
}
: undefined;
let timingData: PathfindingItem['timing_data'] | undefined;
let duration: number | undefined;
if (step.isVia) {
if (step.stopType !== StdcmStopTypes.PASSAGE_TIME) {
duration = stopFor ? sec2ms(ISO8601Duration2sec(stopFor) || Number(stopFor)) : 0;
}
} else {
// if the step is either the origin or the destination,
// it must have a duration
duration = 0;
if (arrivalType === 'preciseTime' && arrival) {
timingData = {
arrival_time: arrival,
arrival_time_tolerance_before: sec2ms(tolerances?.before ?? 0),
arrival_time_tolerance_after: sec2ms(tolerances?.after ?? 0),
};
}
}

return {
duration,
location,
Expand Down
8 changes: 4 additions & 4 deletions front/tests/assets/stdcm/stdcmAllStops.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"operationalPoint": "Mid_West_station",
"code": "BV",
"endStop": "",
"passageStop": "01:17",
"passageStop": "01:16",
"startStop": "",
"weight": "=",
"refEngine": "="
Expand All @@ -23,9 +23,9 @@
"index": 3,
"operationalPoint": "Mid_East_station",
"code": "BV",
"endStop": "01:23",
"endStop": "01:22",
"passageStop": "3 min",
"startStop": "01:26",
"startStop": "01:25",
"weight": "=",
"refEngine": "="
},
Expand All @@ -43,7 +43,7 @@
"index": 5,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "01:41",
"endStop": "01:40",
"passageStop": "",
"startStop": "",
"weight": "400t",
Expand Down
8 changes: 4 additions & 4 deletions front/tests/assets/stdcm/stdcmWithAllVia.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"operationalPoint": "Mid_West_station",
"code": "BV",
"endStop": "",
"passageStop": "20:42",
"passageStop": "20:41",
"startStop": "",
"weight": "=",
"refEngine": "="
Expand All @@ -24,7 +24,7 @@
"operationalPoint": "Mid_East_station",
"code": "BV",
"endStop": "",
"passageStop": "20:47",
"passageStop": "20:46",
"startStop": "",
"weight": "=",
"refEngine": "="
Expand All @@ -34,7 +34,7 @@
"operationalPoint": "North_station",
"code": "BV",
"endStop": "",
"passageStop": "20:53",
"passageStop": "20:52",
"startStop": "",
"weight": "=",
"refEngine": "="
Expand All @@ -43,7 +43,7 @@
"index": 5,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "20:57",
"endStop": "20:56",
"passageStop": "",
"startStop": "",
"weight": "400t",
Expand Down
4 changes: 2 additions & 2 deletions front/tests/assets/stdcm/stdcmWithoutAllVia.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"operationalPoint": "Mid_West_station",
"code": "BV",
"endStop": "",
"passageStop": "20:42",
"passageStop": "20:41",
"startStop": "",
"weight": "=",
"refEngine": "="
Expand All @@ -23,7 +23,7 @@
"index": 3,
"operationalPoint": "South_station",
"code": "BV",
"endStop": "20:57",
"endStop": "20:56",
"passageStop": "",
"startStop": "",
"weight": "400t",
Expand Down
Loading