Description
Suggested refactoring
Add to the class Nodes
the property connected_edges
containing the connected edges. This will replace the property connected_nodes
. To keep reading access of connected_nodes
somehow, calculate the connected nodes based on the connected_edges
and use a @property
decorator.
Do the same with connected_on_left
, connected_on_right
and connected_on_head
and set_connection_left
, set_connection_right
and set_connection_head
.
Therefore, every writing access of connected_edges
and call of set_connection_left
, set_connection_right
, and set_connection_head
has to be refactored.
Affected repositories are
- https://github.com/simulate-digital-rail/orm-importer
- https://github.com/simulate-digital-rail/planpro-importer
- https://github.com/simulate-digital-rail/cli-importer
- https://github.com/simulate-digital-rail/interlocking-exporter
- https://github.com/simulate-digital-rail/track-signal-generator
Advantage of refactoring
With this refactoring, we can identify "Abstellgleise", because we have two different connected edges instead of the same connected node.
Additionally, we can improve calc_anschluss_of_all_nodes. Currently, this function calculates the angles between three edges with their top nodes. This leads to failures if the edge is very long and straight.
Acceptance criterion
- Add
connected_edges
- Replace
connected_nodes
with function and@property
decorator - Add
connected_edge_on_left
,connected_edge_on_right
andconnected_edge_on_head
property with type Edge - Use
connected_edge_on_left
,connected_edge_on_right
andconnected_edge_on_head
inset_connection_left
,set_connection_right
,set_connection_head
. - Use
connected_edges
inset_connection_left
,set_connection_right
andset_connection_head
- Replace
connected_on_left
,connected_on_right
andconnected_on_head
with function and@property
decorator - Add function to
Edge
given a top node of the edge, get the opposite one. - Add function to
Edge
given a top node of the edge, get the nearest geo node