Class Connection

java.lang.Object
org.eclipse.mosaic.lib.database.road.Connection

public class Connection extends Object
This represents an abstraction layer on top of a Way. A connection is a directed part of a way that connects two intersection nodes.
  • Constructor Details

    • Connection

      public Connection(@Nonnull String id, @Nonnull Way way)
    • Connection

      public Connection(@Nonnull String id, @Nonnull Way way, boolean isBackward)
      Default constructor.
      Parameters:
      id - Unique identifier of the connection.
      way - Way represents a number of edges in the network graph.
      isBackward - if this connection represents the forward or backward direction of the way
  • Method Details

    • getId

      @Nonnull public String getId()
      Returns the ID of this connection.
      Returns:
      Unique identifier of the connection.
    • getWay

      @Nonnull public Way getWay()
      This returns the Way this connection belongs to.
      Returns:
      The way of the connection.
    • getFrom

      public Node getFrom()
      This returns the Node the connection starts from.
      Returns:
      Null if no from node exist, otherwise the node.
    • getTo

      public Node getTo()
      This returns the Node that the connections ends at.
      Returns:
      Null if no to node exist, otherwise the node.
    • getLanes

      public int getLanes()
      Returns the number of lanes this Connection presents.
      Returns:
      Number of the lanes.
    • getLength

      public double getLength()
      This connections length in meters.
      Returns:
      The length of the connection.
    • getMaxSpeedInKmh

      public double getMaxSpeedInKmh()
      Gets the maximum speed allowed on this connection in km/h.
      Returns:
      The speed in [km/h].
    • getMaxSpeedInMs

      public double getMaxSpeedInMs()
      Gets the maximum speed allowed on this connection in m/s.
      Returns:
      The speed in [m/s].
    • getNodes

      @Nonnull public List<Node> getNodes()
      These are the Nodes that are part of this connection. Beware that the order is important.
      Returns:
      List of Nodes representing a connection.
    • getOutgoingConnections

      @Nonnull public Collection<Connection> getOutgoingConnections()
      Returns the connections that are accessible through this one.
      Returns:
      List of accessible / upcoming connections.
    • getIncomingConnections

      @Nonnull public Collection<Connection> getIncomingConnections()
      Returns the list of connections that lead into this connection..
      Returns:
      List of incoming connections
    • setLength

      public Connection setLength(double length)
      Sets the connections length in meters.
      Parameters:
      length - Length to set.
    • setLanes

      public Connection setLanes(int lanes)
      Sets the number of lanes for this connection. This overrides eventual values copied from the Way.
      Parameters:
      lanes - Lanes to set.
    • addNode

      public void addNode(@Nonnull Node node)
      Adds a Node belonging to this connection. Be aware that the order of nodes is vital to the order of edges belonging to this connection.
      Parameters:
      node - Node to add.
    • addNodes

      public void addNodes(@Nonnull List<Node> node)
      Adds all given Nodes belonging to this connection. Be aware that the order of nodes is vital to the order of edges belonging to this connection.
      Parameters:
      node - Nodes to add.
    • addOutgoingConnection

      public void addOutgoingConnection(@Nonnull Connection connection)
      Adds a connection that is accessible through this one.
      Parameters:
      connection - Outgoing connection to add.
    • addIncomingConnection

      public void addIncomingConnection(@Nonnull Connection connection)
      Adds a connection through that this connection can be accessed.
      Parameters:
      connection - Incoming connection to add.
    • applyTurnRestriction

      public void applyTurnRestriction(@Nonnull Restriction.Type type, @Nonnull Connection target)
      This applies a turn restriction to the connection. Restrictions can be of type 'only' or 'not' which will cause the outgoing connections to be either trimmed down to the target or the target will be removed from the outgoing connections.
      Parameters:
      type - either 'only' or 'not'
      target - the connection