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-2018 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 the first subsequent node at which the route splits.
41       * @param correctCurrentLanes the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered that
42       *            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 the first subsequent node at which the route splits.
51       * @param correctCurrentLanes the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered that
52       *            lead us in the direction of the route provided by the strategical planner.
53       * @param requiredDirection required direction for lane changes for this split, beyond lane on current link
54       */
55      public NextSplitInfo(final Node nextSplitNode, final Set<Lane> correctCurrentLanes,
56              final LateralDirectionality requiredDirection)
57      {
58          this.nextSplitNode = nextSplitNode;
59          this.correctCurrentLanes = correctCurrentLanes;
60          this.requiredDirection = requiredDirection;
61      }
62  
63      /**
64       * @return split indicates whether the route splits within the given distance.
65       */
66      public final boolean isSplit()
67      {
68          return this.nextSplitNode != null;
69      }
70  
71      /**
72       * @return nextSplitNode the first subsequent node at which the route splits.
73       */
74      public final Node getNextSplitNode()
75      {
76          return this.nextSplitNode;
77      }
78  
79      /**
80       * @return correctCurrentLanes the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered
81       *         that lead us in the direction of the route provided by the strategical planner.
82       */
83      public final Set<Lane> getCorrectCurrentLanes()
84      {
85          return this.correctCurrentLanes;
86      }
87  
88      /**
89       * @return requiredDirection.
90       */
91      public final LateralDirectionality getRequiredDirection()
92      {
93          return this.requiredDirection;
94      }
95  
96      /** {@inheritDoc} */
97      @Override
98      public final String toString()
99      {
100         return "NextSplitInfo [nextSplitNode=" + this.nextSplitNode + ", correctCurrentLanes=" + this.correctCurrentLanes
101                 + ", requiredDirection=" + this.requiredDirection + "]";
102     }
103 }