Shoulder.java

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

  2. import java.util.List;

  3. import org.djunits.value.vdouble.scalar.Length;
  4. import org.opentrafficsim.core.geometry.OTSGeometryException;
  5. import org.opentrafficsim.core.network.NetworkException;

  6. import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;

  7. /**
  8.  * <p>
  9.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  10.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  11.  * <p>
  12.  * $LastChangedDate: 2015-09-03 13:38:01 +0200 (Thu, 03 Sep 2015) $, @version $Revision: 1378 $, by $Author: averbraeck $,
  13.  * initial version Aug 19, 2014 <br>
  14.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  15.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  16.  * @author <a href="http://www.citg.tudelft.nl">Guus Tamminga</a>
  17.  */
  18. public class Shoulder extends CrossSectionElement
  19. {
  20.     /** */
  21.     private static final long serialVersionUID = 20140819L;

  22.     /**
  23.      * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs.
  24.      * @param id String; the id of the lane. Should be unique within the parentLink.
  25.      * @param lateralPositionStart Length; the lateral start position compared to the linear geometry of the Cross Section Link.
  26.      * @param lateralPositionEnd Length; the lateral end position compared to the linear geometry of the Cross Section Link
  27.      * @param beginWidth Length; start width, positioned &lt;i&gt;symmetrically around&lt;/i&gt; the lateral start position.
  28.      * @param endWidth Length; end width, positioned &lt;i&gt;symmetrically around&lt;/i&gt; the lateral end position.
  29.      * @param fixGradualLateralOffset boolean; true if gradualLateralOffset needs to be fixed
  30.      * @throws OTSGeometryException when creation of the center line or contour geometry fails
  31.      * @throws NetworkException when id equal to null or not unique
  32.      */
  33.     public Shoulder(final CrossSectionLink parentLink, final String id, final Length lateralPositionStart,
  34.             final Length lateralPositionEnd, final Length beginWidth, final Length endWidth,
  35.             final boolean fixGradualLateralOffset) throws OTSGeometryException, NetworkException
  36.     {
  37.         super(parentLink, id, lateralPositionStart, lateralPositionEnd, beginWidth, endWidth, fixGradualLateralOffset);
  38.     }

  39.     /**
  40.      * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs.
  41.      * @param id String; the id of the lane. Should be unique within the parentLink.
  42.      * @param lateralPositionStart Length; the lateral start position compared to the linear geometry of the Cross Section Link.
  43.      * @param lateralPositionEnd Length; the lateral end position compared to the linear geometry of the Cross Section Link
  44.      * @param beginWidth Length; start width, positioned &lt;i&gt;symmetrically around&lt;/i&gt; the lateral start position.
  45.      * @param endWidth Length; end width, positioned &lt;i&gt;symmetrically around&lt;/i&gt; the lateral end position.
  46.      * @throws OTSGeometryException when creation of the center line or contour geometry fails
  47.      * @throws NetworkException when id equal to null or not unique
  48.      */
  49.     public Shoulder(final CrossSectionLink parentLink, final String id, final Length lateralPositionStart,
  50.             final Length lateralPositionEnd, final Length beginWidth, final Length endWidth)
  51.             throws OTSGeometryException, NetworkException
  52.     {
  53.         this(parentLink, id, lateralPositionStart, lateralPositionEnd, beginWidth, endWidth, false);
  54.     }

  55.     /**
  56.      * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs.
  57.      * @param id String; the id of the lane. Should be unique within the parentLink.
  58.      * @param lateralPosition Length; the lateral start position compared to the linear geometry of the Cross Section Link.
  59.      * @param width Length; the shoulder width, positioned &lt;i&gt;symmetrically around&lt;/i&gt; the lateral start position.
  60.      * @throws OTSGeometryException when creation of the center line or contour geometry fails
  61.      * @throws NetworkException when id equal to null or not unique
  62.      */
  63.     public Shoulder(final CrossSectionLink parentLink, final String id, final Length lateralPosition, final Length width)
  64.             throws OTSGeometryException, NetworkException
  65.     {
  66.         super(parentLink, id, lateralPosition, width);
  67.     }

  68.     /**
  69.      * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs.
  70.      * @param id String; the id of the lane. Should be unique within the parentLink.
  71.      * @param crossSectionSlices List&lt;CrossSectionSlice&gt;; The offsets and widths at positions along the line, relative to
  72.      *            the design line of the parent link. If there is just one with and offset, there should just be one element in
  73.      *            the list with Length = 0. If there are more slices, the last one should be at the length of the design line.
  74.      *            If not, a NetworkException is thrown.
  75.      * @throws OTSGeometryException when creation of the center line or contour geometry fails
  76.      * @throws NetworkException when id equal to null or not unique
  77.      */
  78.     public Shoulder(final CrossSectionLink parentLink, final String id, final List<CrossSectionSlice> crossSectionSlices)
  79.             throws OTSGeometryException, NetworkException
  80.     {
  81.         super(parentLink, id, crossSectionSlices);
  82.     }

  83.     /**
  84.      * Clone a Shoulder for a new network.
  85.      * @param newParentLink CrossSectionLink; the new link to which the clone belongs
  86.      * @param newSimulator SimulatorInterface.TimeDoubleUnit; the new simulator for this network
  87.      * @param cse Shoulder; the element to clone from
  88.      * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node
  89.      *             or the end node of the link are not registered in the network.
  90.      */
  91.     protected Shoulder(final CrossSectionLink newParentLink, final SimulatorInterface.TimeDoubleUnit newSimulator,
  92.             final Shoulder cse) throws NetworkException
  93.     {
  94.         super(newParentLink, newSimulator, cse);
  95.     }

  96.     /** {@inheritDoc} */
  97.     @Override
  98.     protected final double getZ()
  99.     {
  100.         return -0.0002;
  101.     }

  102.     /** {@inheritDoc} */
  103.     @Override
  104.     @SuppressWarnings("checkstyle:designforextension")
  105.     public String toString()
  106.     {
  107.         return String.format("Shoulder offset %.2fm..%.2fm, width %.2fm..%.2fm", getDesignLineOffsetAtBegin().getSI(),
  108.                 getDesignLineOffsetAtEnd().getSI(), getBeginWidth().getSI(), getEndWidth().getSI());
  109.     }

  110.     /** {@inheritDoc} */
  111.     @Override
  112.     @SuppressWarnings("checkstyle:designforextension")
  113.     public Shoulder clone(final CrossSectionLink newParentLink, final SimulatorInterface.TimeDoubleUnit newSimulator)
  114.             throws NetworkException
  115.     {
  116.         return new Shoulder(newParentLink, newSimulator, this);
  117.     }

  118. }