Class LazyLoadingRoadPosition

java.lang.Object
org.eclipse.mosaic.lib.routing.database.LazyLoadingRoadPosition
All Implemented Interfaces:
Serializable, IRoadPosition

public class LazyLoadingRoadPosition extends Object implements IRoadPosition

Provides information about a road position. All missing information is gathered lazy by requesting the scenario-database as soon as the respective getter method is called. Those information is cached for later calls of the same method by storing the respective items from the scenario-database.

Note, a minimum knowledge about the road position is always needed:

  • Previous node (id) and upcoming node (id), or
  • Connection (id) and previous node (id)

For example, if the connection and the previous node is given, the upcoming node is calculated as soon as the method getUpcomingNode() is called. The information gathered is then being cached in case the method is called again.

See Also:
  • Constructor Details

    • LazyLoadingRoadPosition

      public LazyLoadingRoadPosition(LazyLoadingConnection connection, LazyLoadingNode previousNode, LazyLoadingNode upcomingNode, double roadOffset)
      Creates an IRoadPosition with all required information provided.
      Parameters:
      connection - the connection this road position can be found on
      previousNode - the previous node which is part of the given connection and lies behind this road position
      upcomingNode - the upcoming node which is part of the given connection and lies in front of this road position
      roadOffset - the distance in meters from the previous node to the exact road position
    • LazyLoadingRoadPosition

      public LazyLoadingRoadPosition(IRoadPosition currentRoadPosition, Database database)
      Creates an IRoadPosition object which provides further values taken from the given Database, based on the given IRoadPosition which only provides little information.
      Parameters:
      currentRoadPosition - the IRoadPosition which only contains little information, such as upcoming and previous node ids
      database - a reference to the scenario Database which is used to obtain missing information
  • Method Details

    • getConnectionId

      public String getConnectionId()
      Description copied from interface: IRoadPosition
      Returns the ID of the connection the vehicle currently driving on.
      Specified by:
      getConnectionId in interface IRoadPosition
    • getLaneIndex

      public int getLaneIndex()
      Description copied from interface: IRoadPosition
      Returns the index of the lane, where 0 is the rightmost lane.
      Specified by:
      getLaneIndex in interface IRoadPosition
    • getLateralLanePosition

      public double getLateralLanePosition()
      Description copied from interface: IRoadPosition
      Returns the lateral position of the vehicle on its current lane measured in m.
      Specified by:
      getLateralLanePosition in interface IRoadPosition
    • getOffset

      public double getOffset()
      Description copied from interface: IRoadPosition
      Returns the distance (in m) from the start node of the road segment to the current position of the vehicle.
      Specified by:
      getOffset in interface IRoadPosition
    • getPreviousNode

      public INode getPreviousNode()
      Description copied from interface: IRoadPosition
      Returns the previously traversed node.
      Specified by:
      getPreviousNode in interface IRoadPosition
    • getUpcomingNode

      public INode getUpcomingNode()
      Description copied from interface: IRoadPosition
      Returns the node which will be traversed next.
      Specified by:
      getUpcomingNode in interface IRoadPosition
    • getConnection

      public LazyLoadingConnection getConnection()
      Description copied from interface: IRoadPosition
      Returns the connection the vehicle is currently driving on. A connection is defined as a link between two junctions. Returns the connection the vehicle is currently on.
      Specified by:
      getConnection in interface IRoadPosition
    • hashCode

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

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