LaneStructureRecord.java

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

  2. import org.opentrafficsim.core.gtu.GTUType;
  3. import org.opentrafficsim.core.network.NetworkException;
  4. import org.opentrafficsim.core.network.Node;
  5. import org.opentrafficsim.core.network.route.Route;

  6. /**
  7.  * <p>
  8.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  9.  * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
  10.  * <p>
  11.  * @version $Revision$, $LastChangedDate$, by $Author$, initial version 13 aug. 2018 <br>
  12.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  13.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  14.  * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
  15.  */
  16. public interface LaneStructureRecord extends LaneRecord<LaneStructureRecord>
  17. {

  18.     /**
  19.      * Returns the the 'from' node of the link belonging to this lane, in the driving direction.
  20.      * @return Node; the 'from' node of the link belonging to this lane, in the driving direction
  21.      */
  22.     Node getFromNode();

  23.     /**
  24.      * Returns the the 'to' node of the link belonging to this lane, in the driving direction.
  25.      * @return Node; the 'to' node of the link belonging to this lane, in the driving direction
  26.      */
  27.     Node getToNode();

  28.     /**
  29.      * Returns the left LSR or null if not available. Left and right are relative to the <b>driving</b> direction.
  30.      * @return LaneStructureRecord; the left LSR or null if not available
  31.      */
  32.     LaneStructureRecord getLeft();

  33.     /**
  34.      * Returns the right LSR or null if not available. Left and right are relative to the <b>driving</b> direction.
  35.      * @return LaneStructureRecord; the right LSR or null if not available
  36.      */
  37.     LaneStructureRecord getRight();

  38.     /**
  39.      * Returns whether a left lane change is legal.
  40.      * @return whether a left lane change is legal
  41.      */
  42.     boolean legalLeft();

  43.     /**
  44.      * Returns whether a right lane change is legal.
  45.      * @return whether a right lane change is legal
  46.      */
  47.     boolean legalRight();

  48.     /**
  49.      * Returns whether a left lane change is physically possible.
  50.      * @return whether a left lane change is physically possible
  51.      */
  52.     boolean physicalLeft();

  53.     /**
  54.      * Returns whether a right lane change is physically possible.
  55.      * @return whether a right lane change is physically possible
  56.      */
  57.     boolean physicalRight();

  58.     /**
  59.      * Returns the left lane change possibility.
  60.      * @param legal boolean; legal, or otherwise physical, possibility
  61.      * @return boolean; left lane change possibility
  62.      */
  63.     default boolean possibleLeft(final boolean legal)
  64.     {
  65.         return legal ? legalLeft() : physicalLeft();
  66.     }

  67.     /**
  68.      * Returns the right lane change possibility.
  69.      * @param legal boolean; legal, or otherwise physical, possibility
  70.      * @return boolean; right lane change possibility
  71.      */
  72.     default boolean possibleRight(final boolean legal)
  73.     {
  74.         return legal ? legalRight() : physicalRight();
  75.     }

  76.     /**
  77.      * Returns whether this lane has no next records as the lane structure was cut-off.
  78.      * @return whether this lane has no next records as the lane structure was cut-off
  79.      */
  80.     boolean isCutOffEnd();

  81.     /**
  82.      * Returns whether this lane has no previous records as the lane structure was cut-off.
  83.      * @return whether this lane has no previous records as the lane structure was cut-off
  84.      */
  85.     boolean isCutOffStart();

  86.     /**
  87.      * Returns whether the record forms a dead-end.
  88.      * @return whether the record forms a dead-end
  89.      */
  90.     boolean isDeadEnd();

  91.     /**
  92.      * Returns whether this lane allows the route to be followed.
  93.      * @param route Route; the route to follow
  94.      * @param gtuType GTUType; gtu type
  95.      * @return whether this lane allows the route to be followed
  96.      * @throws NetworkException if no destination node
  97.      */
  98.     boolean allowsRoute(Route route, GTUType gtuType) throws NetworkException;

  99.     /**
  100.      * Returns whether the end of this lane allows the route to be followed.
  101.      * @param route Route; the route to follow
  102.      * @param gtuType GTUType; gtu type
  103.      * @return whether the end of this lane allows the route to be followed
  104.      * @throws NetworkException if no destination node
  105.      */
  106.     boolean allowsRouteAtEnd(Route route, GTUType gtuType) throws NetworkException;

  107. }