1 package org.opentrafficsim.road.gtu.lane.tactical; 2 3 import java.io.Serializable; 4 import java.util.ArrayList; 5 import java.util.List; 6 7 import org.djunits.value.vdouble.scalar.Length; 8 import org.opentrafficsim.core.geometry.OTSLine3D; 9 import org.opentrafficsim.road.network.lane.Lane; 10 import org.opentrafficsim.road.network.lane.LaneDirection; 11 12 /** 13 * This class provides the following information for an operational plan: 14 * <ul> 15 * <li>the lanes to follow, with the direction to drive on them</li> 16 * <li>the starting point on the first lane</li> 17 * <li>the path to follow when staying on the same lane</li> 18 * </ul> 19 * <p> 20 * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 21 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. 22 * </p> 23 * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, 24 * initial version Dec 31, 2015 <br> 25 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 26 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 27 */ 28 public class LanePathInfo implements Serializable 29 { 30 /** */ 31 private static final long serialVersionUID = 20151231L; 32 33 /** 34 * The path it the GTU keeps driving in the same lane, and follows the route if possible in the same lane. The path stops 35 * when the lane or a continuation lane does not lead in the direction of the route provided by the strategical planner. 36 */ 37 private final OTSLine3D path; 38 39 /** 40 * The current lane on which the reference point of the GTU is registered (if the GTU is registered on multiple lanes with 41 * the reference point, one lane is chosen where the reference point has a fractional lane position between 0.0 and 1.0), 42 * and consecutive lanes that follow the route if possible in the same lane. The list of lanes stops when a continuation 43 * lane does not lead in the direction of the route provided by the strategical planner. For each lane, the direction to 44 * drive is provided. 45 */ 46 private final List<LaneDirection> laneDirectionList; 47 48 /** 49 * The start point on the first lane in the laneDirectionList. When this is a point that represents a GTU position, it 50 * should represent the reference point of the GTU. 51 */ 52 private final Length referencePosition; 53 54 /** 55 * @param path the path it the GTU keeps driving in the same lane, and follows the route if possible in the same lane. The 56 * path stops when the lane or a continuation lane does not lead in the direction of the route provided by the 57 * strategical planner. 58 * @param laneDirectionList the current lane on which the reference point of the GTU is registered (if the GTU is registered 59 * on multiple lanes with the reference point, one lane is chosen where the reference point has a fractional lane 60 * position between 0.0 and 1.0), and consecutive lanes that follow the route if possible in the same lane. The 61 * list of lanes stops when a continuation lane does not lead in the direction of the route provided by the 62 * strategical planner. For each lane, the direction to drive is provided. 63 * @param referencePosition the start point on the first lane in the laneDirectionList. When this is a point that represents 64 * a GTU position, it should represent the reference point of the GTU. 65 */ 66 public LanePathInfo(final OTSLine3D path, final List<LaneDirection> laneDirectionList, final Length referencePosition) 67 { 68 super(); 69 this.path = path; 70 this.laneDirectionList = laneDirectionList; 71 this.referencePosition = referencePosition; 72 } 73 74 /** 75 * @return path the path it the GTU keeps driving in the same lane, and follows the route if possible in the same lane. The 76 * path stops when the lane or a continuation lane does not lead in the direction of the route provided by the 77 * strategical planner. 78 */ 79 public final OTSLine3D getPath() 80 { 81 return this.path; 82 } 83 84 /** 85 * @return laneList the current lane on which the reference point of the GTU is registered (if the GTU is registered on 86 * multiple lanes with the reference point, one lane is chosen where the reference point has a fractional lane 87 * position between 0.0 and 1.0), and consecutive lanes that follow the route if possible in the same lane. The list 88 * of lanes stops when a continuation lane does not lead in the direction of the route provided by the strategical 89 * planner. For each lane, the direction to drive is provided. 90 */ 91 public final List<LaneDirection> getLaneDirectionList() 92 { 93 return this.laneDirectionList; 94 } 95 96 /** 97 * @return list of lanes 98 */ 99 public final List<Lane> getLanes() 100 { 101 List<Lane> lanes = new ArrayList<>(); 102 for (LaneDirection ld : this.laneDirectionList) 103 { 104 lanes.add(ld.getLane()); 105 } 106 return lanes; 107 } 108 109 /** 110 * The reference lane is the widest lane on which the reference point of the GTU is fully registered. 111 * @return the reference lane on which the GTU is registered, plus the driving direction on this lane, or null if the GTU is 112 * not registered on any lane. 113 */ 114 public final LaneDirection getReferenceLaneDirection() 115 { 116 return this.laneDirectionList.isEmpty() ? null : this.laneDirectionList.get(0); 117 } 118 119 /** 120 * The reference lane is the widest lane on which the reference point of the GTU is fully registered. 121 * @return the reference lane on which the GTU is registered, or null if the GTU is not registered on any lane. 122 */ 123 public final Lane getReferenceLane() 124 { 125 return this.laneDirectionList.isEmpty() ? null : this.laneDirectionList.get(0).getLane(); 126 } 127 128 /** 129 * @return the start point on the first lane in the laneDirectionList. When this is a point that represents a GTU position, 130 * it should represent the reference point of the GTU. 131 */ 132 public final Length getReferencePosition() 133 { 134 return this.referencePosition; 135 } 136 137 /** {@inheritDoc} */ 138 @Override 139 public final String toString() 140 { 141 return "LanePathInfo [path=" + this.path + ", laneDirectionList=" + this.laneDirectionList + ", referencePosition=" 142 + this.referencePosition + "]"; 143 } 144 145 }