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