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