Skip to content

Commit

Permalink
front: cleanup op format functions in scenarios
Browse files Browse the repository at this point in the history
Signed-off-by: Alice Khoudli <[email protected]>
  • Loading branch information
Synar committed Nov 28, 2024
1 parent 782fe85 commit 29d6244
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions front/src/modules/pathfinding/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import getStepLocation from './helpers/getStepLocation';

export const formatSuggestedOperationalPoints = (
operationalPoints: NonNullable<Required<PathProperties['operational_points']>>,
geometry?: GeoJsonLineString,
pathLength?: number
geometry: GeoJsonLineString,
pathLength: number
): SuggestedOP[] =>
operationalPoints.map((op) => ({
opId: op.id,
Expand All @@ -33,11 +33,7 @@ export const formatSuggestedOperationalPoints = (
offsetOnTrack: op.part.position,
track: op.part.track,
positionOnPath: op.position,
coordinates:
(geometry !== undefined &&
pathLength !== undefined &&
getPointCoordinates(geometry, pathLength, op.position)) ||
undefined,
coordinates: getPointCoordinates(geometry, pathLength, op.position),
}));

export const matchPathStepAndOp = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ const getTimeAndSpeed = (
* on their positions if they match or interpolate its time if they don't
* @returns the computed operational points for each simulation (base and finalOutput)
*/
export const formatOperationalPoints = async (
export const formatOperationalPoints = (
operationalPoints: PathPropertiesFormatted['operationalPoints'],
simulatedTrain: SimulationResponseSuccess,
train: TrainScheduleBase,
trackSections: Record<string, TrackSection>
): Promise<OperationalPointWithTimeAndSpeed[]> => {
): OperationalPointWithTimeAndSpeed[] => {
// Format operational points
const formattedStops: OperationalPointWithTimeAndSpeed[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const useFormattedOperationalPoints = (

const trackIds = pathProperties.operationalPoints.map((op) => op.part.track);
const trackSections = await getTrackSectionsByIds(trackIds);
const formattedOperationalPoints = await formatOperationalPoints(
const formattedOperationalPoints = formatOperationalPoints(
pathProperties.operationalPoints,
simulatedTrain,
train,
Expand Down

0 comments on commit 29d6244

Please sign in to comment.