View Javadoc
1   package org.opentrafficsim.road.network.lane;
2   
3   import java.util.List;
4   
5   import org.djunits.value.vdouble.scalar.Length;
6   import org.opentrafficsim.core.dsol.OTSSimulatorInterface;
7   import org.opentrafficsim.core.geometry.OTSGeometryException;
8   import org.opentrafficsim.core.network.NetworkException;
9   import org.opentrafficsim.core.network.OTSNetwork;
10  
11  /**
12   * <p>
13   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
15   * <p>
16   * $LastChangedDate: 2015-09-03 13:38:01 +0200 (Thu, 03 Sep 2015) $, @version $Revision: 1378 $, by $Author: averbraeck $,
17   * initial version Aug 19, 2014 <br>
18   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
20   * @author <a href="http://www.citg.tudelft.nl">Guus Tamminga</a>
21   */
22  public class Shoulder extends CrossSectionElement
23  {
24      /** */
25      private static final long serialVersionUID = 20140819L;
26  
27      /**
28       * @param parentLink Cross Section Link to which the element belongs.
29       * @param id String; the id of the lane. Should be unique within the parentLink.
30       * @param lateralPositionStart the lateral start position compared to the linear geometry of the Cross Section Link.
31       * @param lateralPositionEnd the lateral end position compared to the linear geometry of the Cross Section Link
32       * @param beginWidth start width, positioned <i>symmetrically around</i> the lateral start position.
33       * @param endWidth end width, positioned <i>symmetrically around</i> the lateral end position.
34       * @throws OTSGeometryException when creation of the center line or contour geometry fails
35       * @throws NetworkException when id equal to null or not unique
36       */
37      public Shoulder(final CrossSectionLink parentLink, final String id, final Length lateralPositionStart,
38              final Length lateralPositionEnd, final Length beginWidth, final Length endWidth)
39              throws OTSGeometryException, NetworkException
40      {
41          super(parentLink, id, lateralPositionStart, lateralPositionEnd, beginWidth, endWidth);
42      }
43  
44      /**
45       * @param parentLink Cross Section Link to which the element belongs.
46       * @param id String; the id of the lane. Should be unique within the parentLink.
47       * @param lateralPosition the lateral start position compared to the linear geometry of the Cross Section Link.
48       * @param width the shoulder width, positioned <i>symmetrically around</i> the lateral start position.
49       * @throws OTSGeometryException when creation of the center line or contour geometry fails
50       * @throws NetworkException when id equal to null or not unique
51       */
52      public Shoulder(final CrossSectionLink parentLink, final String id, final Length lateralPosition, final Length width)
53              throws OTSGeometryException, NetworkException
54      {
55          super(parentLink, id, lateralPosition, width);
56      }
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 crossSectionSlices The offsets and widths at positions along the line, relative to the design line of the parent
62       *            link. If there is just one with and offset, there should just be one element in the list with Length = 0. If
63       *            there are more slices, the last one should be at the length of the design line. If not, a NetworkException is
64       *            thrown.
65       * @throws OTSGeometryException when creation of the center line or contour geometry fails
66       * @throws NetworkException when id equal to null or not unique
67       */
68      public Shoulder(final CrossSectionLink parentLink, final String id, final List<CrossSectionSlice> crossSectionSlices)
69              throws OTSGeometryException, NetworkException
70      {
71          super(parentLink, id, crossSectionSlices);
72      }
73  
74      /**
75       * Clone a Shoulder for a new network.
76       * @param newParentLink the new link to which the clone belongs
77       * @param newSimulator the new simulator for this network
78       * @param animation whether to (re)create animation or not
79       * @param cse the element to clone from
80       * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node
81       *             or the end node of the link are not registered in the network.
82       */
83      protected Shoulder(final CrossSectionLink newParentLink, final OTSSimulatorInterface newSimulator, final boolean animation,
84              final Shoulder cse) throws NetworkException
85      {
86          super(newParentLink, newSimulator, animation, cse);
87  
88          if (animation)
89          {
90              OTSNetwork.cloneAnimation(cse, this, cse.getParentLink().getSimulator(), newSimulator);
91          }
92      }
93  
94      /** {@inheritDoc} */
95      @Override
96      protected final double getZ()
97      {
98          return -0.0002;
99      }
100 
101     /** {@inheritDoc} */
102     @Override
103     @SuppressWarnings("checkstyle:designforextension")
104     public String toString()
105     {
106         return String.format("Shoulder offset %.2fm..%.2fm, width %.2fm..%.2fm", getDesignLineOffsetAtBegin().getSI(),
107                 getDesignLineOffsetAtEnd().getSI(), getBeginWidth().getSI(), getEndWidth().getSI());
108     }
109 
110     /** {@inheritDoc} */
111     @Override
112     @SuppressWarnings("checkstyle:designforextension")
113     public Shoulder clone(final CrossSectionLink newParentLink, final OTSSimulatorInterface newSimulator,
114             final boolean animation) throws NetworkException
115     {
116         return new Shoulder(newParentLink, newSimulator, animation, this);
117     }
118 
119 }