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: handle non-stop transitions for NGE → OSRD conversion #9680

Merged
merged 2 commits into from
Nov 15, 2024
Merged
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 @@ -55,7 +55,6 @@ const getTrainrunSectionsByTrainrunId = (netzgrafikDto: NetzgrafikDto, trainrunI
// source port.
let departureSection: TrainrunSectionDto | undefined;
const sectionsByPrevTargetPortId = new Map<number, TrainrunSectionDto>();
// eslint-disable-next-line no-restricted-syntax
for (const section of sections) {
const sourceNode = getNodeById(netzgrafikDto.nodes, section.sourceNodeId)!;
const transition = sourceNode.transitions.find(
Expand Down Expand Up @@ -177,7 +176,6 @@ const createTrainSchedulePayload = async ({
oldStartDate: Date;
trainSchedule?: TrainScheduleBase;
}) => {
// TODO: check that the trainrunSections format is still compatible
const pathPromise = trainrunSections.map(async (section, index) => {
const sourceNode = getNodeById(nodes, section.sourceNodeId);
const targetNode = getNodeById(nodes, section.targetNodeId);
Expand Down Expand Up @@ -221,7 +219,12 @@ const createTrainSchedulePayload = async ({
const schedule = trainrunSections.flatMap((section, index) => {
const nextSection = trainrunSections[index + 1];

// TODO: extract isNonStopTransit from transitions
const node = getNodeById(nodes, section.targetNodeId)!;
const transition = node.transitions.find(
(tr) => tr.port1Id === section.targetPortId || tr.port2Id === section.targetPortId
);
const isNonStopTransit = transition?.isNonStopTransit ?? false;

let arrival = getTimeLockDate(section.targetArrival, startTimeLock, startDate);
const departure = nextSection
? getTimeLockDate(nextSection.sourceDeparture, startTimeLock, startDate)
Expand All @@ -236,7 +239,7 @@ const createTrainSchedulePayload = async ({
return {
at: `${section.targetNodeId}-${index + 1}`,
arrival: formatDateDifference(arrival, startDate),
stop_for: departure ? formatDateDifference(departure, arrival) : null,
stop_for: departure && !isNonStopTransit ? formatDateDifference(departure, arrival) : null,
};
});

Expand Down
Loading