pub struct RailwayNetwork { /* private fields */ }Expand description
Railway network with spatial indexing for efficient projection
The RailwayNetwork wraps netelements with an R-tree spatial index for O(log n)
nearest-neighbor searches, enabling efficient projection of large GNSS datasets.
§Examples
use tp_core::{parse_network_geojson, RailwayNetwork};
// Load netelements from GeoJSON
let netelements = parse_network_geojson("network.geojson")?;
// Build spatial index
let network = RailwayNetwork::new(netelements)?;
// Query netelements
println!("Network has {} netelements", network.netelements().len());Implementations§
Source§impl RailwayNetwork
impl RailwayNetwork
Sourcepub fn new(netelements: Vec<Netelement>) -> Result<Self>
pub fn new(netelements: Vec<Netelement>) -> Result<Self>
Create a new railway network from netelements
Builds an R-tree spatial index for efficient nearest-neighbor queries.
§Arguments
netelements- Vector of railway track segments with LineString geometries
§Returns
Ok(RailwayNetwork)- Successfully indexed networkErr(ProjectionError)- If netelements are empty or geometries are invalid
§Examples
use tp_core::{Netelement, RailwayNetwork};
use geo::LineString;
let netelements = vec![
Netelement {
id: "NE001".to_string(),
geometry: LineString::from(vec![(4.35, 50.85), (4.36, 50.86)]),
crs: "EPSG:4326".to_string(),
},
];
let network = RailwayNetwork::new(netelements)?;Sourcepub fn get_by_index(&self, index: usize) -> Option<&Netelement>
pub fn get_by_index(&self, index: usize) -> Option<&Netelement>
Sourcepub fn netelements(&self) -> &[Netelement]
pub fn netelements(&self) -> &[Netelement]
Get all netelements
Returns a slice containing all netelements in the network.
Sourcepub fn netelement_count(&self) -> usize
pub fn netelement_count(&self) -> usize
Get the number of netelements in the network
Returns the total count of railway track segments indexed in this network.
Auto Trait Implementations§
impl Freeze for RailwayNetwork
impl RefUnwindSafe for RailwayNetwork
impl Send for RailwayNetwork
impl Sync for RailwayNetwork
impl Unpin for RailwayNetwork
impl UnwindSafe for RailwayNetwork
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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