Crate tp_lib_core

Crate tp_lib_core 

Source
Expand description

TP-Core: Train Positioning Library - Core Engine

This library provides geospatial projection of GNSS positions onto railway track netelements.

§Overview

TP-Core enables projection of GNSS (GPS) coordinates onto railway track centerlines (netelements), calculating precise measures along the track and assigning positions to specific track segments.

§Quick Start

use tp_core::{parse_gnss_csv, parse_network_geojson, RailwayNetwork, project_gnss, ProjectionConfig};

// Load railway network from GeoJSON
let netelements = parse_network_geojson("network.geojson")?;
let network = RailwayNetwork::new(netelements)?;

// Load GNSS positions from CSV
let positions = parse_gnss_csv("gnss.csv", "EPSG:4326", "latitude", "longitude", "timestamp")?;

// Project onto network with default configuration
let config = ProjectionConfig::default();
let projected = project_gnss(&positions, &network, &config)?;

// Use projected results
for pos in projected {
    println!("Position at measure {} on netelement {}", pos.measure_meters, pos.netelement_id);
}

§Features

  • Spatial Indexing: R-tree based spatial indexing for efficient nearest-netelement search
  • CRS Support: Explicit coordinate reference system handling with optional transformations
  • Timezone Awareness: RFC3339 timestamps with explicit timezone offsets
  • Multiple Formats: CSV and GeoJSON input/output support

Re-exports§

pub use errors::ProjectionError;
pub use io::parse_gnss_csv;
pub use io::parse_gnss_geojson;
pub use io::parse_network_geojson;
pub use io::write_csv;
pub use io::write_geojson;
pub use models::GnssPosition;
pub use models::Netelement;
pub use models::ProjectedPosition;

Modules§

crs
Coordinate Reference System transformations
errors
Error types for projection operations
io
Input/output module for CSV, GeoJSON, and Arrow formats
models
Data models for GNSS positioning and railway network
projection
Projection engine for GNSS positions onto railway netelements
temporal
Temporal utilities for timezone handling

Structs§

ProjectionConfig
Configuration for GNSS projection operations
RailwayNetwork
Railway network with spatial indexing for efficient projection

Functions§

project_gnss
Project GNSS positions onto railway network

Type Aliases§

Result
Result type alias using ProjectionError