1 package org.opentrafficsim.road.gtu.lane.perception.categories;
2
3 import org.djunits.value.vdouble.scalar.Length;
4 import org.opentrafficsim.core.gtu.GTUException;
5 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
6 import org.opentrafficsim.road.gtu.lane.perception.headway.GTUStatus;
7 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGTU;
8 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGTUReal;
9 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGTURealCopy;
10
11
12
13
14
15
16
17
18
19
20
21
22 public enum HeadwayGtuType
23 {
24
25
26 WRAP
27 {
28 @Override
29 public HeadwayGTU createHeadwayGtu(final LaneBasedGTU gtu, final Length distance) throws GTUException
30 {
31 return new HeadwayGTUReal(gtu, distance, true);
32 }
33
34 @Override
35 public HeadwayGTU createHeadwayGtu(final LaneBasedGTU gtu, final Length overlapFront, final Length overlap,
36 final Length overlapRear) throws GTUException
37 {
38 return new HeadwayGTUReal(gtu, overlapFront, overlap, overlapRear, true);
39 }
40 },
41
42
43 COPY
44 {
45 @Override
46 public HeadwayGTU createHeadwayGtu(final LaneBasedGTU gtu, final Length distance) throws GTUException
47 {
48
49 if (gtu.getTurnIndicatorStatus().isLeft())
50 {
51 return new HeadwayGTURealCopy(gtu, distance, GTUStatus.LEFT_TURNINDICATOR);
52 }
53 else if (gtu.getTurnIndicatorStatus().isRight())
54 {
55 return new HeadwayGTURealCopy(gtu, distance, GTUStatus.RIGHT_TURNINDICATOR);
56 }
57 else if (gtu.getTurnIndicatorStatus().isHazard())
58 {
59 return new HeadwayGTURealCopy(gtu, distance, GTUStatus.EMERGENCY_LIGHTS);
60 }
61 return new HeadwayGTURealCopy(gtu, distance);
62 }
63
64 @Override
65 public HeadwayGTU createHeadwayGtu(final LaneBasedGTU gtu, final Length overlapFront, final Length overlap,
66 final Length overlapRear) throws GTUException
67 {
68 return new HeadwayGTURealCopy(gtu, overlapFront, overlap, overlapRear);
69 }
70 };
71
72
73
74
75
76
77
78
79 public abstract HeadwayGTU createHeadwayGtu(LaneBasedGTU gtu, Length distance) throws GTUException;
80
81
82
83
84
85
86
87
88
89
90 public abstract HeadwayGTU createHeadwayGtu(LaneBasedGTU gtu, Length overlapFront, Length overlap, Length overlapRear)
91 throws GTUException;
92
93 }