View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical;
2   
3   import java.io.Serializable;
4   import java.util.ArrayList;
5   import java.util.List;
6   
7   import org.djunits.value.vdouble.scalar.Length;
8   import org.opentrafficsim.core.geometry.OtsLine3d;
9   import org.opentrafficsim.road.network.lane.Lane;
10  
11  /**
12   * This class provides the following information for an operational plan:
13   * <ul>
14   * <li>the lanes to follow, with the direction to drive on them</li>
15   * <li>the starting point on the first lane</li>
16   * <li>the path to follow when staying on the same lane</li>
17   * </ul>
18   * <p>
19   * Copyright (c) 2013-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
20   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
21   * </p>
22   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
23   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
24   */
25  public class LanePathInfo implements Serializable
26  {
27      /** */
28      private static final long serialVersionUID = 20151231L;
29  
30      /**
31       * The path it the GTU keeps driving in the same lane, and follows the route if possible in the same lane. The path stops
32       * when the lane or a continuation lane does not lead in the direction of the route provided by the strategical planner.
33       */
34      private final OtsLine3d path;
35  
36      /**
37       * The current lane on which the reference point of the GTU is registered (if the GTU is registered on multiple lanes with
38       * the reference point, one lane is chosen where the reference point has a fractional lane position between 0.0 and 1.0),
39       * and consecutive lanes that follow the route if possible in the same lane. The list of lanes stops when a continuation
40       * lane does not lead in the direction of the route provided by the strategical planner.
41       */
42      private final List<Lane> laneList;
43  
44      /**
45       * The start point on the first lane in the laneDirectionList. When this is a point that represents a GTU position, it
46       * should represent the reference point of the GTU.
47       */
48      private final Length referencePosition;
49  
50      /**
51       * @param path OtsLine3d; the path it the GTU keeps driving in the same lane, and follows the route if possible in the same
52       *            lane. The path stops when the lane or a continuation lane does not lead in the direction of the route provided
53       *            by the strategical planner.
54       * @param laneList List&lt;Lane&gt;; the current lane on which the reference point of the GTU is registered (if the GTU is
55       *            registered on multiple lanes with the reference point, one lane is chosen where the reference point has a
56       *            fractional lane position between 0.0 and 1.0), and consecutive lanes that follow the route if possible in the
57       *            same lane. The list of lanes stops when a continuation lane does not lead in the direction of the route
58       *            provided by the strategical planner.
59       * @param referencePosition Length; the start point on the first lane in the laneList. When this is a point that represents
60       *            a GTU position, it should represent the reference point of the GTU.
61       */
62      public LanePathInfo(final OtsLine3d path, final List<Lane> laneList, final Length referencePosition)
63      {
64          this.path = path;
65          this.laneList = laneList;
66          this.referencePosition = referencePosition;
67      }
68  
69      /**
70       * @return path the path it the GTU keeps driving in the same lane, and follows the route if possible in the same lane. The
71       *         path stops when the lane or a continuation lane does not lead in the direction of the route provided by the
72       *         strategical planner.
73       */
74      public final OtsLine3d getPath()
75      {
76          return this.path;
77      }
78  
79      /**
80       * @return laneList the current lane on which the reference point of the GTU is registered (if the GTU is registered on
81       *         multiple lanes with the reference point, one lane is chosen where the reference point has a fractional lane
82       *         position between 0.0 and 1.0), and consecutive lanes that follow the route if possible in the same lane. The list
83       *         of lanes stops when a continuation lane does not lead in the direction of the route provided by the strategical
84       *         planner. For each lane, the direction to drive is provided.
85       */
86      public final List<Lane> getLaneList()
87      {
88          return this.laneList;
89      }
90  
91      /**
92       * @return list of lanes
93       */
94      public final List<Lane> getLanes()
95      {
96          List<Lane> lanes = new ArrayList<>();
97          for (Lane lane : this.laneList)
98          {
99              lanes.add(lane);
100         }
101         return lanes;
102     }
103 
104     /**
105      * The reference lane is the widest lane on which the reference point of the GTU is fully registered.
106      * @return the reference lane on which the GTU is registered, or null if the GTU is not registered on any lane.
107      */
108     public final Lane getReferenceLane()
109     {
110         return this.laneList.isEmpty() ? null : this.laneList.get(0);
111     }
112 
113     /**
114      * @return the start point on the first lane in the laneDirectionList. When this is a point that represents a GTU position,
115      *         it should represent the reference point of the GTU.
116      */
117     public final Length getReferencePosition()
118     {
119         return this.referencePosition;
120     }
121 
122     /** {@inheritDoc} */
123     @Override
124     public final String toString()
125     {
126         return "LanePathInfo [path=" + this.path + ", laneDirectionList=" + this.laneList + ", referencePosition="
127                 + this.referencePosition + "]";
128     }
129 
130 }