NoTrafficLane.java

  1. package org.opentrafficsim.road.network.lane;

  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;

  5. import org.djunits.unit.SpeedUnit;
  6. import org.djunits.value.vdouble.scalar.Length;
  7. import org.djunits.value.vdouble.scalar.Speed;
  8. import org.opentrafficsim.core.geometry.OTSGeometryException;
  9. import org.opentrafficsim.core.gtu.GTUType;
  10. import org.opentrafficsim.core.network.LongitudinalDirectionality;
  11. import org.opentrafficsim.core.network.NetworkException;
  12. import org.opentrafficsim.road.network.lane.changing.OvertakingConditions;

  13. /**
  14.  * Lane without traffic, e.g. emergency lane next to highway.
  15.  * <p>
  16.  * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  17.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  18.  * <p>
  19.  * $LastChangedDate: 2015-09-16 19:20:07 +0200 (Wed, 16 Sep 2015) $, @version $Revision: 1405 $, by $Author: averbraeck $,
  20.  * initial version Feb 28, 2015 <br>
  21.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  22.  */
  23. public class NoTrafficLane extends Lane
  24. {
  25.     /** */
  26.     private static final long serialVersionUID = 20150228L;

  27.     /** Map that tells that directionality is NONE for all GTU types. */
  28.     private static final Map<GTUType, LongitudinalDirectionality> DIRECTIONALITY_NONE = new HashMap<>();

  29.     /** Map that tells that speed is 0.0 for all GTU Types. */
  30.     private static final Map<GTUType, Speed> SPEED_NULL = new HashMap<>();

  31.     /** The overtaking rules for a no-traffic lane. */
  32.     private static final OvertakingConditions NO_OVERTAKING = new OvertakingConditions.None();

  33.     static
  34.     {
  35.         DIRECTIONALITY_NONE.put(GTUType.ALL, LongitudinalDirectionality.DIR_NONE);
  36.         SPEED_NULL.put(GTUType.ALL, new Speed(0.0, SpeedUnit.SI));
  37.     }

  38.     /**
  39.      * @param parentLink Cross Section Link to which the element belongs.
  40.      * @param id String; the id of the lane. Should be unique within the parentLink.
  41.      * @param lateralOffsetAtStart Length.Rel; the lateral offset of the design line of the new CrossSectionLink with respect to
  42.      *            the design line of the parent Link at the start of the parent Link
  43.      * @param lateralOffsetAtEnd Length.Rel; the lateral offset of the design line of the new CrossSectionLink with respect to
  44.      *            the design line of the parent Link at the end of the parent Link
  45.      * @param beginWidth Length.Rel; start width, positioned <i>symmetrically around</i> the design line
  46.      * @param endWidth Length.Rel; end width, positioned <i>symmetrically around</i> the design line
  47.      * @throws OTSGeometryException when creation of the geometry fails
  48.      * @throws NetworkException when id equal to null or not unique
  49.      */
  50.     @SuppressWarnings("checkstyle:parameternumber")
  51.     public NoTrafficLane(final CrossSectionLink parentLink, final String id, final Length.Rel lateralOffsetAtStart,
  52.         final Length.Rel lateralOffsetAtEnd, final Length.Rel beginWidth, final Length.Rel endWidth)
  53.         throws OTSGeometryException, NetworkException
  54.     {
  55.         super(parentLink, id, lateralOffsetAtStart, lateralOffsetAtEnd, beginWidth, endWidth, LaneType.NONE,
  56.             DIRECTIONALITY_NONE, SPEED_NULL, NO_OVERTAKING);
  57.     }

  58.     /**
  59.      * @param parentLink Cross Section Link to which the element belongs.
  60.      * @param id String; the id of the lane. Should be unique within the parentLink.
  61.      * @param lateralOffset Length.Rel; the lateral offset of the design line of the new CrossSectionLink with respect to the
  62.      *            design line of the parent Link
  63.      * @param width Length.Rel; width, positioned <i>symmetrically around</i> the design line
  64.      * @throws OTSGeometryException when creation of the geometry fails
  65.      * @throws NetworkException when id equal to null or not unique
  66.      */
  67.     @SuppressWarnings("checkstyle:parameternumber")
  68.     public NoTrafficLane(final CrossSectionLink parentLink, final String id, final Length.Rel lateralOffset,
  69.         final Length.Rel width) throws OTSGeometryException, NetworkException
  70.     {
  71.         super(parentLink, id, lateralOffset, width, LaneType.NONE, DIRECTIONALITY_NONE, SPEED_NULL, NO_OVERTAKING);
  72.     }

  73.     /**
  74.      * @param parentLink Cross Section Link to which the element belongs.
  75.      * @param id String; the id of the lane. Should be unique within the parentLink.
  76.      * @param crossSectionSlices The offsets and widths at positions along the line, relative to the design line of the parent
  77.      *            link. If there is just one with and offset, there should just be one element in the list with Length.Rel = 0.
  78.      *            If there are more slices, the last one should be at the length of the design line. If not, a NetworkException
  79.      *            is thrown.
  80.      * @throws OTSGeometryException when creation of the geometry fails
  81.      * @throws NetworkException when id equal to null or not unique
  82.      */
  83.     @SuppressWarnings("checkstyle:parameternumber")
  84.     public NoTrafficLane(final CrossSectionLink parentLink, final String id,
  85.         final List<CrossSectionSlice> crossSectionSlices) throws OTSGeometryException, NetworkException
  86.     {
  87.         super(parentLink, id, crossSectionSlices, LaneType.NONE, DIRECTIONALITY_NONE, SPEED_NULL, NO_OVERTAKING);
  88.     }

  89.     /** {@inheritDoc} */
  90.     @Override
  91.     protected final double getZ()
  92.     {
  93.         return -0.00005;
  94.     }
  95. }