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

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

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

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

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

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