Struct survex_rs::station::StationManager
source · pub struct StationManager {
pub stations: Vec<Rc<RefCell<Station>>>,
pub graph: UnGraph<String, f64>,
}
Expand description
Handles the creation and management of stations, as well as the graph of stations.
Fields§
§stations: Vec<Rc<RefCell<Station>>>
§graph: UnGraph<String, f64>
Implementations§
source§impl StationManager
impl StationManager
sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty StationManager
with no stations or connections. This method should not
be used directly. Instead, create a StationManager
from a Survex file using the
read::load_from_path
helper function.
sourcepub fn get_by_label(&self, label: &str) -> Option<Rc<RefCell<Station>>>
pub fn get_by_label(&self, label: &str) -> Option<Rc<RefCell<Station>>>
Retrieve a reference to a Station
by its label.
sourcepub fn get_by_coords(&self, coords: &Point) -> Option<Rc<RefCell<Station>>>
pub fn get_by_coords(&self, coords: &Point) -> Option<Rc<RefCell<Station>>>
Retrieve a reference to a Station
by its coordinates. If multiple stations exist at the
given coordinates, the first station found is returned.
sourcepub fn add_or_update(
&mut self,
coords: Point,
label: &str
) -> (Rc<RefCell<Station>>, NodeIndex)
pub fn add_or_update( &mut self, coords: Point, label: &str ) -> (Rc<RefCell<Station>>, NodeIndex)
This helper method is used to add or update a Station
to both the stations vector and
the graph.
If a Station
with the given label already exists, the existing station is updated with
the new coordinates and the existing index is returned. Otherwise, a new Station
is
created and added to the stations vector and the graph, and the new index is returned.