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