Skip to main content

Module path

Module path 

Source
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:

  1. Identifies candidate netelements for each GNSS position
  2. Calculates probabilities based on distance and heading alignment
  3. Constructs paths bidirectionally (forward and backward)
  4. Validates path continuity and navigability
  5. 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::validate_path_navigability;
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§

CandidateInfo
Information about a single candidate netelement
CandidatePath
Information about a candidate path evaluated during calculation
DebugInfo
Debug information for path calculation (US7: T153)
NetelementProbabilityInfo
Probability information for a single netelement in the Viterbi result
PathConfig
Configuration for train path calculation algorithm
PathConfigBuilder
Builder for PathConfig with fluent API and validation
PathDecision
A decision point in the Viterbi path decoding process
PathResult
Result of train path calculation
PositionCandidates
Candidates considered for a single GNSS position
TransitionProbabilityEntry
A single transition probability between two candidates at consecutive GNSS positions

Enums§

PathCalculationMode
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)