View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical;
2   
3   import java.io.Serializable;
4   import java.util.List;
5   
6   import org.djunits.value.vdouble.scalar.Length;
7   import org.opentrafficsim.core.geometry.OTSLine3D;
8   import org.opentrafficsim.road.network.lane.Lane;
9   import org.opentrafficsim.road.network.lane.LaneDirection;
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-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
20   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
21   * </p>
22   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
23   * initial version Dec 31, 2015 <br>
24   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
25   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
26   */
27  public class LanePathInfo implements Serializable
28  {
29      /** */
30      private static final long serialVersionUID = 20151231L;
31  
32      /**
33       * The path it the GTU keeps driving in the same lane, and follows the route if possible in the same lane. The path stops
34       * when the lane or a continuation lane does not lead in the direction of the route provided by the strategical planner.
35       */
36      private final OTSLine3D path;
37  
38      /**
39       * The current lane on which the reference point of the GTU is registered (if the GTU is registered on multiple lanes with
40       * the reference point, one lane is chosen where the reference point has a fractional lane position between 0.0 and 1.0),
41       * and consecutive lanes that follow the route if possible in the same lane. The list of lanes stops when a continuation
42       * lane does not lead in the direction of the route provided by the strategical planner. For each lane, the direction to
43       * drive is provided.
44       */
45      private final List<LaneDirection> laneDirectionList;
46  
47      /**
48       * The start point on the first lane in the laneDirectionList. When this is a point that represents a GTU position, it
49       * should represent the reference point of the GTU.
50       */
51      private final Length.Rel referencePosition;
52  
53      /**
54       * @param path the path it the GTU keeps driving in the same lane, and follows the route if possible in the same lane. The
55       *            path stops when the lane or a continuation lane does not lead in the direction of the route provided by the
56       *            strategical planner.
57       * @param laneDirectionList the current lane on which the reference point of the GTU is registered (if the GTU is registered
58       *            on multiple lanes with the reference point, one lane is chosen where the reference point has a fractional lane
59       *            position between 0.0 and 1.0), and consecutive lanes that follow the route if possible in the same lane. The
60       *            list of lanes stops when a continuation lane does not lead in the direction of the route provided by the
61       *            strategical planner. For each lane, the direction to drive is provided.
62       * @param referencePosition the start point on the first lane in the laneDirectionList. When this is a point that represents
63       *            a GTU position, it should represent the reference point of the GTU.
64       */
65      public LanePathInfo(final OTSLine3D path, final List<LaneDirection> laneDirectionList, final Length.Rel referencePosition)
66      {
67          super();
68          this.path = path;
69          this.laneDirectionList = laneDirectionList;
70          this.referencePosition = referencePosition;
71      }
72  
73      /**
74       * @return path the path it the GTU keeps driving in the same lane, and follows the route if possible in the same lane. The
75       *         path stops when the lane or a continuation lane does not lead in the direction of the route provided by the
76       *         strategical planner.
77       */
78      public final OTSLine3D getPath()
79      {
80          return this.path;
81      }
82  
83      /**
84       * @return laneList the current lane on which the reference point of the GTU is registered (if the GTU is registered on
85       *         multiple lanes with the reference point, one lane is chosen where the reference point has a fractional lane
86       *         position between 0.0 and 1.0), and consecutive lanes that follow the route if possible in the same lane. The list
87       *         of lanes stops when a continuation lane does not lead in the direction of the route provided by the strategical
88       *         planner. For each lane, the direction to drive is provided.
89       */
90      public final List<LaneDirection> getLaneDirectionList()
91      {
92          return this.laneDirectionList;
93      }
94  
95      /**
96       * The reference lane is the widest lane on which the reference point of the GTU is fully registered.
97       * @return the reference lane on which the GTU is registered, plus the driving direction on this lane, or null if the GTU is
98       *         not registered on any lane.
99       */
100     public final LaneDirection getReferenceLaneDirection()
101     {
102         return this.laneDirectionList.isEmpty() ? null : this.laneDirectionList.get(0);
103     }
104 
105     /**
106      * The reference lane is the widest lane on which the reference point of the GTU is fully registered.
107      * @return the reference lane on which the GTU is registered, or null if the GTU is not registered on any lane.
108      */
109     public final Lane getReferenceLane()
110     {
111         return this.laneDirectionList.isEmpty() ? null : this.laneDirectionList.get(0).getLane();
112     }
113 
114     /**
115      * @return the start point on the first lane in the laneDirectionList. When this is a point that represents a GTU position,
116      *         it should represent the reference point of the GTU.
117      */
118     public final Length.Rel getReferencePosition()
119     {
120         return this.referencePosition;
121     }
122 
123 }