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