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