View Javadoc
1   package org.opentrafficsim.core.definitions;
2   
3   import java.util.Locale;
4   import java.util.function.BiFunction;
5   
6   import org.djunits.unit.SpeedUnit;
7   import org.djunits.value.vdouble.scalar.Length;
8   import org.djunits.value.vdouble.scalar.Speed;
9   import org.opentrafficsim.core.distributions.ConstantGenerator;
10  import org.opentrafficsim.core.gtu.GtuTemplate;
11  import org.opentrafficsim.core.gtu.GtuType;
12  import org.opentrafficsim.core.network.LinkType;
13  import org.opentrafficsim.core.object.DetectorType;
14  import org.opentrafficsim.core.units.distributions.ContinuousDistSpeed;
15  
16  import nl.tudelft.simulation.jstats.distributions.DistNormal;
17  import nl.tudelft.simulation.jstats.streams.StreamInterface;
18  
19  /**
20   * Defaults for locale nl_NL.
21   * <p>
22   * Copyright (c) 2022-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
23   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
24   * </p>
25   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
26   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
27   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
28   */
29  public final class DefaultsNl extends Defaults implements BiFunction<GtuType, StreamInterface, GtuTemplate>
30  {
31  
32      /**
33       * Constructor setting locale nl_NL.
34       */
35      DefaultsNl()
36      {
37          super(new Locale("nl", "NL"));
38      }
39  
40      /***************************************************************************************/
41      /***************************************** GTU *****************************************/
42      /***************************************************************************************/
43  
44      /** Super type for all road users. */
45      public static final GtuType ROAD_USER = new GtuType("NL.ROAD_USER");
46  
47      /** Super type for pedestrians. */
48      public static final GtuType PEDESTRIAN = new GtuType("NL.PEDESTRIAN", ROAD_USER);
49  
50      /** Super type for bicycle. */
51      public static final GtuType BICYCLE = new GtuType("NL.BICYCLE", ROAD_USER);
52  
53      /** Super type for mopeds. */
54      public static final GtuType MOPED = new GtuType("NL.MOPED", BICYCLE);
55  
56      /** Super type for vehicles. */
57      public static final GtuType VEHICLE = new GtuType("NL.VEHICLE", ROAD_USER);
58  
59      /** Super type for emergency vehicles. */
60      public static final GtuType EMERGENCY_VEHICLE = new GtuType("NL.EMERGENCY_VEHICLE", VEHICLE);
61  
62      /** Super type for cars. */
63      public static final GtuType CAR = new GtuType("NL.CAR", VEHICLE);
64  
65      /** Super type for motorcycles. */
66      public static final GtuType MOTORCYCLE = new GtuType("NL.MOTORCYCLE", VEHICLE);
67  
68      /** Super type for vans. */
69      public static final GtuType VAN = new GtuType("NL.VAN", VEHICLE);
70  
71      /** Super type for busses. */
72      public static final GtuType BUS = new GtuType("NL.BUS", VEHICLE);
73  
74      /** Super type for trucks. */
75      public static final GtuType TRUCK = new GtuType("NL.TRUCK", VEHICLE);
76  
77      /** Super type for scheduled busses. */
78      public static final GtuType SCHEDULED_BUS = new GtuType("NL.SCHEDULED_BUS", BUS);
79  
80      /**
81       * Returns a template for the given GTU type. This can be defined at the level of super types, returning {@code null} for
82       * more specific types. There is no need to define a template for all default types defined for a locale, so long as at
83       * least one parent of each type has a template defined.<br>
84       * <br>
85       * Note: implementations should not cache the template per GTU type, as different simulations may request templates for the
86       * same GTU type, while having their separate random streams.
87       * @param gtuType GTU type.
88       * @param randomStream random stream.
89       * @return template, {@code null} if no default is defined.
90       */
91      @Override
92      public GtuTemplate apply(final GtuType gtuType, final StreamInterface randomStream)
93      {
94          GtuTemplate template = null;
95          if (gtuType.equals(CAR))
96          {
97              // from "Maatgevende normen in de Nederlandse richtlijnen voor wegontwerp", R-2014-38, SWOV
98              template = new GtuTemplate(gtuType, new ConstantGenerator<>(Length.instantiateSI(4.19)),
99                      new ConstantGenerator<>(Length.instantiateSI(1.7)),
100                     new ConstantGenerator<>(new Speed(180, SpeedUnit.KM_PER_HOUR)));
101         }
102         else if (gtuType.equals(TRUCK))
103         {
104             // from "Maatgevende normen in de Nederlandse richtlijnen voor wegontwerp", R-2014-38, SWOV
105             template = new GtuTemplate(gtuType, new ConstantGenerator<>(Length.instantiateSI(12.0)),
106                     new ConstantGenerator<>(Length.instantiateSI(2.55)),
107                     new ContinuousDistSpeed(new DistNormal(randomStream, 85.0, 2.5), SpeedUnit.KM_PER_HOUR));
108         }
109         else if (gtuType.equals(BUS))
110         {
111             template = new GtuTemplate(gtuType, new ConstantGenerator<>(Length.instantiateSI(12.0)),
112                     new ConstantGenerator<>(Length.instantiateSI(2.55)),
113                     new ConstantGenerator<>(new Speed(90, SpeedUnit.KM_PER_HOUR)));
114         }
115         else if (gtuType.equals(VAN))
116         {
117             template = new GtuTemplate(gtuType, new ConstantGenerator<>(Length.instantiateSI(5.0)),
118                     new ConstantGenerator<>(Length.instantiateSI(2.4)),
119                     new ConstantGenerator<>(new Speed(180, SpeedUnit.KM_PER_HOUR)));
120         }
121         else if (gtuType.equals(EMERGENCY_VEHICLE))
122         {
123             template = new GtuTemplate(gtuType, new ConstantGenerator<>(Length.instantiateSI(5.0)),
124                     new ConstantGenerator<>(Length.instantiateSI(2.55)),
125                     new ConstantGenerator<>(new Speed(180, SpeedUnit.KM_PER_HOUR)));
126         }
127         else if (gtuType.equals(MOTORCYCLE))
128         {
129             // Yamaha R7 2022
130             template = new GtuTemplate(gtuType, new ConstantGenerator<>(Length.instantiateSI(2.1)),
131                     new ConstantGenerator<>(Length.instantiateSI(0.7)),
132                     new ConstantGenerator<>(new Speed(180, SpeedUnit.KM_PER_HOUR)));
133         }
134         else if (gtuType.equals(BICYCLE))
135         {
136             // length/width: https://www.verderfietsen.nl/fiets-afmetingen/
137             // width: https://www.fietsberaad.nl/CROWFietsberaad/media/Kennis/Bestanden/document000172.pdf?ext=.pdf
138             template = new GtuTemplate(gtuType, new ConstantGenerator<>(Length.instantiateSI(1.9)),
139                     new ConstantGenerator<>(Length.instantiateSI(0.6)),
140                     new ConstantGenerator<>(new Speed(35, SpeedUnit.KM_PER_HOUR)));
141         }
142         return template;
143     };
144 
145     /***************************************************************************************/
146     /**************************************** LINK *****************************************/
147     /***************************************************************************************/
148 
149     /** Connector type. */
150     public static final LinkType CONNECTOR = new LinkType("NL.CONNECTOR");
151 
152     /** Super type for all roads. */
153     public static final LinkType ROAD = new LinkType("NL.ROAD");
154 
155     /** Freeway (snelweg, 130km/h). */
156     public static final LinkType FREEWAY = new LinkType("NL.FREEWAY", ROAD);
157 
158     /** Highway (autoweg, 100km/h). */
159     public static final LinkType HIGHWAY = new LinkType("NL.HIGHWAY", ROAD);
160 
161     /** Provincial (provinciaalse weg / N-weg, 80km/h). */
162     public static final LinkType PROVINCIAL = new LinkType("NL.PROVINCIAL", ROAD);
163 
164     /** Rural (landelijk, 60km/h). */
165     public static final LinkType RURAL = new LinkType("NL.RURAL", ROAD);
166 
167     /** Urban (stedelijk, 50km/h). */
168     public static final LinkType URBAN = new LinkType("NL.URBAN", ROAD);
169 
170     /** Residential (buurtweg, 30km/h). */
171     public static final LinkType RESIDENTIAL = new LinkType("NL.RESIDENTIAL", ROAD);
172 
173     static
174     {
175         CONNECTOR.addCompatibleGtuType(ROAD_USER);
176         ROAD.addCompatibleGtuType(ROAD_USER);
177         FREEWAY.addIncompatibleGtuType(PEDESTRIAN);
178         FREEWAY.addIncompatibleGtuType(BICYCLE);
179         HIGHWAY.addIncompatibleGtuType(PEDESTRIAN);
180         HIGHWAY.addIncompatibleGtuType(BICYCLE);
181         PROVINCIAL.addIncompatibleGtuType(PEDESTRIAN);
182         PROVINCIAL.addIncompatibleGtuType(BICYCLE);
183     }
184 
185     /***************************************************************************************/
186     /************************************** DETECTOR ***************************************/
187     /***************************************************************************************/
188 
189     /** Makes a Detector compatible with all road users, e.g. for SinkDetector. */
190     public static final DetectorType ROAD_USERS = new DetectorType("NL.ROAD_USERS");
191 
192     /** Makes a Detector compatible with all vehicles, e.g. for loop detectors. */
193     public static final DetectorType VEHICLES = new DetectorType("NL.VEHICLES");
194 
195     /** Loop detector type. */
196     public static final DetectorType LOOP_DETECTOR = new DetectorType("NL.LOOP_DETECTOR", VEHICLES);
197 
198     /** Traffic light detector type. */
199     public static final DetectorType TRAFFIC_LIGHT = new DetectorType("NL.TRAFFIC_LIGHT", LOOP_DETECTOR);
200 
201     static
202     {
203         ROAD_USERS.addCompatibleGtuType(DefaultsNl.ROAD_USER);
204         VEHICLES.addCompatibleGtuType(DefaultsNl.VEHICLE);
205         TRAFFIC_LIGHT.addCompatibleGtuType(DefaultsNl.BICYCLE);
206     }
207 
208 }