View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical;
2   
3   import java.io.Serializable;
4   import java.util.Set;
5   
6   import org.opentrafficsim.core.network.LateralDirectionality;
7   import org.opentrafficsim.core.network.Node;
8   import org.opentrafficsim.road.network.lane.Lane;
9   
10  /**
11   * This class provides information for an operational plan about the next location where the network splits. if the networks
12   * splits, the node where it splits, and the current lanes that lead to the right node are calculated.
13   * <p>
14   * Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * </p>
17   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
18   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
19   */
20  public class NextSplitInfo implements Serializable
21  {
22      /** */
23      private static final long serialVersionUID = 20151231L;
24  
25      /** If the route splits, at what node does it split? */
26      private final Node nextSplitNode;
27  
28      /** Required direction. */
29      private final LateralDirectionality requiredDirection;
30  
31      /**
32       * If the route splits, what are the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered
33       * that lead us in the direction of the route provided by the strategical planner.
34       */
35      private final Set<Lane> correctCurrentLanes;
36  
37      /**
38       * @param nextSplitNode Node; the first subsequent node at which the route splits.
39       * @param correctCurrentLanes Set&lt;Lane&gt;; the lane(s) and/or adjacent lane(s) on which the reference point of the GTU
40       *            is registered that lead us in the direction of the route provided by the strategical planner.
41       */
42      public NextSplitInfo(final Node nextSplitNode, final Set<Lane> correctCurrentLanes)
43      {
44          this(nextSplitNode, correctCurrentLanes, null);
45      }
46  
47      /**
48       * @param nextSplitNode Node; the first subsequent node at which the route splits.
49       * @param correctCurrentLanes Set&lt;Lane&gt;; the lane(s) and/or adjacent lane(s) on which the reference point of the GTU
50       *            is registered that lead us in the direction of the route provided by the strategical planner.
51       * @param requiredDirection LateralDirectionality; required direction for lane changes for this split, beyond lane on
52       *            current link
53       */
54      public NextSplitInfo(final Node nextSplitNode, final Set<Lane> correctCurrentLanes,
55              final LateralDirectionality requiredDirection)
56      {
57          this.nextSplitNode = nextSplitNode;
58          this.correctCurrentLanes = correctCurrentLanes;
59          this.requiredDirection = requiredDirection;
60      }
61  
62      /**
63       * @return split indicates whether the route splits within the given distance.
64       */
65      public final boolean isSplit()
66      {
67          return this.nextSplitNode != null;
68      }
69  
70      /**
71       * @return nextSplitNode the first subsequent node at which the route splits.
72       */
73      public final Node getNextSplitNode()
74      {
75          return this.nextSplitNode;
76      }
77  
78      /**
79       * @return correctCurrentLanes the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered
80       *         that lead us in the direction of the route provided by the strategical planner.
81       */
82      public final Set<Lane> getCorrectCurrentLanes()
83      {
84          return this.correctCurrentLanes;
85      }
86  
87      /**
88       * @return requiredDirection.
89       */
90      public final LateralDirectionality getRequiredDirection()
91      {
92          return this.requiredDirection;
93      }
94  
95      /** {@inheritDoc} */
96      @Override
97      public final String toString()
98      {
99          return "NextSplitInfo [nextSplitNode=" + this.nextSplitNode + ", correctCurrentLanes=" + this.correctCurrentLanes
100                 + ", requiredDirection=" + this.requiredDirection + "]";
101     }
102 }