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

Add CI/CH/UIC codes next to station names #6180

Merged
merged 1 commit into from
Dec 22, 2023
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
13 changes: 13 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,9 @@ components:
type: object
PathWaypoint:
properties:
ch:
nullable: true
type: string
duration:
format: double
type: number
Expand All @@ -1317,6 +1320,10 @@ components:
$ref: '#/components/schemas/GeoJsonPoint'
suggestion:
type: boolean
uic:
format: int64
nullable: true
type: integer
required:
- id
- name
Expand All @@ -1326,6 +1333,8 @@ components:
- suggestion
- geo
- sch
- uic
- ch
type: object
PathfindingPayload:
description: |-
Expand Down Expand Up @@ -1748,6 +1757,9 @@ components:
type: object
ResultStops:
properties:
ch:
nullable: true
type: string
duration:
format: double
type: number
Expand All @@ -1761,6 +1773,7 @@ components:
- time
- position
- duration
- ch
type: object
RjsPowerRestrictionRange:
description: A range along the train path where a power restriction is applied.
Expand Down
2 changes: 2 additions & 0 deletions editoast/src/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,13 @@ pub mod tests {
time: 0.0,
duration: 0.0,
position: 0.0,
ch: None,
},
ResultStops {
time: 110.90135448736316,
duration: 1.0,
position: 2417.6350658673214,
ch: None,
},
],
head_positions: vec![ResultPosition {
Expand Down
4 changes: 4 additions & 0 deletions editoast/src/models/pathfinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ pub struct PathWaypoint {
))]
#[schema(value_type = GeoJsonPoint)]
pub sch: geojson::Geometry,
#[schema(required)]
pub uic: Option<i64>,
#[schema(required)]
pub ch: Option<String>,
}

impl Pathfinding {
Expand Down
2 changes: 2 additions & 0 deletions editoast/src/models/train_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ pub struct ResultStops {
pub time: f64,
pub position: f64,
pub duration: f64,
#[schema(required)]
pub ch: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default, ToSchema)]
Expand Down
22 changes: 15 additions & 7 deletions editoast/src/views/pathfinding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,18 @@ impl Pathfinding {
} else {
steps_duration.next().unwrap()
};
let op_name = waypoint
.id
.as_ref()
.map(|op_id| op_map.get(op_id).expect("unexpected OP id"))
.and_then(|op| op.extensions.identifier.as_ref())
.map(|ident| ident.name.as_ref().to_owned());
let op_info = waypoint.id.as_ref().map(|op_id| {
let op = op_map.get(op_id).expect("unexpected OP id");
let name = op
.extensions
.identifier
.as_ref()
.map(|ident| ident.name.as_ref().to_owned());
let uic = op.extensions.identifier.as_ref().map(|ident| ident.uic);
let ch = op.extensions.sncf.as_ref().map(|sncf| sncf.ch.to_owned());
(name, uic, ch)
});
let (name, uic, ch) = op_info.unwrap_or_default();
let track = track_map
.get(&waypoint.location.track_section.0)
.expect("unexpected track id");
Expand All @@ -397,13 +403,15 @@ impl Pathfinding {
let sch = geos::geojson::Geometry::try_from(sch).unwrap();
PathWaypoint {
id: waypoint.id.clone(),
name: op_name,
name,
location: waypoint.location.clone(),
duration,
path_offset: waypoint.path_offset,
suggestion: waypoint.suggestion,
geo,
sch,
uic,
ch,
}
})
.collect();
Expand Down
2 changes: 2 additions & 0 deletions editoast/src/views/train_schedule/simulation_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ async fn add_stops_additional_information(
time: s.time,
position: s.position,
duration: s.duration,
ch: pw.ch.clone(),
},
id: pw.id.clone(),
name: pw.name.clone(),
Expand All @@ -286,6 +287,7 @@ async fn add_stops_additional_information(
time: s.time,
position: s.position,
duration: s.duration,
ch: pw.ch.clone(),
},
..Default::default()
},
Expand Down
2 changes: 2 additions & 0 deletions front/src/applications/operationalStudies/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export interface PointOnMap {
track?: string;
position?: number;
path_offset?: number;
uic?: number | null;
ch?: string | null;
location?: {
track_section?: string;
offset?: number;
Expand Down
9 changes: 4 additions & 5 deletions front/src/common/StationCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { formatUicToCi } from 'utils/strings';

export interface ImportStation {
trigram?: string;
Expand Down Expand Up @@ -33,17 +34,15 @@ export default function StationCard({ station, onClick, fixedHeight = false }: P
>
<div className="station-card-head">
<span className="station-card-code">{trigram}</span>
<span className="station-card-name">{name}</span>
{yardname && !yardNamesToExclude.includes(yardname) && (
<span className="station-card-ch">{yardname}</span>
)}
<span className="station-card-name">{name}&nbsp;</span>
{yardname && !yardNamesToExclude.includes(yardname) && <small>{yardname}</small>}
{uic && <span className="station-card-uic ml-3">{formatUicToCi(uic)}</span>}
</div>
<div className="station-card-localization">
<span className="station-card-city">{town}</span>
<span className="station-card-department">{department}</span>
{department && region && <div className="station-card-separator">/</div>}
<span className="station-card-region">{region}</span>
<span className="station-card-uic">{uic}</span>
</div>
{linename && (
<div className="station-card-footer">
Expand Down
3 changes: 3 additions & 0 deletions front/src/common/api/osrdEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,7 @@ export type GeoJsonPoint = {
type: 'Point';
};
export type PathWaypoint = {
ch: string | null;
duration: number;
geo: GeoJsonPoint;
id: string | null;
Expand All @@ -1650,6 +1651,7 @@ export type PathWaypoint = {
path_offset: number;
sch: GeoJsonPoint;
suggestion: boolean;
uic: number | null;
};
export type PathResponse = {
created: string;
Expand Down Expand Up @@ -2200,6 +2202,7 @@ export type ResultSpeed = {
time: number;
};
export type ResultStops = {
ch: string | null;
duration: number;
position: number;
time: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export default function DriverTrainScheduleStop({ stop, idx, train }: Props) {
<td className="d-flex justify-content-center">
<div>{Number.isInteger(pk) ? `${pk}.0` : pk}</div>
</td>
<td>{stop.name || 'Unknown'}</td>
<td>
{stop.name || 'Unknown'}&nbsp;
<small>{stop.ch}</small>
</td>
<td className="stoptime-container">
<div className="box">
<div className="box-row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PathWaypoint, TrainScheduleBatchItem } from 'common/api/osrdEditoastApi
import { time2sec } from 'utils/timeManipulation';

// Hope for indexes are the same !
// Synchronisation is done with indexes between pathfinding not suggered positions, and required steps from importation
// Synchronisation is done with indexes between pathfinding not suggested positions, and required steps from importation
function mixPathPositionsAndTimes(requiredSteps: Step[], pathFindingWaypoints: PathWaypoint[]) {
const startTime = new Date(requiredSteps[0].departureTime);
const pathFindingStepsFiltered = pathFindingWaypoints.filter((waypoint) => !waypoint.suggestion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export default function AllowancesModalOP({
key={waypoint.path_offset}
>
<div className="col-6">{waypoint.path_offset}</div>
<div className="col-6">{waypoint.name}</div>
<div className="col-6">
{waypoint.name}&nbsp;
{waypoint.ch === '00' || !waypoint.ch ? 'BV' : `${waypoint.ch}`}
</div>
</button>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import cx from 'classnames';
import { AnyAction, ThunkAction } from '@reduxjs/toolkit';
import { Position } from 'geojson';
import { RootState } from 'reducers';
import { formatUicToCi } from 'utils/strings';

type InputStopTimeProps = {
index: number;
Expand Down Expand Up @@ -99,6 +100,10 @@ export default function DisplayVias({ zoomToFeaturePoint }: DisplayViasProps) {
`KM ${place.position && Math.round(place.position) / 1000}`
}`}
</small>
<small className="">{place.ch}</small>
{place.uic && (
<small className="text-muted ml-3">{formatUicToCi(place.uic)}</small>
)}
</div>
{index !== indexSelected && (
<div className="default-durations-button mr-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { ModalContext } from 'common/BootstrapSNCF/ModalSNCF/ModalProvider';
import { Spinner } from 'common/Loader';
import type { ArrayElement } from 'utils/types';
import type { PathResponse, PathWaypoint } from 'common/api/osrdEditoastApi';
import { formatUicToCi } from 'utils/strings';
import cx from 'classnames';

type Props = {
removeAllVias: () => void;
Expand Down Expand Up @@ -65,32 +67,37 @@ export default function ModalSugerredVias({ removeAllVias, pathfindingInProgress

const formatVia = (via: ArrayElement<PathResponse['steps']>, idx: number, idxTrueVia: number) => (
<div
key={`suggered-via-modal-${via.id}-${idx}`}
className={`d-flex align-items-center p-1 ${via.suggestion && 'suggerred-via-clickable'}`}
key={`suggested-via-modal-${via.id}-${idx}`}
className={cx('d-flex align-items-center p-1', via.suggestion && 'suggested-via-clickable')}
title={via.name!}
>
{!via.suggestion && <small className="pr-2">{idxTrueVia}</small>}
<i className={`${via.suggestion ? 'text-muted' : 'text-info'} icons-itinerary-bullet mr-2`} />
{via.name || ''}
<small className="ml-2">
{via.path_offset && `KM ${Math.round(via.path_offset) / 1000}`}
</small>
{via.suggestion && via.id && !selectedViasTracks.includes(via.id) ? (
<button
className="btn btn-sm btn-only-icon ml-auto"
type="button"
onClick={() => convertPathfindingVias(suggeredVias, idx - 1)}
>
<GoPlus />
</button>
) : (
<button
className="btn btn-sm btn-only-icon ml-auto bg-dark"
type="button"
onClick={() => removeViaFromPath(via)}
>
<GoDash color="white" />
</button>
)}
<span className="suggested-via-name">{via.name || ''}</span>&nbsp;
<span>{via.ch}</span>
{via.uic && <small className="text-muted ml-3">{formatUicToCi(via.uic)}</small>}
<div className="ml-auto">
{via.path_offset && (
<small className="mr-2">{`KM ${Math.round(via.path_offset) / 1000}`}</small>
)}
{via.suggestion && via.id && !selectedViasTracks.includes(via.id) ? (
<button
className="btn btn-sm btn-only-icon"
type="button"
onClick={() => convertPathfindingVias(suggeredVias, idx - 1)}
>
<GoPlus />
</button>
) : (
<button
className="btn btn-sm btn-only-icon bg-dark"
type="button"
onClick={() => removeViaFromPath(via)}
>
<GoDash color="white" />
</button>
)}
</div>
</div>
);

Expand All @@ -104,7 +111,7 @@ export default function ModalSugerredVias({ removeAllVias, pathfindingInProgress
</button>
</ModalHeaderSNCF>
<ModalBodySNCF>
<div className="suggered-vias">
<div className="suggested-vias">
{pathfindingInProgress && <LoaderPathfindingInProgress />}
{suggeredVias &&
suggeredVias.map((via, idx) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}

.manage-vias-modal {
.suggered-vias {
.suggested-vias {
max-height: 30vh;
overflow-y: auto;
.loaderPathfindingInProgress {
Expand All @@ -48,11 +48,20 @@
border-radius: 0 0 4px 4px;
background-color: rgba(242, 242, 242, 0.75);
}
.suggerred-via-clickable {
cursor: pointer;
border-radius: 4px;
&:hover {
background-color: var(--coolgray1);
.suggested-via {
&-clickable {
cursor: pointer;
border-radius: 4px;
&:hover {
background-color: var(--coolgray1);
}
}

&-name {
max-width: 47%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export default function commonConfBuilder() {
type: 'Point',
},
suggestion: true,
ch: null,
uic: null,
},
],
}),
Expand Down
1 change: 1 addition & 0 deletions front/src/reducers/osrdsimulation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface Stop {
track_number: number | null;
line_name: string | null;
track_name: string | null;
ch?: string | null;
}

export interface RouteAspect<Time = number, Color = number> {
Expand Down
Loading