Class RailDestination

java.lang.Object
com.amalgamasimulation.trains.RailDestination

public class RailDestination extends Object
Class representing a combination of a specific graph position and information about which side of the train should arrive at the destination. A position can point to point on graph arc at certain offset from arc's beginning only. Pointing to a node is not allowed. If it is specified that the train should end with its tail, then the train will pass through the specified position and stop when its tail is at the specified position if there is enough space on the specified arch for this, otherwise an exception will be thrown.
Author:
Andrey Korotin
  • Constructor Details

    • RailDestination

      public RailDestination(GeometricGraphPosition<RailNode,RailArc> geometricGraphPosition, TrainsEnvironment.TrainDirection movementEndTrainDirection)
      Creates a new instance of the rail destination by the specified GeometricGraphPosition and information about which side of the train should arrive at the destination.
      Parameters:
      geometricGraphPosition - specified position
      movementEndTrainDirection - which side of the train should arrive at the destination
    • RailDestination

      public RailDestination(GeometricGraphPosition<RailNode,RailArc> geometricGraphPosition)
      Creates a new instance of the rail destination by the specified GeometricGraphPosition. The train direction (i.e. whether train's head or tail should arrive first) is not specified.
      Parameters:
      geometricGraphPosition - specified position
  • Method Details

    • of

      public static RailDestination of(GeometricGraphPosition<RailNode,RailArc> geometricGraphPosition, TrainsEnvironment.TrainDirection movementEndTrainDirection)
      Creates a new instance of the rail destination by the specified GeometricGraphPosition and information about which side of the train should arrive at the destination.
      Parameters:
      geometricGraphPosition - specified position
      movementEndTrainDirection - which side of the train should arrive at the destination
    • of

      public static RailDestination of(GeometricGraphPosition<RailNode,RailArc> geometricGraphPosition)
      Creates a new instance of the rail destination by the specified GeometricGraphPosition. The train direction (i.e. whether train's head or tail should arrive first) is not specified.
      Parameters:
      geometricGraphPosition - specified position
    • of

      public static RailDestination of(Graph<RailNode,RailArc>.Arc arc, double arcAbsOffset, TrainsEnvironment.TrainDirection movementEndTrainDirection)
      Creates a new instance of the rail destination by the specified GeometricGraphPosition and information about which side of the train should arrive at the destination.
      Parameters:
      arc - specified arc, must not be null
      arcAbsOffset - specified absolute offset on the arc
      movementEndTrainDirection - which side of the train should arrive at the destination
    • of

      public static RailDestination of(Graph<RailNode,RailArc>.Arc arc, double arcAbsOffset)
      Creates a new instance of the rail destination by the specified arc and offset. The train direction (i.e. whether train's head or tail should arrive first) is not specified.
      Parameters:
      arc - specified arc, must not be null
      arcAbsOffset - specified absolute offset on the arc
    • getGeometricGraphPosition

      public GeometricGraphPosition<RailNode,RailArc> getGeometricGraphPosition(double trainLength)
      Returns an instance of GeometricGraphPosition which represents this position in the underlying rail graph considering which side of the train should arrive at the destination.
      Parameters:
      trainLength - train length
      Returns:
      instance of GeometricGraphPosition which represents this position in the underlying rail graph considering which side of the train should arrive at the destination
      See Also:
    • getMovementEndTrainDirection

      public TrainsEnvironment.TrainDirection getMovementEndTrainDirection()
      Return the side of the train should arrive at the destination
      Returns:
      the side of the train should arrive at the destination
    • getTrack

      public RailTrack getTrack()
      Returns the track which this position points to.
      Returns:
      track which this position points to
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object