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.geometry.OTSGeometryException; 7 import org.opentrafficsim.core.network.NetworkException; 8 9 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface; 10 11 /** 12 * <p> 13 * Copyright (c) 2013-2020 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 CrossSectionLink; 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 Length; the lateral start position compared to the linear geometry of the Cross Section Link. 31 * @param lateralPositionEnd Length; the lateral end position compared to the linear geometry of the Cross Section Link 32 * @param beginWidth Length; start width, positioned <i>symmetrically around</i> the lateral start position. 33 * @param endWidth Length; end width, positioned <i>symmetrically around</i> the lateral end position. 34 * @param fixGradualLateralOffset boolean; true if gradualLateralOffset needs to be fixed 35 * @throws OTSGeometryException when creation of the center line or contour geometry fails 36 * @throws NetworkException when id equal to null or not unique 37 */ 38 public Shoulder(final CrossSectionLink parentLink, final String id, final Length lateralPositionStart, 39 final Length lateralPositionEnd, final Length beginWidth, final Length endWidth, 40 final boolean fixGradualLateralOffset) throws OTSGeometryException, NetworkException 41 { 42 super(parentLink, id, lateralPositionStart, lateralPositionEnd, beginWidth, endWidth, fixGradualLateralOffset); 43 } 44 45 /** 46 * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs. 47 * @param id String; the id of the lane. Should be unique within the parentLink. 48 * @param lateralPositionStart Length; the lateral start position compared to the linear geometry of the Cross Section Link. 49 * @param lateralPositionEnd Length; the lateral end position compared to the linear geometry of the Cross Section Link 50 * @param beginWidth Length; start width, positioned <i>symmetrically around</i> the lateral start position. 51 * @param endWidth Length; end width, positioned <i>symmetrically around</i> the lateral end position. 52 * @throws OTSGeometryException when creation of the center line or contour geometry fails 53 * @throws NetworkException when id equal to null or not unique 54 */ 55 public Shoulder(final CrossSectionLink parentLink, final String id, final Length lateralPositionStart, 56 final Length lateralPositionEnd, final Length beginWidth, final Length endWidth) 57 throws OTSGeometryException, NetworkException 58 { 59 this(parentLink, id, lateralPositionStart, lateralPositionEnd, beginWidth, endWidth, false); 60 } 61 62 /** 63 * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs. 64 * @param id String; the id of the lane. Should be unique within the parentLink. 65 * @param lateralPosition Length; the lateral start position compared to the linear geometry of the Cross Section Link. 66 * @param width Length; the shoulder width, positioned <i>symmetrically around</i> the lateral start position. 67 * @throws OTSGeometryException when creation of the center line or contour geometry fails 68 * @throws NetworkException when id equal to null or not unique 69 */ 70 public Shoulder(final CrossSectionLink parentLink, final String id, final Length lateralPosition, final Length width) 71 throws OTSGeometryException, NetworkException 72 { 73 super(parentLink, id, lateralPosition, width); 74 } 75 76 /** 77 * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs. 78 * @param id String; the id of the lane. Should be unique within the parentLink. 79 * @param crossSectionSlices List<CrossSectionSlice>; The offsets and widths at positions along the line, relative to 80 * the design line of the parent link. If there is just one with and offset, there should just be one element in 81 * the list with Length = 0. If there are more slices, the last one should be at the length of the design line. 82 * If not, a NetworkException is thrown. 83 * @throws OTSGeometryException when creation of the center line or contour geometry fails 84 * @throws NetworkException when id equal to null or not unique 85 */ 86 public Shoulder(final CrossSectionLink parentLink, final String id, final List<CrossSectionSlice> crossSectionSlices) 87 throws OTSGeometryException, NetworkException 88 { 89 super(parentLink, id, crossSectionSlices); 90 } 91 92 /** 93 * Clone a Shoulder for a new network. 94 * @param newParentLink CrossSectionLink; the new link to which the clone belongs 95 * @param newSimulator SimulatorInterface.TimeDoubleUnit; the new simulator for this network 96 * @param cse Shoulder; the element to clone from 97 * @throws NetworkException if link already exists in the network, if name of the link is not unique, or if the start node 98 * or the end node of the link are not registered in the network. 99 */ 100 protected Shoulder(final CrossSectionLink newParentLink, final SimulatorInterface.TimeDoubleUnit newSimulator, 101 final Shoulder cse) throws NetworkException 102 { 103 super(newParentLink, newSimulator, cse); 104 } 105 106 /** {@inheritDoc} */ 107 @Override 108 protected final double getZ() 109 { 110 return -0.0002; 111 } 112 113 /** {@inheritDoc} */ 114 @Override 115 @SuppressWarnings("checkstyle:designforextension") 116 public String toString() 117 { 118 return String.format("Shoulder offset %.2fm..%.2fm, width %.2fm..%.2fm", getDesignLineOffsetAtBegin().getSI(), 119 getDesignLineOffsetAtEnd().getSI(), getBeginWidth().getSI(), getEndWidth().getSI()); 120 } 121 122 /** {@inheritDoc} */ 123 @Override 124 @SuppressWarnings("checkstyle:designforextension") 125 public Shoulder clone(final CrossSectionLink newParentLink, final SimulatorInterface.TimeDoubleUnit newSimulator) 126 throws NetworkException 127 { 128 return new Shoulder(newParentLink, newSimulator, this); 129 } 130 131 }