1 package org.opentrafficsim.road.gtu.lane.perception.headway;
2
3 import org.djunits.unit.LengthUnit;
4 import org.djunits.value.vdouble.scalar.Acceleration;
5 import org.djunits.value.vdouble.scalar.Length;
6 import org.djunits.value.vdouble.scalar.Speed;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public class HeadwayDistance implements Headway
23 {
24
25 private static final long serialVersionUID = 20160410L;
26
27
28 private final Length distance;
29
30
31
32
33
34
35 public HeadwayDistance(final double distance)
36 {
37 this(new Length(distance, LengthUnit.SI));
38 }
39
40
41
42
43
44
45 public HeadwayDistance(final Length distance)
46 {
47 this.distance = distance;
48 }
49
50
51 @Override
52 public final String getId()
53 {
54 return "DISTANCE";
55 }
56
57
58 @Override
59 public final Length getLength()
60 {
61 return null;
62 }
63
64
65 @Override
66 public final Speed getSpeed()
67 {
68 return Speed.ZERO;
69 }
70
71
72 @Override
73 public final Length getDistance()
74 {
75 return this.distance;
76 }
77
78
79 @Override
80 public final ObjectType getObjectType()
81 {
82 return ObjectType.DISTANCEONLY;
83 }
84
85
86 @Override
87 public final Acceleration getAcceleration()
88 {
89 return Acceleration.ZERO;
90 }
91
92
93 @Override
94 public final Length getOverlapFront()
95 {
96 return null;
97 }
98
99
100 @Override
101 public final Length getOverlapRear()
102 {
103 return null;
104 }
105
106
107 @Override
108 public final Length getOverlap()
109 {
110 return null;
111 }
112
113
114 @Override
115 public final boolean isAhead()
116 {
117 return this.distance.ge0();
118 }
119
120
121 @Override
122 public final boolean isBehind()
123 {
124 return this.distance.lt0();
125 }
126
127
128 @Override
129 public final boolean isParallel()
130 {
131 return false;
132 }
133
134
135 @Override
136 public final String toString()
137 {
138 return "HeadwayDistance [distance=" + this.distance + "]";
139 }
140
141 }