1 package org.opentrafficsim.road.network.lane; 2 3 import java.io.Serializable; 4 import java.util.ArrayList; 5 import java.util.List; 6 7 import org.opentrafficsim.core.geometry.OTSLine3D; 8 import org.opentrafficsim.core.network.Node; 9 import org.opentrafficsim.core.network.OTSLink; 10 import org.opentrafficsim.road.network.lane.changing.LaneKeepingPolicy; 11 12 /** 13 * A CrossSectionLink is a link with lanes where GTUs can possibly switch between lanes. 14 * <p> 15 * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 16 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. 17 * <p> 18 * $LastChangedDate: 2015-09-16 19:20:07 +0200 (Wed, 16 Sep 2015) $, @version $Revision: 1405 $, by $Author: averbraeck $, 19 * initial version Aug 19, 2014 <br> 20 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 21 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 22 * @author <a href="http://www.citg.tudelft.nl">Guus Tamminga</a> 23 */ 24 public class CrossSectionLink extends OTSLink implements Serializable 25 { 26 /** */ 27 private static final long serialVersionUID = 20141015L; 28 29 /** list of cross-section elements. */ 30 private final List<CrossSectionElement> crossSectionElementList = new ArrayList<>(); 31 32 /** the policy to generally keep left, keep right, or keep lane. */ 33 private final LaneKeepingPolicy laneKeepingPolicy; 34 35 /** 36 * Construction of a link. 37 * @param id the link id. 38 * @param startNode start node (directional). 39 * @param endNode end node (directional). 40 * @param designLine the OTSLine3D design line of the Link 41 * @param laneKeepingPolicy the policy to generally keep left, keep right, or keep lane 42 */ 43 public CrossSectionLink(final String id, final Node startNode, final Node endNode, final OTSLine3D designLine, 44 final LaneKeepingPolicy laneKeepingPolicy) 45 { 46 super(id, startNode, endNode, designLine); 47 this.laneKeepingPolicy = laneKeepingPolicy; 48 } 49 50 /** 51 * Add a cross section element at the end of the list. <br> 52 * <b>Note:</b> LEFT is seen as a positive lateral direction, RIGHT as a negative lateral direction. 53 * @param cse the cross section element to add. 54 */ 55 protected final void addCrossSectionElement(final CrossSectionElement cse) 56 { 57 this.crossSectionElementList.add(cse); 58 } 59 60 /** 61 * Add a cross section element at specified index in the list.<br> 62 * <b>Note:</b> LEFT is seen as a positive lateral direction, RIGHT as a negative lateral direction. 63 * @param index the location to insert the element. 64 * @param cse the cross section element to add. 65 */ 66 protected final void addCrossSectionElement(final CrossSectionElement cse, final int index) 67 { 68 this.crossSectionElementList.add(index, cse); 69 } 70 71 /** 72 * @return crossSectionElementList. 73 */ 74 public final List<CrossSectionElement> getCrossSectionElementList() 75 { 76 return this.crossSectionElementList; 77 } 78 79 /** 80 * @return laneKeepingPolicy 81 */ 82 public final LaneKeepingPolicy getLaneKeepingPolicy() 83 { 84 return this.laneKeepingPolicy; 85 } 86 }