1 package org.opentrafficsim.road.network.lane; 2 3 import java.util.LinkedHashMap; 4 import java.util.List; 5 import java.util.Map; 6 7 import org.djunits.value.vdouble.scalar.Length; 8 import org.djunits.value.vdouble.scalar.Speed; 9 import org.opentrafficsim.core.geometry.OTSGeometryException; 10 import org.opentrafficsim.core.gtu.GTUType; 11 import org.opentrafficsim.core.network.LongitudinalDirectionality; 12 import org.opentrafficsim.core.network.NetworkException; 13 import org.opentrafficsim.road.network.RoadNetwork; 14 15 /** 16 * Lane without traffic, e.g. emergency lane next to highway. 17 * <p> 18 * Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 19 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. 20 * <p> 21 * $LastChangedDate: 2015-09-16 19:20:07 +0200 (Wed, 16 Sep 2015) $, @version $Revision: 1405 $, by $Author: averbraeck $, 22 * initial version Feb 28, 2015 <br> 23 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 24 */ 25 public class NoTrafficLane extends Lane 26 { 27 /** */ 28 private static final long serialVersionUID = 20150228L; 29 30 /** 31 * Return a Map that tells that directionality is NONE for all vehicles. 32 * @param network RoadNetwork; the network for which to define the directionality 33 * @return Map<GTUType, LongitudinalDirectionality>; a Map that tells that directionality is NONE for all vehicles 34 */ 35 private static Map<GTUType, LongitudinalDirectionality> directionalityNone(final RoadNetwork network) 36 { 37 Map<GTUType, LongitudinalDirectionality> dirNone = new LinkedHashMap<>(); 38 dirNone.put(network.getGtuType(GTUType.DEFAULTS.VEHICLE), LongitudinalDirectionality.DIR_NONE); 39 return dirNone; 40 } 41 42 /** 43 * Map that tells that speed is 0.0 for all vehicles. 44 * @param network RoadNetwork; the network for which to define the speeds 45 * @return Map<GTUType, Speed>; Map that tells that speed is 0.0 for all vehicles 46 */ 47 private static Map<GTUType, Speed> speedNull(final RoadNetwork network) 48 { 49 Map<GTUType, Speed> speedMap = new LinkedHashMap<>(); 50 speedMap.put(network.getGtuType(GTUType.DEFAULTS.VEHICLE), Speed.ZERO); 51 return speedMap; 52 } 53 54 /** 55 * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs. 56 * @param id String; the id of the lane. Should be unique within the parentLink. 57 * @param lateralOffsetAtStart Length; the lateral offset of the design line of the new CrossSectionLink with respect to the 58 * design line of the parent Link at the start of the parent Link 59 * @param lateralOffsetAtEnd Length; the lateral offset of the design line of the new CrossSectionLink with respect to the 60 * design line of the parent Link at the end of the parent Link 61 * @param beginWidth Length; start width, positioned <i>symmetrically around</i> the design line 62 * @param endWidth Length; end width, positioned <i>symmetrically around</i> the design line 63 * @param fixGradualLateralOffset boolean; true if gradualLateralOffset needs to be fixed 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 lateralOffsetAtStart, 69 final Length lateralOffsetAtEnd, final Length beginWidth, final Length endWidth, 70 final boolean fixGradualLateralOffset) throws OTSGeometryException, NetworkException 71 { 72 super(parentLink, id, lateralOffsetAtStart, lateralOffsetAtEnd, beginWidth, endWidth, 73 parentLink.getNetwork().getLaneType(LaneType.DEFAULTS.NONE), speedNull(parentLink.getNetwork()), 74 fixGradualLateralOffset); 75 } 76 77 /** 78 * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs. 79 * @param id String; the id of the lane. Should be unique within the parentLink. 80 * @param lateralOffsetAtStart Length; the lateral offset of the design line of the new CrossSectionLink with respect to the 81 * design line of the parent Link at the start of the parent Link 82 * @param lateralOffsetAtEnd Length; the lateral offset of the design line of the new CrossSectionLink with respect to the 83 * design line of the parent Link at the end of the parent Link 84 * @param beginWidth Length; start width, positioned <i>symmetrically around</i> the design line 85 * @param endWidth Length; end width, positioned <i>symmetrically around</i> the design line 86 * @throws OTSGeometryException when creation of the geometry fails 87 * @throws NetworkException when id equal to null or not unique 88 */ 89 @SuppressWarnings("checkstyle:parameternumber") 90 public NoTrafficLane(final CrossSectionLink parentLink, final String id, final Length lateralOffsetAtStart, 91 final Length lateralOffsetAtEnd, final Length beginWidth, final Length endWidth) 92 throws OTSGeometryException, NetworkException 93 { 94 this(parentLink, id, lateralOffsetAtStart, lateralOffsetAtEnd, beginWidth, endWidth, false); 95 } 96 97 /** 98 * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs. 99 * @param id String; the id of the lane. Should be unique within the parentLink. 100 * @param lateralOffset Length; the lateral offset of the design line of the new CrossSectionLink with respect to the design 101 * line of the parent Link 102 * @param width Length; width, positioned <i>symmetrically around</i> the design line 103 * @throws OTSGeometryException when creation of the geometry fails 104 * @throws NetworkException when id equal to null or not unique 105 */ 106 @SuppressWarnings("checkstyle:parameternumber") 107 public NoTrafficLane(final CrossSectionLink parentLink, final String id, final Length lateralOffset, final Length width) 108 throws OTSGeometryException, NetworkException 109 { 110 super(parentLink, id, lateralOffset, width, parentLink.getNetwork().getLaneType(LaneType.DEFAULTS.NONE), 111 speedNull(parentLink.getNetwork())); 112 } 113 114 /** 115 * @param parentLink CrossSectionLink; Cross Section Link to which the element belongs. 116 * @param id String; the id of the lane. Should be unique within the parentLink. 117 * @param crossSectionSlices List<CrossSectionSlice>; The offsets and widths at positions along the line, relative to 118 * the design line of the parent link. If there is just one with and offset, there should just be one element in 119 * the list with Length = 0. If there are more slices, the last one should be at the length of the design line. 120 * If not, a NetworkException is thrown. 121 * @throws OTSGeometryException when creation of the geometry fails 122 * @throws NetworkException when id equal to null or not unique 123 */ 124 @SuppressWarnings("checkstyle:parameternumber") 125 public NoTrafficLane(final CrossSectionLink parentLink, final String id, final List<CrossSectionSlice> crossSectionSlices) 126 throws OTSGeometryException, NetworkException 127 { 128 super(parentLink, id, crossSectionSlices, parentLink.getNetwork().getLaneType(LaneType.DEFAULTS.NONE), 129 speedNull(parentLink.getNetwork())); 130 } 131 132 /** {@inheritDoc} */ 133 @Override 134 public final double getZ() 135 { 136 return -0.00005; 137 } 138 }