Expand description
Train path calculation module
This module provides probabilistic train path calculation through rail networks using GNSS data and network topology (netrelations).
§Overview
The path calculation algorithm:
- Identifies candidate netelements for each GNSS position
- Calculates probabilities based on distance and heading alignment
- Constructs paths bidirectionally (forward and backward)
- Validates path continuity and navigability
- Selects the highest probability path
§Examples
use tp_lib_core::{calculate_train_path, PathConfig, GnssPosition, Netelement, NetRelation};
let gnss_positions: Vec<GnssPosition> = vec![]; // Load GNSS data
let netelements: Vec<Netelement> = vec![]; // Load network
let netrelations: Vec<NetRelation> = vec![]; // Load topology
let config = PathConfig::default();
let result = calculate_train_path(
&gnss_positions,
&netelements,
&netrelations,
&config,
)?;
if result.path.is_some() {
println!("Path calculated successfully");
}Re-exports§
pub use debug::export_all_debug_info;pub use debug::export_gap_fills;pub use debug::export_hmm_candidate_netelements;pub use debug::export_hmm_emission_probabilities;pub use debug::export_hmm_selected_path;pub use debug::export_hmm_viterbi_trace;pub use debug::export_path_sanity_decisions;pub use graph::build_topology_graph;pub use graph::cached_shortest_path_distance;pub use graph::shortest_path_distance;pub use graph::shortest_path_route;pub use graph::validate_netrelation_references;pub use graph::NetelementSide;pub use graph::ShortestPathCache;pub use spacing::calculate_mean_spacing;pub use spacing::select_resampled_subset;pub use viterbi::build_path_from_viterbi;pub use viterbi::fill_path_gaps;pub use viterbi::viterbi_decode;pub use viterbi::GapFill;pub use viterbi::SanityDecision;pub use viterbi::ViterbiResult;pub use viterbi::ViterbiSubsequence;pub use PathCalculationMode::FallbackIndependent;pub use PathCalculationMode::TopologyBased;pub use candidate::*;pub use probability::*;
Modules§
- candidate
- Candidate netelement selection for GNSS positions
- debug
- Debug information export utilities for path calculation (US7)
- graph
- Network topology graph representation
- probability
- Probability calculation module
- spacing
- Spacing calculation for GNSS positions
- viterbi
- Log-space Viterbi algorithm for HMM-based map matching
Structs§
- Candidate
Info - Information about a single candidate netelement
- Candidate
Path - Information about a candidate path evaluated during calculation
- Debug
Info - Debug information for path calculation (US7: T153)
- Netelement
Probability Info - Probability information for a single netelement in the Viterbi result
- Path
Config - Configuration for train path calculation algorithm
- Path
Config Builder - Builder for PathConfig with fluent API and validation
- Path
Decision - A decision point in the Viterbi path decoding process
- Path
Result - Result of train path calculation
- Position
Candidates - Candidates considered for a single GNSS position
- Transition
Probability Entry - A single transition probability between two candidates at consecutive GNSS positions
Enums§
- Path
Calculation Mode - Path calculation mode indicating which algorithm was used
Functions§
- calculate_
train_ path - Calculate the most probable continuous train path through the network
- project_
onto_ path - Project GNSS coordinates onto a calculated train path (US2: T093-T097)