diff --git a/backend/backend/idfm_interface/idfm_interface.py b/backend/backend/idfm_interface/idfm_interface.py index b6bf4b7..7bcc734 100644 --- a/backend/backend/idfm_interface/idfm_interface.py +++ b/backend/backend/idfm_interface/idfm_interface.py @@ -31,6 +31,10 @@ class IdfmInterface: async def startup(self) -> None: ... + @staticmethod + def _format_line_id(line_id: str) -> int: + return int(line_id[1:] if line_id[0] == "C" else line_id) + async def render_line_picto(self, line: Line) -> tuple[None | str, None | str]: line_picto_path = line_picto_format = None target = f"/tmp/{line.id}_repr" @@ -81,7 +85,6 @@ class IdfmInterface: if (stop := await Stop.get_by_id(stop_id)) is not None: expected_stop_ids = {stop.id} - elif (stop_area := await StopArea.get_by_id(stop_id)) is not None: expected_stop_ids = {stop.id for stop in stop_area.stops} else: @@ -105,7 +108,8 @@ class IdfmInterface: if ( dst_names := journey.DestinationName ) and monitored_stop_id in expected_stop_ids: - line_id = journey.LineRef.value.split(":")[-2] + raw_line_id = journey.LineRef.value.split(":")[-2] + line_id = IdfmInterface._format_line_id(raw_line_id) destinations[line_id].add(dst_names[0].value) return destinations diff --git a/backend/backend/schemas/line.py b/backend/backend/schemas/line.py index 01feeed..69f29bc 100644 --- a/backend/backend/schemas/line.py +++ b/backend/backend/schemas/line.py @@ -53,8 +53,8 @@ class Line(BaseModel): transportMode: TransportMode backColorHexa: str foreColorHexa: str - operatorId: str + operatorId: int accessibility: IdfmState visualSignsAvailable: IdfmState audibleSignsAvailable: IdfmState - stopIds: list[str] + stopIds: list[int] diff --git a/backend/backend/schemas/stop.py b/backend/backend/schemas/stop.py index 2bd6f6e..78581ac 100644 --- a/backend/backend/schemas/stop.py +++ b/backend/backend/schemas/stop.py @@ -9,7 +9,7 @@ class Stop(BaseModel): town: str epsg3857_x: float epsg3857_y: float - lines: list[str] + lines: list[int] class StopArea(BaseModel): @@ -17,7 +17,7 @@ class StopArea(BaseModel): name: str town: str type: StopAreaType - lines: list[str] # SNCF lines are linked to stop areas and not stops. + lines: list[int] # SNCF lines are linked to stop areas and not stops. stops: list[Stop] diff --git a/frontend/src/types.tsx b/frontend/src/types.tsx index dd2da16..63d68d9 100644 --- a/frontend/src/types.tsx +++ b/frontend/src/types.tsx @@ -8,7 +8,7 @@ export enum TrafficStatus { export class Passage { line: number; - operator: string; + operator: number; destinations: string[]; atStop: boolean; aimedArrivalTs: number; @@ -19,7 +19,7 @@ export class Passage { arrivalStatus: string; departStatus: string; - constructor(line: number, operator: string, destinations: string[], atStop: boolean, aimedArrivalTs: number, + constructor(line: number, operator: number, destinations: string[], atStop: boolean, aimedArrivalTs: number, expectedArrivalTs: number, arrivalPlatformName: string, aimedDepartTs: number, expectedDepartTs: number, arrivalStatus: string, departStatus: string) { this.line = line; @@ -45,9 +45,9 @@ export class Stop { epsg3857_x: number; epsg3857_y: number; stops: Stop[]; - lines: string[]; + lines: number[]; - constructor(id: number, name: string, town: string, epsg3857_x: number, epsg3857_y: number, stops: Stop[], lines: string[]) { + constructor(id: number, name: string, town: string, epsg3857_x: number, epsg3857_y: number, stops: Stop[], lines: number[]) { this.id = id; this.name = name; this.town = town; @@ -82,7 +82,7 @@ export class StopShape { export type StopShapes = Record; export class Line { - id: string; + id: number; shortName: string; name: string; status: string; // TODO: Use an enum @@ -95,7 +95,7 @@ export class Line { audibleSignsAvailable: string; // TODO: Use an enum stopIds: number[]; - constructor(id: string, shortName: string, name: string, status: string, transportMode: string, backColorHexa: string, + constructor(id: number, shortName: string, name: string, status: string, transportMode: string, backColorHexa: string, foreColorHexa: string, operatorId: number, accessibility: boolean, visualSignsAvailable: string, audibleSignsAvailable: string, stopIds: number[]) { this.id = id;