View Javadoc
1   package org.opentrafficsim.road.gtu.lane.plan.operational;
2   
3   import org.djunits.value.vdouble.scalar.Duration;
4   import org.opentrafficsim.base.geometry.OtsLine2d;
5   import org.opentrafficsim.core.gtu.plan.operational.OperationalPlan;
6   import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
7   import org.opentrafficsim.core.gtu.plan.operational.Segments;
8   import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
9   
10  /**
11   * An operational plan with some extra information about the lanes and lane changes so this information does not have to be
12   * recalculated multiple times. Furthermore, it is quite expensive to check whether a lane change is part of the oprtational
13   * plan based on geographical data.
14   * <p>
15   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
17   * </p>
18   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
20   */
21  public class LaneBasedOperationalPlan extends OperationalPlan
22  {
23      /** Deviative; meaning not along lane center lines. */
24      private final boolean deviative;
25  
26      /**
27       * Construct an operational plan with or without a lane change.
28       * @param gtu the GTU for debugging purposes
29       * @param path the path to follow from a certain time till a certain time. The path should have &lt;i&gt;at least&lt;/i&gt;
30       *            the length
31       * @param startTime the absolute start time when we start executing the path
32       * @param segments the segments that make up the path with an acceleration, constant speed or deceleration profile
33       * @param deviative whether the path is not along lane center lines
34       * @throws OperationalPlanException when the path is too short for the operation
35       */
36      @SuppressWarnings("checkstyle:parameternumber")
37      public LaneBasedOperationalPlan(final LaneBasedGtu gtu, final OtsLine2d path, final Duration startTime,
38              final Segments segments, final boolean deviative) throws OperationalPlanException
39      {
40          super(gtu, path, startTime, segments);
41          this.deviative = deviative;
42      }
43  
44      /**
45       * Check if we deviate from the center line.
46       * @return whether this maneuver involves deviation from the center line.
47       */
48      public final boolean isDeviative()
49      {
50          return this.deviative;
51      }
52  
53      @Override
54      public final String toString()
55      {
56          return "LaneBasedOperationalPlan [deviative=" + this.deviative + "]";
57      }
58  }