Struct survex_rs::data::SurveyData
source · pub struct SurveyData {
pub stations: Stations,
pub graph: StationGraph,
}
Expand description
Handles the creation and management of stations, as well as holding the
graph
of stations.
Fields§
§stations: Stations
§graph: StationGraph
Implementations§
source§impl SurveyData
impl SurveyData
sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty SurveyData
instance with no stations or connections. This method should
not be used directly. Instead, create a SurveyData
instance from a Survex file using the
load_from_path
helper function.
sourcepub fn get_by_label(&self, label: &str) -> Option<RefStation>
pub fn get_by_label(&self, label: &str) -> Option<RefStation>
Retrieve a reference to a Station
by its label. Only exact matches are returned. To
retrieve a station by partial label use
get_by_label_part
.
sourcepub fn get_by_label_part(&self, label: &str) -> Option<RefStation>
pub fn get_by_label_part(&self, label: &str) -> Option<RefStation>
sourcepub fn get_by_coords(&self, coords: &Point) -> Option<RefStation>
pub fn get_by_coords(&self, coords: &Point) -> Option<RefStation>
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 get_by_index(&self, index: NodeIndex) -> Option<RefStation>
pub fn get_by_index(&self, index: NodeIndex) -> Option<RefStation>
Retrieve a reference to a Station
by its index in the graph.
sourcepub fn add_or_update(
&mut self,
coords: Point,
label: &str
) -> (RefStation, NodeIndex)
pub fn add_or_update( &mut self, coords: Point, label: &str ) -> (RefStation, 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. Otherwise, a new Station
is created and added to the stations
vector and the graph. In either case, a reference to the station is returned in a tuple
along with the index of the station in the graph.
Trait Implementations§
source§impl Default for SurveyData
impl Default for SurveyData
source§fn default() -> Self
fn default() -> Self
Returns an empty SurveyData
instance with no stations.