1 package org.opentrafficsim.road.gtu.lane;
2
3 import org.djunits.value.vdouble.scalar.Length;
4 import org.djunits.value.vdouble.scalar.Speed;
5 import org.opentrafficsim.core.dsol.OTSSimulatorInterface;
6 import org.opentrafficsim.core.gtu.GTUException;
7 import org.opentrafficsim.core.gtu.GTUType;
8 import org.opentrafficsim.core.network.OTSNetwork;
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public abstract class AbstractLaneBasedIndividualGTU extends AbstractLaneBasedGTU
23 {
24
25 private static final long serialVersionUID = 20140822L;
26
27
28 private final Length length;
29
30
31 private final Length width;
32
33
34 private final Speed maximumSpeed;
35
36
37 private Length noLaneChangeDistance;
38
39
40
41
42
43
44
45
46
47
48
49
50 @SuppressWarnings("checkstyle:parameternumber")
51 public AbstractLaneBasedIndividualGTU(final String id, final GTUType gtuType, final Length length, final Length width,
52 final Speed maximumSpeed, final OTSSimulatorInterface simulator, final OTSNetwork network) throws GTUException
53 {
54 super(id, gtuType, simulator, network);
55 this.length = length;
56 this.width = width;
57 if (null == maximumSpeed)
58 {
59 throw new GTUException("maximumSpeed may not be null");
60 }
61 this.maximumSpeed = maximumSpeed;
62 }
63
64
65 @Override
66 public final Length getLength()
67 {
68 return this.length;
69 }
70
71
72 @Override
73 public final Length getWidth()
74 {
75 return this.width;
76 }
77
78
79 @Override
80 public final Speed getMaximumSpeed()
81 {
82 return this.maximumSpeed;
83 }
84
85
86 @Override
87 public final void setNoLaneChangeDistance(final Length distance)
88 {
89 this.noLaneChangeDistance = distance;
90 }
91
92
93 @Override
94 public final boolean laneChangeAllowed()
95 {
96 return this.noLaneChangeDistance == null ? true : getOdometer().gt(this.noLaneChangeDistance);
97 }
98
99 }