From 4d9dddafe5ba417fba1f9e7cb10a4802fe386b4c Mon Sep 17 00:00:00 2001 From: hamz2a Date: Fri, 12 Apr 2024 13:10:04 +0200 Subject: [PATCH] editoast: move TrackLocation to editoast_schemas --- editoast/editoast_schemas/src/infra.rs | 3 +++ .../src/infra/track_location.rs | 18 ++++++++++++++++++ editoast/src/core/pathfinding.rs | 2 +- editoast/src/core/simulation.rs | 2 +- editoast/src/models/pathfinding.rs | 2 +- editoast/src/schema/mod.rs | 11 ----------- 6 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 editoast/editoast_schemas/src/infra/track_location.rs diff --git a/editoast/editoast_schemas/src/infra.rs b/editoast/editoast_schemas/src/infra.rs index 798b660a845..004994ac548 100644 --- a/editoast/editoast_schemas/src/infra.rs +++ b/editoast/editoast_schemas/src/infra.rs @@ -1,9 +1,11 @@ mod direction; +mod track_location; mod track_offset; mod track_range; mod waypoint; pub use direction::Direction; +pub use track_location::TrackLocation; pub use track_offset::TrackOffset; pub use track_range::TrackRange; pub use waypoint::Waypoint; @@ -11,4 +13,5 @@ pub use waypoint::Waypoint; editoast_common::schemas! { track_offset::schemas(), direction::schemas(), + track_location::schemas(), } diff --git a/editoast/editoast_schemas/src/infra/track_location.rs b/editoast/editoast_schemas/src/infra/track_location.rs new file mode 100644 index 00000000000..0f7f0764dc5 --- /dev/null +++ b/editoast/editoast_schemas/src/infra/track_location.rs @@ -0,0 +1,18 @@ +use editoast_common::Identifier; +use serde::Deserialize; +use serde::Serialize; +use utoipa::ToSchema; + +editoast_common::schemas! { + TrackLocation, +} + +/// A track location is a track section and an offset +#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, ToSchema)] +pub struct TrackLocation { + /// The track section UUID + #[schema(inline)] + pub track_section: Identifier, + /// The offset on the track section in meters + pub offset: f64, +} diff --git a/editoast/src/core/pathfinding.rs b/editoast/src/core/pathfinding.rs index 315704523b4..bc779ade358 100644 --- a/editoast/src/core/pathfinding.rs +++ b/editoast/src/core/pathfinding.rs @@ -10,8 +10,8 @@ use super::Json; use crate::models::CurveGraph; use crate::models::RoutePath; use crate::models::SlopeGraph; -use crate::schema::TrackLocation; use editoast_schemas::infra::Direction; +use editoast_schemas::infra::TrackLocation; pub type PathfindingWaypoints = Vec>; diff --git a/editoast/src/core/simulation.rs b/editoast/src/core/simulation.rs index 499711d9e81..46db5d1f5f7 100644 --- a/editoast/src/core/simulation.rs +++ b/editoast/src/core/simulation.rs @@ -19,7 +19,7 @@ use crate::models::RoutePath; use crate::models::ScheduledPoint; use crate::models::SignalSighting; use crate::models::ZoneUpdate; -use crate::schema::TrackLocation; +use editoast_schemas::infra::TrackLocation; editoast_common::schemas! { SignalUpdate, diff --git a/editoast/src/models/pathfinding.rs b/editoast/src/models/pathfinding.rs index bded6d98451..2c1abce12c4 100644 --- a/editoast/src/models/pathfinding.rs +++ b/editoast/src/models/pathfinding.rs @@ -18,9 +18,9 @@ use utoipa::ToSchema; use crate::models::Identifiable; use crate::schema::DirectionalTrackRange; -use crate::schema::TrackLocation; use crate::tables::pathfinding; use editoast_schemas::infra::Direction; +use editoast_schemas::infra::TrackLocation; editoast_common::schemas! { Slope, diff --git a/editoast/src/schema/mod.rs b/editoast/src/schema/mod.rs index b8a0af5377f..9053e332811 100644 --- a/editoast/src/schema/mod.rs +++ b/editoast/src/schema/mod.rs @@ -72,7 +72,6 @@ use editoast_common::Identifier; use editoast_common::NonBlankString; editoast_common::schemas! { - TrackLocation, DirectionalTrackRange, utils::schemas(), editoast_schemas::schemas(), @@ -229,13 +228,3 @@ pub struct Sign { pub value: String, pub kp: String, } - -/// A track location is a track section and an offset -#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, ToSchema)] -pub struct TrackLocation { - /// The track section UUID - #[schema(inline)] - pub track_section: Identifier, - /// The offset on the track section in meters - pub offset: f64, -}