pub struct TrainPath {
pub segments: Vec<AssociatedNetElement>,
pub overall_probability: f64,
pub calculated_at: Option<DateTime<Utc>>,
pub metadata: Option<PathMetadata>,
}Expand description
Represents a continuous train path through the rail network
A TrainPath is an ordered sequence of netelements (track segments) that the train traversed, calculated from GNSS coordinates and network topology.
§Examples
use tp_lib_core::{TrainPath, AssociatedNetElement};
use chrono::Utc;
let segments = vec![
AssociatedNetElement::new(
"NE_A".to_string(), 0.87, 0.0, 1.0, 0, 10
)?,
AssociatedNetElement::new(
"NE_B".to_string(), 0.92, 0.0, 1.0, 11, 18
)?,
];
let path = TrainPath::new(
segments,
0.89,
Some(Utc::now()),
None,
)?;
assert_eq!(path.segments.len(), 2);
assert_eq!(path.overall_probability, 0.89);Fields§
§segments: Vec<AssociatedNetElement>Ordered sequence of netelements in the path Order represents the direction of travel from first to last GNSS position
overall_probability: f64Overall probability score for this path (0.0 to 1.0) Calculated as length-weighted average of segment probabilities, averaged between forward and backward path calculations
calculated_at: Option<DateTime<Utc>>Timestamp when this path was calculated
metadata: Option<PathMetadata>Algorithm configuration metadata
Implementations§
Source§impl TrainPath
impl TrainPath
Sourcepub fn new(
segments: Vec<AssociatedNetElement>,
overall_probability: f64,
calculated_at: Option<DateTime<Utc>>,
metadata: Option<PathMetadata>,
) -> Result<Self, ProjectionError>
pub fn new( segments: Vec<AssociatedNetElement>, overall_probability: f64, calculated_at: Option<DateTime<Utc>>, metadata: Option<PathMetadata>, ) -> Result<Self, ProjectionError>
Create a new train path with validation
Sourcepub fn diagnostics(&self) -> PathDiagnosticInfo
pub fn diagnostics(&self) -> PathDiagnosticInfo
Build diagnostic info from the current segments (order, intrinsics, probabilities)
Sourcepub fn with_metadata(self, metadata: PathMetadata) -> Self
pub fn with_metadata(self, metadata: PathMetadata) -> Self
Attach metadata, auto-populating diagnostic info if not provided
Sourcepub fn total_fractional_length(&self) -> f64
pub fn total_fractional_length(&self) -> f64
Calculate total path length (sum of fractional lengths)
Sourcepub fn netelement_ids(&self) -> Vec<&str>
pub fn netelement_ids(&self) -> Vec<&str>
Get netelement IDs in traversal order
Sourcepub fn total_gnss_positions(&self) -> usize
pub fn total_gnss_positions(&self) -> usize
Total number of GNSS positions in path
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TrainPath
impl<'de> Deserialize<'de> for TrainPath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for TrainPath
impl RefUnwindSafe for TrainPath
impl Send for TrainPath
impl Sync for TrainPath
impl Unpin for TrainPath
impl UnsafeUnpin for TrainPath
impl UnwindSafe for TrainPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more