1 package org.opentrafficsim.core.definitions;
2
3 import java.util.Locale;
4 import java.util.Optional;
5 import java.util.function.BiFunction;
6
7 import org.djunits.unit.SpeedUnit;
8 import org.djunits.value.vdouble.scalar.Length;
9 import org.djunits.value.vdouble.scalar.Speed;
10 import org.opentrafficsim.core.distributions.ConstantSupplier;
11 import org.opentrafficsim.core.gtu.GtuTemplate;
12 import org.opentrafficsim.core.gtu.GtuType;
13 import org.opentrafficsim.core.network.LinkType;
14 import org.opentrafficsim.core.object.DetectorType;
15 import org.opentrafficsim.core.units.distributions.ContinuousDistSpeed;
16
17 import nl.tudelft.simulation.jstats.distributions.DistNormal;
18 import nl.tudelft.simulation.jstats.streams.StreamInterface;
19
20
21
22
23
24
25
26
27
28
29
30 public final class DefaultsNl extends Defaults implements BiFunction<GtuType, StreamInterface, Optional<GtuTemplate>>
31 {
32
33
34
35
36 DefaultsNl()
37 {
38 super(new Locale("nl", "NL"));
39 }
40
41
42
43
44
45
46 public static final GtuType ROAD_USER = new GtuType("NL.ROAD_USER");
47
48
49 public static final GtuType PEDESTRIAN = new GtuType("NL.PEDESTRIAN", ROAD_USER);
50
51
52 public static final GtuType BICYCLE = new GtuType("NL.BICYCLE", ROAD_USER);
53
54
55 public static final GtuType MOPED = new GtuType("NL.MOPED", BICYCLE);
56
57
58 public static final GtuType VEHICLE = new GtuType("NL.VEHICLE", ROAD_USER);
59
60
61 public static final GtuType EMERGENCY_VEHICLE = new GtuType("NL.EMERGENCY_VEHICLE", VEHICLE);
62
63
64 public static final GtuType CAR = new GtuType("NL.CAR", VEHICLE);
65
66
67 public static final GtuType MOTORCYCLE = new GtuType("NL.MOTORCYCLE", VEHICLE);
68
69
70 public static final GtuType VAN = new GtuType("NL.VAN", VEHICLE);
71
72
73 public static final GtuType BUS = new GtuType("NL.BUS", VEHICLE);
74
75
76 public static final GtuType TRUCK = new GtuType("NL.TRUCK", VEHICLE);
77
78
79 public static final GtuType SCHEDULED_BUS = new GtuType("NL.SCHEDULED_BUS", BUS);
80
81
82
83
84
85
86
87
88
89
90
91
92 @Override
93 public Optional<GtuTemplate> apply(final GtuType gtuType, final StreamInterface randomStream)
94 {
95 return Optional.ofNullable(apply(gtuType, gtuType, randomStream));
96 }
97
98
99
100
101
102
103
104
105 private GtuTemplate apply(final GtuType gtuType, final GtuType originalGtuType, final StreamInterface randomStream)
106 {
107 if (gtuType.equals(CAR))
108 {
109
110 return new GtuTemplate(originalGtuType, new ConstantSupplier<>(Length.ofSI(4.19)),
111 new ConstantSupplier<>(Length.ofSI(1.7)), new ConstantSupplier<>(new Speed(180, SpeedUnit.KM_PER_HOUR)));
112 }
113 else if (gtuType.equals(TRUCK))
114 {
115
116 return new GtuTemplate(originalGtuType, new ConstantSupplier<>(Length.ofSI(12.0)),
117 new ConstantSupplier<>(Length.ofSI(2.55)),
118 new ContinuousDistSpeed(new DistNormal(randomStream, 85.0, 2.5), SpeedUnit.KM_PER_HOUR));
119 }
120 else if (gtuType.equals(BUS))
121 {
122 return new GtuTemplate(originalGtuType, new ConstantSupplier<>(Length.ofSI(12.0)),
123 new ConstantSupplier<>(Length.ofSI(2.55)), new ConstantSupplier<>(new Speed(90, SpeedUnit.KM_PER_HOUR)));
124 }
125 else if (gtuType.equals(VAN))
126 {
127 return new GtuTemplate(originalGtuType, new ConstantSupplier<>(Length.ofSI(5.0)),
128 new ConstantSupplier<>(Length.ofSI(2.4)), new ConstantSupplier<>(new Speed(180, SpeedUnit.KM_PER_HOUR)));
129 }
130 else if (gtuType.equals(EMERGENCY_VEHICLE))
131 {
132 return new GtuTemplate(originalGtuType, new ConstantSupplier<>(Length.ofSI(5.0)),
133 new ConstantSupplier<>(Length.ofSI(2.55)), new ConstantSupplier<>(new Speed(180, SpeedUnit.KM_PER_HOUR)));
134 }
135 else if (gtuType.equals(MOTORCYCLE))
136 {
137
138 return new GtuTemplate(originalGtuType, new ConstantSupplier<>(Length.ofSI(2.1)),
139 new ConstantSupplier<>(Length.ofSI(0.7)), new ConstantSupplier<>(new Speed(180, SpeedUnit.KM_PER_HOUR)));
140 }
141 else if (gtuType.equals(BICYCLE))
142 {
143
144
145 return new GtuTemplate(originalGtuType, new ConstantSupplier<>(Length.ofSI(1.9)),
146 new ConstantSupplier<>(Length.ofSI(0.6)), new ConstantSupplier<>(new Speed(35, SpeedUnit.KM_PER_HOUR)));
147 }
148 else if (gtuType.getParent().isPresent())
149 {
150 return apply(gtuType.getParent().get(), originalGtuType, randomStream);
151 }
152 return null;
153 }
154
155
156
157
158
159
160 public static final LinkType CONNECTOR = new LinkType("NL.CONNECTOR");
161
162
163 public static final LinkType ROAD = new LinkType("NL.ROAD");
164
165
166 public static final LinkType FREEWAY = new LinkType("NL.FREEWAY", ROAD);
167
168
169 public static final LinkType HIGHWAY = new LinkType("NL.HIGHWAY", ROAD);
170
171
172 public static final LinkType PROVINCIAL = new LinkType("NL.PROVINCIAL", ROAD);
173
174
175 public static final LinkType RURAL = new LinkType("NL.RURAL", ROAD);
176
177
178 public static final LinkType URBAN = new LinkType("NL.URBAN", ROAD);
179
180
181 public static final LinkType RESIDENTIAL = new LinkType("NL.RESIDENTIAL", ROAD);
182
183 static
184 {
185 CONNECTOR.addCompatibleGtuType(ROAD_USER);
186 ROAD.addCompatibleGtuType(ROAD_USER);
187 FREEWAY.addIncompatibleGtuType(PEDESTRIAN);
188 FREEWAY.addIncompatibleGtuType(BICYCLE);
189 HIGHWAY.addIncompatibleGtuType(PEDESTRIAN);
190 HIGHWAY.addIncompatibleGtuType(BICYCLE);
191 PROVINCIAL.addIncompatibleGtuType(PEDESTRIAN);
192 PROVINCIAL.addIncompatibleGtuType(BICYCLE);
193 }
194
195
196
197
198
199
200 public static final DetectorType ROAD_USERS = new DetectorType("NL.ROAD_USERS");
201
202
203 public static final DetectorType VEHICLES = new DetectorType("NL.VEHICLES");
204
205
206 public static final DetectorType LOOP_DETECTOR = new DetectorType("NL.LOOP_DETECTOR", VEHICLES);
207
208
209 public static final DetectorType TRAFFIC_LIGHT = new DetectorType("NL.TRAFFIC_LIGHT", LOOP_DETECTOR);
210
211 static
212 {
213 ROAD_USERS.addCompatibleGtuType(DefaultsNl.ROAD_USER);
214 VEHICLES.addCompatibleGtuType(DefaultsNl.VEHICLE);
215 TRAFFIC_LIGHT.addCompatibleGtuType(DefaultsNl.BICYCLE);
216 }
217
218 }