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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LazyLoadingRoadPosition(IRoadPosition currentRoadPosition, Database database)
Creates anIRoadPosition
object which provides further values taken from the givenDatabase
, based on the givenIRoadPosition
which only provides little information.LazyLoadingRoadPosition(LazyLoadingConnection connection, LazyLoadingNode previousNode, LazyLoadingNode upcomingNode, double roadOffset)
Creates anIRoadPosition
with all required information provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
LazyLoadingConnection
getConnection()
Returns the connection the vehicle is currently driving on.String
getConnectionId()
Returns the ID of the connection the vehicle currently driving on.int
getLaneIndex()
Returns the index of the lane, where 0 is the rightmost lane.double
getLateralLanePosition()
Returns the lateral position of the vehicle on its current lane measured in m.double
getOffset()
Returns the distance (in m) from the start node of the road segment to the current position of the vehicle.INode
getPreviousNode()
Returns the previously traversed node.INode
getUpcomingNode()
Returns the node which will be traversed next.int
hashCode()
-
-
-
Constructor Detail
-
LazyLoadingRoadPosition
public LazyLoadingRoadPosition(LazyLoadingConnection connection, LazyLoadingNode previousNode, LazyLoadingNode upcomingNode, double roadOffset)
Creates anIRoadPosition
with all required information provided.- Parameters:
connection
- the connection this road position can be found onpreviousNode
- the previous node which is part of the given connection and lies behind this road positionupcomingNode
- the upcoming node which is part of the given connection and lies in front of this road positionroadOffset
- the distance in meters from the previous node to the exact road position
-
LazyLoadingRoadPosition
public LazyLoadingRoadPosition(IRoadPosition currentRoadPosition, Database database)
Creates anIRoadPosition
object which provides further values taken from the givenDatabase
, based on the givenIRoadPosition
which only provides little information.- Parameters:
currentRoadPosition
- theIRoadPosition
which only contains little information, such as upcoming and previous node idsdatabase
- a reference to the scenarioDatabase
which is used to obtain missing information
-
-
Method Detail
-
getConnectionId
public String getConnectionId()
Description copied from interface:IRoadPosition
Returns the ID of the connection the vehicle currently driving on.- Specified by:
getConnectionId
in interfaceIRoadPosition
-
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 interfaceIRoadPosition
-
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 interfaceIRoadPosition
-
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 interfaceIRoadPosition
-
getPreviousNode
public INode getPreviousNode()
Description copied from interface:IRoadPosition
Returns the previously traversed node.- Specified by:
getPreviousNode
in interfaceIRoadPosition
-
getUpcomingNode
public INode getUpcomingNode()
Description copied from interface:IRoadPosition
Returns the node which will be traversed next.- Specified by:
getUpcomingNode
in interfaceIRoadPosition
-
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 interfaceIRoadPosition
-
-