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 displayed op on manchette #10334

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -35,7 +35,7 @@ export const upsertMapWaypointsInOperationalPoints = (
},
part: { track: step.track, position: step.offset },
position: positionOnPath,
weight: null,
weight: 100,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid magic numbers and because it's also used in useGetProjectedTrainOperationalsPoints maybe we should use a const like 'HIGHEST_PRIORITY_WEIGHT' here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed !

};

waypointCounter += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useAppDispatch } from 'store';
import { getPointCoordinates } from 'utils/geometry';

import useSimulationResults from '../hooks/useSimulationResults';
import type { OperationalPoint, PathPropertiesFormatted } from '../types';

const SPEED_SPACE_CHART_HEIGHT = 521.5;
const HANDLE_TAB_RESIZE_HEIGHT = 20;
Expand Down Expand Up @@ -120,6 +121,21 @@ const SimulationResults = ({
return null;
}

const updatePathProperties = (
pathProps: PathPropertiesFormatted | undefined,
updatedOperationalPoints: OperationalPoint[] | undefined
): PathPropertiesFormatted | undefined => {
if (!pathProps || !updatedOperationalPoints) {
return undefined;
}
return {
...pathProps,
operationalPoints: updatedOperationalPoints,
};
};

const updatedPathProperties = updatePathProperties(pathProperties, projectedOperationalPoints);

return (
<div className="simulation-results">
{/* SIMULATION : STICKY BAR */}
Expand Down Expand Up @@ -203,7 +219,7 @@ const SimulationResults = ({
trainSimulation={trainSimulation}
selectedTrainPowerRestrictions={selectedTrainPowerRestrictions}
rollingStock={selectedTrainRollingStock}
pathProperties={pathProperties}
pathProperties={updatedPathProperties}
heightOfSpeedSpaceChartContainer={speedSpaceChartContainerHeight}
setHeightOfSpeedSpaceChartContainer={setSpeedSpaceChartContainerHeight}
/>
Expand Down
3 changes: 0 additions & 3 deletions front/src/modules/pathfinding/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,4 @@ export const isVia = (
{ withKP = false } = {}
) => vias.some((via) => pathStepMatchesOp(via, op, withKP));

export const isStation = (chCode: string): boolean =>
chCode === 'BV' || chCode === '00' || chCode === '';

export const isPathStepInvalid = (step: PathStep | null): boolean => step?.isInvalid || false;
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const ManchetteWithSpaceTimeChartWrapper = ({
position: waypoint.position,
name: waypoint.extensions?.identifier?.name,
secondaryCode: waypoint.extensions?.sncf?.ch,
weight: waypoint.weight ?? 0,
}));
}, [waypointsPanelData, operationalPoints]);

Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where it comes from, but there is a white screen if we try to switch to linear mode in the manchette

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
type TrainScheduleResult,
} from 'common/api/osrdEditoastApi';
import { useOsrdConfSelectors } from 'common/osrdContext';
import { isStation } from 'modules/pathfinding/utils';

const useGetProjectedTrainOperationalPoints = (
trainScheduleUsedForProjection?: TrainScheduleResult,
Expand Down Expand Up @@ -76,12 +75,6 @@ const useGetProjectedTrainOperationalPoints = (
operationalPointsWithUniqueIds = JSON.parse(stringifiedSavedWaypoints) as NonNullable<
PathProperties['operational_points']
>;
} else {
// If the manchette hasn't been saved, we want to display by default only
// the waypoints with CH BV/00/'' and the ones added by map click
operationalPointsWithUniqueIds = operationalPointsWithUniqueIds.filter((op) =>
op.extensions?.sncf ? isStation(op.extensions.sncf.ch) : true
);
}
setFilteredOperationalPoints(operationalPointsWithUniqueIds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { formatData } from './helpers';
export type SpeedSpaceChartContainerProps = {
trainSimulation: SimulationResponseSuccess;
selectedTrainPowerRestrictions?: LayerData<PowerRestrictionValues>[];
pathProperties: PathPropertiesFormatted;
pathProperties?: PathPropertiesFormatted;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think it makes sense to have a speed space chart without path properties

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I fixed it

heightOfSpeedSpaceChartContainer: number;
rollingStock: RollingStockWithLiveries;
setHeightOfSpeedSpaceChartContainer: React.Dispatch<React.SetStateAction<number>>;
Expand Down
Loading