Class Conflict
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.core.object.StaticObject
org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject
org.opentrafficsim.road.network.lane.conflict.Conflict
- All Implemented Interfaces:
Serializable
,Remote
,EventListener
,Locatable
,org.djutils.event.EventListener
,org.djutils.event.EventProducer
,org.opentrafficsim.base.Identifiable
,Drawable
,LocatedObject
,LaneBasedObject
public final class Conflict
extends AbstractLaneBasedObject
implements org.djutils.event.EventListener
Conflicts deal with traffic on different links/roads that need to consider each other as their paths may be in conflict
spatially. A single
This class provides easy access to upstream and downstream GTUs through
Conflict
represents the one-sided consideration of a conflicting situation. I.e., what is
considered a single conflict in traffic theory, is represented by two Conflict
s, one on each of the
conflicting Lane
s.This class provides easy access to upstream and downstream GTUs through
PerceptionIterable
s using methods
getUpstreamGtus
and getDownstreamGtus
. These methods are efficient in that they reuse underlying data
structures if the GTUs are requested at the same time by another GTU.
Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Light-weight lane based object to indicate the end of a conflict. -
Field Summary
Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
generateConflictPair
(ConflictType conflictType, ConflictRule conflictRule, boolean permitted, Lane lane1, Length longitudinalPosition1, Length length1, OtsLine3d geometry1, Lane lane2, Length longitudinalPosition2, Length length2, OtsLine3d geometry2, OtsSimulatorInterface simulator) Creates a pair of conflicts.getDownstreamGtus
(LaneBasedGtu perceivingGtu, HeadwayGtuType headwayGtuType, Length visibility) Provides the downstream GTUs.getTrafficLightDistance
(Length maxDistance) Returns the distance to an upstream traffic light.getUpstreamGtus
(LaneBasedGtu perceivingGtu, HeadwayGtuType headwayGtuType, Length visibility) Provides the upstream GTUs.double
getZ()
boolean
If permitted, traffic upstream of traffic lights may not be ignored, as these can have green light.void
notify
(org.djutils.event.Event event) toString()
Methods inherited from class org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject
getFullId, getLane, getLocation, getLongitudinalPosition, init
Methods inherited from class org.opentrafficsim.core.object.StaticObject
create, create, getBounds, getGeometry, getHeight, getId
Methods inherited from class org.djutils.event.LocalEventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
Methods inherited from interface org.opentrafficsim.base.Identifiable
getId
Methods inherited from interface org.opentrafficsim.road.network.lane.object.LaneBasedObject
getBounds
Methods inherited from interface org.opentrafficsim.core.object.LocatedObject
getGeometry, getHeight
-
Method Details
-
getUpstreamGtus
public PerceptionCollectable<HeadwayGtu,LaneBasedGtu> getUpstreamGtus(LaneBasedGtu perceivingGtu, HeadwayGtuType headwayGtuType, Length visibility) Provides the upstream GTUs.- Parameters:
perceivingGtu
- LaneBasedGtu; perceiving GTUheadwayGtuType
- HeadwayGtuType; headway GTU type to usevisibility
- Length; distance over which GTU's are provided- Returns:
- PerceptionIterable<HeadwayGtU>; iterable over the upstream GTUs
-
getDownstreamGtus
public PerceptionCollectable<HeadwayGtu,LaneBasedGtu> getDownstreamGtus(LaneBasedGtu perceivingGtu, HeadwayGtuType headwayGtuType, Length visibility) Provides the downstream GTUs.- Parameters:
perceivingGtu
- LaneBasedGtu; perceiving GTUheadwayGtuType
- HeadwayGtuType; headway GTU type to usevisibility
- Length; distance over which GTU's are provided- Returns:
- PerceptionIterable<HeadwayGtU>; iterable over the downstream GTUs
-
notify
- Specified by:
notify
in interfaceorg.djutils.event.EventListener
- Throws:
RemoteException
-
getConflictType
- Returns:
- conflictType.
-
getConflictRule
- Returns:
- conflictRule.
-
conflictPriority
- Returns:
- conflictPriority.
-
getLength
- Returns:
- length.
-
getOtherConflict
- Returns:
- otherConflict.
-
isPermitted
public boolean isPermitted()If permitted, traffic upstream of traffic lights may not be ignored, as these can have green light.- Returns:
- permitted.
-
getTrafficLightDistance
Returns the distance to an upstream traffic light.- Parameters:
maxDistance
- Length; maximum distance of traffic light- Returns:
- Length; distance to upstream traffic light, infinite if beyond maximum distance
-
generateConflictPair
public static void generateConflictPair(ConflictType conflictType, ConflictRule conflictRule, boolean permitted, Lane lane1, Length longitudinalPosition1, Length length1, OtsLine3d geometry1, Lane lane2, Length longitudinalPosition2, Length length2, OtsLine3d geometry2, OtsSimulatorInterface simulator) throws NetworkException Creates a pair of conflicts.- Parameters:
conflictType
- ConflictType; conflict type, i.e. crossing, merge or splitconflictRule
- ConflictRule; conflict rulepermitted
- boolean; whether the conflict is permitted in traffic light controllane1
- Lane; lane of conflict 1longitudinalPosition1
- Length; longitudinal position of conflict 1length1
- Length;Length
of conflict 1geometry1
- OtsLine3d; geometry of conflict 1lane2
- Lane; lane of conflict 2longitudinalPosition2
- Length; longitudinal position of conflict 2length2
- Length;Length
of conflict 2geometry2
- OtsLine3d; geometry of conflict 2simulator
- OtsSimulatorInterface; the simulator for animation and timed events- Throws:
NetworkException
- if the combination of conflict type and both conflict rules is not correct
-
getZ
- Specified by:
getZ
in interfaceLocatable
- Throws:
RemoteException
-
toString
- Overrides:
toString
in classAbstractLaneBasedObject
-