Class LazyLoadingRoadPosition
java.lang.Object
org.eclipse.mosaic.lib.routing.database.LazyLoadingRoadPosition
- All Implemented Interfaces:
Serializable
,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 Summary
ConstructorsConstructorDescriptionLazyLoadingRoadPosition
(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
Modifier and TypeMethodDescriptionboolean
Returns the connection the vehicle is currently driving on.Returns the ID of the connection the vehicle currently driving on.int
Returns the index of the lane, where 0 is the rightmost lane.double
Returns the lateral position of the vehicle on its current lane measured in m.double
Returns the distance (in m) from the start node of the road segment to the current position of the vehicle.Returns the previously traversed node.Returns the node which will be traversed next.int
hashCode()
-
Constructor Details
-
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
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 Details
-
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
Description copied from interface:IRoadPosition
Returns the previously traversed node.- Specified by:
getPreviousNode
in interfaceIRoadPosition
-
getUpcomingNode
Description copied from interface:IRoadPosition
Returns the node which will be traversed next.- Specified by:
getUpcomingNode
in interfaceIRoadPosition
-
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
-
hashCode
public int hashCode() -
equals
-