MTCT
Design Automation and Optimization for ETCS Railway Networks
Loading...
Searching...
No Matches
cda_rail::Route Class Reference

Ordered list of network edges that a train follows. More...

#include <Route.hpp>

Classes

struct  EdgePosition
 Start and end position of one edge within the route. More...

Public Member Functions

size_t size () const
 Gets the number of edges in the route.
double length (const Network &network) const
 Returns the total route length.
bool empty () const
 Checks whether the route is empty.
const cda_rail::index_vector & get_edges () const
 Provides the edges forming the route in travel order.
EdgePosition edge_pos_on_route (Network::EdgeInput const &edge, const Network &network) const
 Returns where a specific edge lies on this route.
EdgePosition edge_set_pos_on_route (const cda_rail::index_vector &edges_to_consider, const Network &network) const
 Returns one interval that covers all selected edges on the route.
std::optional< double > get_first_pos_on_edges (const cda_rail::index_set &edge_indices, const Network &network) const
 Returns where the first matching edge starts.
std::optional< double > get_last_pos_on_edges (const cda_rail::index_set &edge_indices, const Network &network) const
 Returns where the last matching edge ends.
size_t get_edge_id_at_pos (double pos, const Network &network) const
 Returns the edge that contains a given position on the route.
size_t get_edge_id (size_t route_index) const
 Returns the edge id at a given route position.
const Edge & get_edge (size_t route_index, const Network &network) const
 Returns the full edge object at a given route position.
const Edge & get_first_edge (const Network &network) const
 Returns the first edge in the route.
const Edge & get_last_edge (const Network &network) const
 Returns the last edge in the route.
bool contains_edge (size_t const edgeIndex) const
 Checks whether an edge id appears in this route.
bool contains_edge (Network::EdgeInput const &edge_input, const Network &network) const
 Checks whether a network edge appears in this route.
bool contains_edge (std::optional< size_t > const edgeIndex) const
 Determines if an optional edge id is present in this route.
void push_back_edge (Network::EdgeInput const &new_edge, const Network &network)
 Adds an edge at the end of the route.
void push_front_edge (Network::EdgeInput const &new_edge, const Network &network)
 Adds an edge at the beginning of the route.
void remove_first_edge ()
 Removes the first edge from the route.
void remove_last_edge ()
 Removes the last edge from the route.
bool check_consistency (const Network &network) const
 Checks whether the route is connected step by step.
void update_after_discretization (const std::vector< std::pair< size_t, cda_rail::index_vector > > &new_edges)
 Updates the route after edge splitting in the network.

Detailed Description

Ordered list of network edges that a train follows.

For a non-empty route, each next edge should be reachable from the previous one according to the network successor rules.

Member Function Documentation

◆ check_consistency()

bool cda_rail::Route::check_consistency ( const Network & network) const
nodiscard

Checks whether the route is connected step by step.

The route is consistent when every edge can directly continue to the next edge according to the network. Empty and single-edge routes are valid.

Parameters
networkNetwork used for successor checks.
Returns
true if all consecutive pairs are valid successors.
Exceptions
cda_rail::exceptions::EdgeNotExistentExceptionIf one of the checked route edges does not exist in network.

◆ contains_edge() [1/3]

bool cda_rail::Route::contains_edge ( Network::EdgeInput const & edge_input,
const Network & network ) const
inlinenodiscard

Checks whether a network edge appears in this route.

Parameters
edge_inputEdge input resolved via network.
networkNetwork used for descriptor resolution.
Returns
true if the resolved edge id is part of this route.
Exceptions
cda_rail::exceptions::EdgeNotExistentExceptionIf edge_input cannot be resolved to an existing edge.
cda_rail::exceptions::ConsistencyExceptionIf edge_input is an Edge object that mismatches the stored edge attributes.

◆ contains_edge() [2/3]

bool cda_rail::Route::contains_edge ( size_t const edgeIndex) const
inlinenodiscard

Checks whether an edge id appears in this route.

Parameters
edgeIndexThe edge id to search for.
Returns
true if the edge is part of this route, false otherwise.

◆ contains_edge() [3/3]

bool cda_rail::Route::contains_edge ( std::optional< size_t > const edgeIndex) const
inlinenodiscard

Determines if an optional edge id is present in this route.

Returns
true if edgeIndex holds a value and that edge id is in the route, false otherwise.

◆ edge_pos_on_route()

cda_rail::Route::EdgePosition cda_rail::Route::edge_pos_on_route ( Network::EdgeInput const & edge,
const Network & network ) const
nodiscard

Returns where a specific edge lies on this route.

Parameters
edgeEdge to look up.
networkNetwork used to resolve edge.
Returns
Position interval {source, target} in metres from route start.
Precondition
The resolved edge is contained in this route.
Exceptions
cda_rail::exceptions::EdgeNotExistentExceptionIf edge does not exist in network.
cda_rail::exceptions::ConsistencyExceptionIf the edge exists in network but is not part of this route.

◆ edge_set_pos_on_route()

cda_rail::Route::EdgePosition cda_rail::Route::edge_set_pos_on_route ( const cda_rail::index_vector & edges_to_consider,
const Network & network ) const
nodiscard

Returns one interval that covers all selected edges on the route.

The function takes the earliest start and latest end among all route edges whose id is listed in edges_to_consider.

Parameters
edges_to_considerEdge ids to include.
networkNetwork used to read edge lengths.
Returns
Position interval {source, target} in metres from route start.
Precondition
At least one edge from edges_to_consider occurs in this route.
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf no edge from edges_to_consider exists in this route.
cda_rail::exceptions::EdgeNotExistentExceptionIf this route contains an edge that does not exist in network.

◆ empty()

bool cda_rail::Route::empty ( ) const
inlinenodiscard

Checks whether the route is empty.

Returns
true if the route has no edges, false otherwise.

◆ get_edge()

const cda_rail::Edge & cda_rail::Route::get_edge ( size_t route_index,
const Network & network ) const
nodiscard

Returns the full edge object at a given route position.

Parameters
route_indexIndex into route order.
networkNetwork containing all route edges.
Returns
Const reference to the referenced Edge object.
Precondition
route_index < size().
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf route_index is out of range.
cda_rail::exceptions::EdgeNotExistentExceptionIf the referenced edge id is not present in network.

◆ get_edge_id()

size_t cda_rail::Route::get_edge_id ( size_t route_index) const
nodiscard

Returns the edge id at a given route position.

Parameters
route_indexIndex into route order.
Returns
Edge id stored at route_index.
Precondition
route_index < size().
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf route_index is out of range.

◆ get_edge_id_at_pos()

size_t cda_rail::Route::get_edge_id_at_pos ( double pos,
const Network & network ) const
nodiscard

Returns the edge that contains a given position on the route.

Parameters
posPosition in metres from route start.
networkNetwork used to read edge lengths.
Returns
Network edge id of the edge that contains pos.
Precondition
pos >= 0.
Exceptions
cda_rail::exceptions::InvalidInputExceptionIf pos is negative.
cda_rail::exceptions::ConsistencyExceptionIf pos lies outside the route interval [0, length(network)].
cda_rail::exceptions::EdgeNotExistentExceptionIf this route contains an edge that does not exist in network.

◆ get_edges()

const cda_rail::index_vector & cda_rail::Route::get_edges ( ) const
inlinenodiscard

Provides the edges forming the route in travel order.

Returns
A const reference to the route's edge indices.

◆ get_first_edge()

const Edge & cda_rail::Route::get_first_edge ( const Network & network) const
inlinenodiscard

Returns the first edge in the route.

Parameters
networkThe network containing edge information.
Returns
const Edge& A reference to the first edge.
Exceptions
InvalidInputExceptionIf the route is empty.
EdgeNotExistentExceptionIf the first edge's id does not exist in the network.

◆ get_first_pos_on_edges()

std::optional< double > cda_rail::Route::get_first_pos_on_edges ( const cda_rail::index_set & edge_indices,
const Network & network ) const
nodiscard

Returns where the first matching edge starts.

Parameters
edge_indicesEdge ids to search for.
networkNetwork used to read edge lengths.
Returns
Position (metres from route start) at the beginning of the first route edge contained in edge_indices, or std::nullopt if no such edge exists.
Exceptions
cda_rail::exceptions::EdgeNotExistentExceptionIf this route contains an edge that does not exist in network.

◆ get_last_edge()

const Edge & cda_rail::Route::get_last_edge ( const Network & network) const
inlinenodiscard

Returns the last edge in the route.

Returns
const Edge& The last edge in the route.
Exceptions
InvalidInputExceptionIf the route is empty.
EdgeNotExistentExceptionIf the last edge id is not in the network.

◆ get_last_pos_on_edges()

std::optional< double > cda_rail::Route::get_last_pos_on_edges ( const cda_rail::index_set & edge_indices,
const Network & network ) const
nodiscard

Returns where the last matching edge ends.

Parameters
edge_indicesEdge ids to search for.
networkNetwork used to read edge lengths.
Returns
Position (metres from route start) at the end of the last route edge contained in edge_indices, or std::nullopt if no such edge exists.
Exceptions
cda_rail::exceptions::EdgeNotExistentExceptionIf this route contains an edge that does not exist in network.

◆ length()

double cda_rail::Route::length ( const Network & network) const
nodiscard

Returns the total route length.

Parameters
networkNetwork containing all edges referenced by this route.
Returns
Sum of all route edge lengths in metres.
Exceptions
cda_rail::exceptions::EdgeNotExistentExceptionIf any referenced edge does not exist in network.

◆ push_back_edge()

void cda_rail::Route::push_back_edge ( Network::EdgeInput const & new_edge,
const Network & network )

Adds an edge at the end of the route.

If the route is not empty, the new edge must be a valid next edge of the current last edge.

Parameters
new_edgeEdge descriptor to append.
networkNetwork used to resolve and validate new_edge.
Exceptions
cda_rail::exceptions::EdgeNotExistentExceptionIf new_edge does not exist in network.
cda_rail::exceptions::ConsistencyExceptionIf the route is non-empty and new_edge is not a valid successor of the current last edge.

◆ push_front_edge()

void cda_rail::Route::push_front_edge ( Network::EdgeInput const & new_edge,
const Network & network )

Adds an edge at the beginning of the route.

If the route is not empty, the new edge must be a valid predecessor of the current first edge.

Parameters
new_edgeEdge descriptor to prepend.
networkNetwork used to resolve and validate new_edge.
Exceptions
cda_rail::exceptions::EdgeNotExistentExceptionIf new_edge does not exist in network.
cda_rail::exceptions::ConsistencyExceptionIf the route is non-empty and new_edge is not a valid predecessor of the current first edge.

◆ remove_first_edge()

void cda_rail::Route::remove_first_edge ( )

Removes the first edge from the route.

Precondition
!empty().
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf the route is empty.

◆ remove_last_edge()

void cda_rail::Route::remove_last_edge ( )

Removes the last edge from the route.

Precondition
!empty().
Exceptions
cda_rail::exceptions::ConsistencyExceptionIf the route is empty.

◆ size()

size_t cda_rail::Route::size ( ) const
inlinenodiscard

Gets the number of edges in the route.

Returns
The number of edges stored in the route.

◆ update_after_discretization()

void cda_rail::Route::update_after_discretization ( const std::vector< std::pair< size_t, cda_rail::index_vector > > & new_edges)

Updates the route after edge splitting in the network.

For each pair (old_edge, replacement_edges) in new_edges, every occurrence of old_edge is replaced by all edges in replacement_edges, keeping the original travel order.

Parameters
new_edgesMapping from original edge id to replacement edge sequence.

The documentation for this class was generated from the following files: