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-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * </p>
17   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
18   * initial version Dec 31, 2015 <br>
19   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
20   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
21   */
22  public class NextSplitInfo implements Serializable
23  {
24      /** */
25      private static final long serialVersionUID = 20151231L;
26  
27      /** If the route splits, at what node does it split? */
28      private final Node nextSplitNode;
29  
30      /** Required direction. */
31      private final LateralDirectionality requiredDirection;
32  
33      /**
34       * If the route splits, what are the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered
35       * that lead us in the direction of the route provided by the strategical planner.
36       */
37      private final Set<Lane> correctCurrentLanes;
38  
39      /**
40       * @param nextSplitNode Node; the first subsequent node at which the route splits.
41       * @param correctCurrentLanes Set&lt;Lane&gt;; the lane(s) and/or adjacent lane(s) on which the reference point of the GTU
42       *            is registered that lead us in the direction of the route provided by the strategical planner.
43       */
44      public NextSplitInfo(final Node nextSplitNode, final Set<Lane> correctCurrentLanes)
45      {
46          this(nextSplitNode, correctCurrentLanes, null);
47      }
48  
49      /**
50       * @param nextSplitNode Node; the first subsequent node at which the route splits.
51       * @param correctCurrentLanes Set&lt;Lane&gt;; the lane(s) and/or adjacent lane(s) on which the reference point of the GTU
52       *            is registered that lead us in the direction of the route provided by the strategical planner.
53       * @param requiredDirection LateralDirectionality; required direction for lane changes for this split, beyond lane on
54       *            current link
55       */
56      public NextSplitInfo(final Node nextSplitNode, final Set<Lane> correctCurrentLanes,
57              final LateralDirectionality requiredDirection)
58      {
59          this.nextSplitNode = nextSplitNode;
60          this.correctCurrentLanes = correctCurrentLanes;
61          this.requiredDirection = requiredDirection;
62      }
63  
64      /**
65       * @return split indicates whether the route splits within the given distance.
66       */
67      public final boolean isSplit()
68      {
69          return this.nextSplitNode != null;
70      }
71  
72      /**
73       * @return nextSplitNode the first subsequent node at which the route splits.
74       */
75      public final Node getNextSplitNode()
76      {
77          return this.nextSplitNode;
78      }
79  
80      /**
81       * @return correctCurrentLanes the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered
82       *         that lead us in the direction of the route provided by the strategical planner.
83       */
84      public final Set<Lane> getCorrectCurrentLanes()
85      {
86          return this.correctCurrentLanes;
87      }
88  
89      /**
90       * @return requiredDirection.
91       */
92      public final LateralDirectionality getRequiredDirection()
93      {
94          return this.requiredDirection;
95      }
96  
97      /** {@inheritDoc} */
98      @Override
99      public final String toString()
100     {
101         return "NextSplitInfo [nextSplitNode=" + this.nextSplitNode + ", correctCurrentLanes=" + this.correctCurrentLanes
102                 + ", requiredDirection=" + this.requiredDirection + "]";
103     }
104 }