diff --git a/python/altrios/altrios_pyo3.pyi b/python/altrios/altrios_pyo3.pyi index 7bc623dc..edd895d2 100644 --- a/python/altrios/altrios_pyo3.pyi +++ b/python/altrios/altrios_pyo3.pyi @@ -968,6 +968,22 @@ class Link(SerdeAPI): def default(cls) -> Self: ... +class Elev(SerdeAPI): + offset_meters: float + elev_meters: float + @classmethod + def default(cls) -> Self: ... + + +class Heading(SerdeAPI): + offset_meters: float + heading: float + lat: Optional[float] + lon: Optional[float] + @classmethod + def default(cls) -> Self: ... + + def import_locations(filename: str) -> Dict[str, List[Location]]: ... def import_rail_vehicles(filename: str) -> Dict[str, RailVehicle]: ... diff --git a/rust/altrios-core/src/track/link/elev.rs b/rust/altrios-core/src/track/link/elev.rs index b563a02c..bcf6308c 100644 --- a/rust/altrios-core/src/track/link/elev.rs +++ b/rust/altrios-core/src/track/link/elev.rs @@ -2,12 +2,26 @@ use crate::imports::*; /// Struct containing elevation for a particular offset w.r.t. `Link` #[derive(Clone, Copy, Default, Debug, PartialEq, PartialOrd, Serialize, Deserialize, SerdeAPI)] -#[altrios_api] +#[altrios_api( + #[new] + fn __new__( + offset_meters: f64, + elev_meters: f64, + ) -> PyResult { + Ok(Self::new(offset_meters * uc::M, elev_meters * uc::M)) + } +)] pub struct Elev { pub offset: si::Length, pub elev: si::Length, } +impl Elev { + pub fn new(offset: si::Length, elev: si::Length) -> Self { + Self { offset, elev } + } +} + impl Valid for Elev {} impl ObjState for Elev {