NextSplitInfo.java

  1. package org.opentrafficsim.road.gtu.lane.tactical;

  2. import java.io.Serializable;
  3. import java.util.Set;

  4. import org.opentrafficsim.core.network.LateralDirectionality;
  5. import org.opentrafficsim.core.network.Node;
  6. import org.opentrafficsim.road.network.lane.Lane;

  7. /**
  8.  * This class provides information for an operational plan about the next location where the network splits. if the networks
  9.  * splits, the node where it splits, and the current lanes that lead to the right node are calculated.
  10.  * <p>
  11.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  12.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  13.  * </p>
  14.  * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
  15.  * initial version Dec 31, 2015 <br>
  16.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  17.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  18.  */
  19. public class NextSplitInfo implements Serializable
  20. {
  21.     /** */
  22.     private static final long serialVersionUID = 20151231L;

  23.     /** If the route splits, at what node does it split? */
  24.     private final Node nextSplitNode;

  25.     /** Required direction. */
  26.     private final LateralDirectionality requiredDirection;

  27.     /**
  28.      * If the route splits, what are the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered
  29.      * that lead us in the direction of the route provided by the strategical planner.
  30.      */
  31.     private final Set<Lane> correctCurrentLanes;

  32.     /**
  33.      * @param nextSplitNode Node; the first subsequent node at which the route splits.
  34.      * @param correctCurrentLanes Set&lt;Lane&gt;; the lane(s) and/or adjacent lane(s) on which the reference point of the GTU
  35.      *            is registered that lead us in the direction of the route provided by the strategical planner.
  36.      */
  37.     public NextSplitInfo(final Node nextSplitNode, final Set<Lane> correctCurrentLanes)
  38.     {
  39.         this(nextSplitNode, correctCurrentLanes, null);
  40.     }

  41.     /**
  42.      * @param nextSplitNode Node; the first subsequent node at which the route splits.
  43.      * @param correctCurrentLanes Set&lt;Lane&gt;; the lane(s) and/or adjacent lane(s) on which the reference point of the GTU
  44.      *            is registered that lead us in the direction of the route provided by the strategical planner.
  45.      * @param requiredDirection LateralDirectionality; required direction for lane changes for this split, beyond lane on
  46.      *            current link
  47.      */
  48.     public NextSplitInfo(final Node nextSplitNode, final Set<Lane> correctCurrentLanes,
  49.             final LateralDirectionality requiredDirection)
  50.     {
  51.         this.nextSplitNode = nextSplitNode;
  52.         this.correctCurrentLanes = correctCurrentLanes;
  53.         this.requiredDirection = requiredDirection;
  54.     }

  55.     /**
  56.      * @return split indicates whether the route splits within the given distance.
  57.      */
  58.     public final boolean isSplit()
  59.     {
  60.         return this.nextSplitNode != null;
  61.     }

  62.     /**
  63.      * @return nextSplitNode the first subsequent node at which the route splits.
  64.      */
  65.     public final Node getNextSplitNode()
  66.     {
  67.         return this.nextSplitNode;
  68.     }

  69.     /**
  70.      * @return correctCurrentLanes the lane(s) and/or adjacent lane(s) on which the reference point of the GTU is registered
  71.      *         that lead us in the direction of the route provided by the strategical planner.
  72.      */
  73.     public final Set<Lane> getCorrectCurrentLanes()
  74.     {
  75.         return this.correctCurrentLanes;
  76.     }

  77.     /**
  78.      * @return requiredDirection.
  79.      */
  80.     public final LateralDirectionality getRequiredDirection()
  81.     {
  82.         return this.requiredDirection;
  83.     }

  84.     /** {@inheritDoc} */
  85.     @Override
  86.     public final String toString()
  87.     {
  88.         return "NextSplitInfo [nextSplitNode=" + this.nextSplitNode + ", correctCurrentLanes=" + this.correctCurrentLanes
  89.                 + ", requiredDirection=" + this.requiredDirection + "]";
  90.     }
  91. }