View Javadoc
1   package org.opentrafficsim.road.network.lane;
2   
3   import java.util.HashMap;
4   import java.util.List;
5   import java.util.Map;
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.geometry.OTSGeometryException;
11  import org.opentrafficsim.core.gtu.GTUType;
12  import org.opentrafficsim.core.network.LongitudinalDirectionality;
13  import org.opentrafficsim.core.network.NetworkException;
14  import org.opentrafficsim.road.network.lane.changing.OvertakingConditions;
15  
16  /**
17   * Lane without traffic, e.g. emergency lane next to highway.
18   * <p>
19   * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
20   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
21   * <p>
22   * $LastChangedDate: 2015-09-16 19:20:07 +0200 (Wed, 16 Sep 2015) $, @version $Revision: 1405 $, by $Author: averbraeck $,
23   * initial version Feb 28, 2015 <br>
24   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
25   */
26  public class NoTrafficLane extends Lane
27  {
28      /** */
29      private static final long serialVersionUID = 20150228L;
30  
31      /** Map that tells that directionality is NONE for all GTU types. */
32      private static final Map<GTUType, LongitudinalDirectionality> DIRECTIONALITY_NONE = new HashMap<>();
33  
34      /** Map that tells that speed is 0.0 for all GTU Types. */
35      private static final Map<GTUType, Speed> SPEED_NULL = new HashMap<>();
36  
37      /** The overtaking rules for a no-traffic lane. */
38      private static final OvertakingConditions NO_OVERTAKING = new OvertakingConditions.None();
39  
40      static
41      {
42          DIRECTIONALITY_NONE.put(GTUType.ALL, LongitudinalDirectionality.DIR_NONE);
43          SPEED_NULL.put(GTUType.ALL, new Speed(0.0, SpeedUnit.SI));
44      }
45  
46      /**
47       * @param parentLink Cross Section Link to which the element belongs.
48       * @param id String; the id of the lane. Should be unique within the parentLink.
49       * @param lateralOffsetAtStart Length.Rel; the lateral offset of the design line of the new CrossSectionLink with respect to
50       *            the design line of the parent Link at the start of the parent Link
51       * @param lateralOffsetAtEnd Length.Rel; the lateral offset of the design line of the new CrossSectionLink with respect to
52       *            the design line of the parent Link at the end of the parent Link
53       * @param beginWidth Length.Rel; start width, positioned <i>symmetrically around</i> the design line
54       * @param endWidth Length.Rel; end width, positioned <i>symmetrically around</i> the design line
55       * @throws OTSGeometryException when creation of the geometry fails
56       * @throws NetworkException when id equal to null or not unique
57       */
58      @SuppressWarnings("checkstyle:parameternumber")
59      public NoTrafficLane(final CrossSectionLink parentLink, final String id, final Length.Rel lateralOffsetAtStart,
60          final Length.Rel lateralOffsetAtEnd, final Length.Rel beginWidth, final Length.Rel endWidth)
61          throws OTSGeometryException, NetworkException
62      {
63          super(parentLink, id, lateralOffsetAtStart, lateralOffsetAtEnd, beginWidth, endWidth, LaneType.NONE,
64              DIRECTIONALITY_NONE, SPEED_NULL, NO_OVERTAKING);
65      }
66  
67      /**
68       * @param parentLink Cross Section Link to which the element belongs.
69       * @param id String; the id of the lane. Should be unique within the parentLink.
70       * @param lateralOffset Length.Rel; the lateral offset of the design line of the new CrossSectionLink with respect to the
71       *            design line of the parent Link
72       * @param width Length.Rel; width, positioned <i>symmetrically around</i> the design line
73       * @throws OTSGeometryException when creation of the geometry fails
74       * @throws NetworkException when id equal to null or not unique
75       */
76      @SuppressWarnings("checkstyle:parameternumber")
77      public NoTrafficLane(final CrossSectionLink parentLink, final String id, final Length.Rel lateralOffset,
78          final Length.Rel width) throws OTSGeometryException, NetworkException
79      {
80          super(parentLink, id, lateralOffset, width, LaneType.NONE, DIRECTIONALITY_NONE, SPEED_NULL, NO_OVERTAKING);
81      }
82  
83      /**
84       * @param parentLink Cross Section Link to which the element belongs.
85       * @param id String; the id of the lane. Should be unique within the parentLink.
86       * @param crossSectionSlices The offsets and widths at positions along the line, relative to the design line of the parent
87       *            link. If there is just one with and offset, there should just be one element in the list with Length.Rel = 0.
88       *            If there are more slices, the last one should be at the length of the design line. If not, a NetworkException
89       *            is thrown.
90       * @throws OTSGeometryException when creation of the geometry fails
91       * @throws NetworkException when id equal to null or not unique
92       */
93      @SuppressWarnings("checkstyle:parameternumber")
94      public NoTrafficLane(final CrossSectionLink parentLink, final String id,
95          final List<CrossSectionSlice> crossSectionSlices) throws OTSGeometryException, NetworkException
96      {
97          super(parentLink, id, crossSectionSlices, LaneType.NONE, DIRECTIONALITY_NONE, SPEED_NULL, NO_OVERTAKING);
98      }
99  
100     /** {@inheritDoc} */
101     @Override
102     protected final double getZ()
103     {
104         return -0.00005;
105     }
106 }