1 package org.opentrafficsim.road.gtu.lane.plan.operational;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.djunits.value.vdouble.scalar.Duration;
7 import org.djunits.value.vdouble.scalar.Speed;
8 import org.djunits.value.vdouble.scalar.Time;
9 import org.opentrafficsim.core.geometry.OTSLine3D;
10 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlan;
11 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
12 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
13 import org.opentrafficsim.road.network.lane.Lane;
14
15 import nl.tudelft.simulation.language.d3.DirectedPoint;
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 public class LaneBasedOperationalPlan extends OperationalPlan
31 {
32
33 private static final long serialVersionUID = 20160120L;
34
35
36 private final List<Lane> referenceLaneList;
37
38
39 private final List<Lane> secondLaneList;
40
41 private final int lastLaneIndex;
42
43 private final double lastFractionalPosition;
44
45
46
47
48
49
50
51
52
53
54
55
56 public LaneBasedOperationalPlan(final LaneBasedGTU gtu, final OTSLine3D path, final Time startTime, final Speed startSpeed,
57 final List<Segment> operationalPlanSegmentList, final List<Lane> referenceLaneList) throws OperationalPlanException
58 {
59 super(gtu, path, startTime, startSpeed, operationalPlanSegmentList);
60 this.referenceLaneList = referenceLaneList;
61 this.secondLaneList = null;
62 this.lastLaneIndex = 0;
63 this.lastFractionalPosition = 0;
64 }
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 @SuppressWarnings("checkstyle:parameternumber")
81 public LaneBasedOperationalPlan(final LaneBasedGTU gtu, final OTSLine3D path, final Time startTime, final Speed startSpeed,
82 final List<Segment> operationalPlanSegmentList, final List<Lane> fromLaneList, final List<Lane> toLaneList,
83 final int lastLaneIndex, final double lastFractionalPosition) throws OperationalPlanException
84 {
85 super(gtu, path, startTime, startSpeed, operationalPlanSegmentList);
86 this.referenceLaneList = fromLaneList;
87 this.secondLaneList = toLaneList;
88 this.lastLaneIndex = lastLaneIndex;
89 this.lastFractionalPosition = lastFractionalPosition;
90 }
91
92
93
94
95
96
97
98
99
100
101 public LaneBasedOperationalPlan(final LaneBasedGTU gtu, final DirectedPoint waitPoint, final Time startTime,
102 final Duration duration, final Lane referenceLane) throws OperationalPlanException
103 {
104 super(gtu, waitPoint, startTime, duration);
105 this.referenceLaneList = new ArrayList<>();
106 this.referenceLaneList.add(referenceLane);
107 this.secondLaneList = null;
108 this.lastLaneIndex = 0;
109 this.lastFractionalPosition = 0;
110 }
111
112
113
114
115
116 public final boolean isDeviative()
117 {
118 return this.secondLaneList != null;
119 }
120
121
122
123
124 public final Lane getReferenceLane()
125 {
126 return this.referenceLaneList.get(0);
127 }
128
129
130
131
132 public final List<Lane> getReferenceLaneList()
133 {
134 return this.referenceLaneList;
135 }
136
137
138
139
140 public final List<Lane> getSecondLaneList()
141 {
142 return this.secondLaneList;
143 }
144
145
146
147
148 public final int getLastLaneIndex()
149 {
150 return this.lastLaneIndex;
151 }
152
153
154
155
156 public final double getLastFractionalPosition()
157 {
158 return this.lastFractionalPosition;
159 }
160
161
162 @Override
163 public final String toString()
164 {
165 return "LaneBasedOperationalPlan [referenceLaneList=" + this.referenceLaneList + ", secondLaneList="
166 + this.secondLaneList + "]";
167 }
168 }