pub trait RailwayGraphExt {
// Required methods
fn get_edge_by_id(&self, id: EdgeId) -> Option<RailwayEdge>;
fn get_node_by_id(&self, id: NodeId) -> Option<&RailwayNode>;
fn railway_edge(
&self,
start_node_id: NodeId,
end_node_id: NodeId
) -> Option<&RailwayEdge>;
fn get_edges_of_node(&self, node_id: NodeId) -> Vec<&RailwayEdge>;
fn bounding_box(&self) -> (Coord, Coord);
fn total_length(&self) -> f64;
fn nearest_node(
&self,
edge_id: EdgeId,
position_on_edge: f64,
current_node_id: Option<NodeId>
) -> Option<NodeId>;
}
Expand description
An extension trait for the RailwayGraph.
Required Methods§
sourcefn get_edge_by_id(&self, id: EdgeId) -> Option<RailwayEdge>
fn get_edge_by_id(&self, id: EdgeId) -> Option<RailwayEdge>
sourcefn get_node_by_id(&self, id: NodeId) -> Option<&RailwayNode>
fn get_node_by_id(&self, id: NodeId) -> Option<&RailwayNode>
Returns a reference to a RailwayNode with the specified NodeId if it exists in the graph.
This method searches the railway graph for a node with the given NodeId. If the node is found, it returns a reference to the RailwayNode. If the node is not found, it returns None.
Arguments
- id - The NodeId of the node to be retrieved from the railway graph.
Returns
An Option containing a reference to the RailwayNode if it exists, otherwise None.
sourcefn railway_edge(
&self,
start_node_id: NodeId,
end_node_id: NodeId
) -> Option<&RailwayEdge>
fn railway_edge( &self, start_node_id: NodeId, end_node_id: NodeId ) -> Option<&RailwayEdge>
sourcefn get_edges_of_node(&self, node_id: NodeId) -> Vec<&RailwayEdge>
fn get_edges_of_node(&self, node_id: NodeId) -> Vec<&RailwayEdge>
sourcefn bounding_box(&self) -> (Coord, Coord)
fn bounding_box(&self) -> (Coord, Coord)
Calculate the bounding box of the graph.
The bounding box is represented as a tuple containing the minimum and maximum latitude and longitude values of the nodes in the graph.
Returns
A tuple containing two Coordinate
structs representing the minimum and maximum coordinates
of the bounding box of the graph.
sourcefn total_length(&self) -> f64
fn total_length(&self) -> f64
Calculate the total length of the railway network.
The total length is the sum of the lengths of all edges in the graph.
Returns
A f64
value representing the total length of the railway network in meters.
sourcefn nearest_node(
&self,
edge_id: EdgeId,
position_on_edge: f64,
current_node_id: Option<NodeId>
) -> Option<NodeId>
fn nearest_node( &self, edge_id: EdgeId, position_on_edge: f64, current_node_id: Option<NodeId> ) -> Option<NodeId>
Returns the nearest node to the given position on the specified edge.
Arguments
edge_id
- The ID of the edge.position_on_edge
- The position on the edge, ranging from 0.0 to 1.0.current_node_id
- An optionalNodeId
of the current node to determine the start node.
Returns
An Option<NodeId>
containing the ID of the nearest node if found, or None
if the edge is not found.