View Javadoc
1   package org.opentrafficsim.road.gtu.lane.perception;
2   
3   import org.opentrafficsim.core.gtu.GTUType;
4   import org.opentrafficsim.core.network.NetworkException;
5   import org.opentrafficsim.core.network.Node;
6   import org.opentrafficsim.core.network.route.Route;
7   
8   /**
9    * <p>
10   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
12   * <p>
13   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 13 aug. 2018 <br>
14   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
16   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
17   */
18  public interface LaneStructureRecord extends LaneRecord<LaneStructureRecord>
19  {
20  
21      /**
22       * Returns the the 'from' node of the link belonging to this lane, in the driving direction.
23       * @return Node; the 'from' node of the link belonging to this lane, in the driving direction
24       */
25      Node getFromNode();
26  
27      /**
28       * Returns the the 'to' node of the link belonging to this lane, in the driving direction.
29       * @return Node; the 'to' node of the link belonging to this lane, in the driving direction
30       */
31      Node getToNode();
32  
33      /**
34       * Returns the left LSR or null if not available. Left and right are relative to the <b>driving</b> direction.
35       * @return LaneStructureRecord; the left LSR or null if not available
36       */
37      LaneStructureRecord getLeft();
38  
39      /**
40       * Returns the right LSR or null if not available. Left and right are relative to the <b>driving</b> direction.
41       * @return LaneStructureRecord; the right LSR or null if not available
42       */
43      LaneStructureRecord getRight();
44  
45      /**
46       * Returns whether a left lane change is legal.
47       * @return whether a left lane change is legal
48       */
49      boolean legalLeft();
50  
51      /**
52       * Returns whether a right lane change is legal.
53       * @return whether a right lane change is legal
54       */
55      boolean legalRight();
56  
57      /**
58       * Returns whether a left lane change is physically possible.
59       * @return whether a left lane change is physically possible
60       */
61      boolean physicalLeft();
62  
63      /**
64       * Returns whether a right lane change is physically possible.
65       * @return whether a right lane change is physically possible
66       */
67      boolean physicalRight();
68  
69      /**
70       * Returns the left lane change possibility.
71       * @param legal boolean; legal, or otherwise physical, possibility
72       * @return boolean; left lane change possibility
73       */
74      default boolean possibleLeft(final boolean legal)
75      {
76          return legal ? legalLeft() : physicalLeft();
77      }
78  
79      /**
80       * Returns the right lane change possibility.
81       * @param legal boolean; legal, or otherwise physical, possibility
82       * @return boolean; right lane change possibility
83       */
84      default boolean possibleRight(final boolean legal)
85      {
86          return legal ? legalRight() : physicalRight();
87      }
88  
89      /**
90       * Returns whether this lane has no next records as the lane structure was cut-off.
91       * @return whether this lane has no next records as the lane structure was cut-off
92       */
93      boolean isCutOffEnd();
94  
95      /**
96       * Returns whether this lane has no previous records as the lane structure was cut-off.
97       * @return whether this lane has no previous records as the lane structure was cut-off
98       */
99      boolean isCutOffStart();
100 
101     /**
102      * Returns whether the record forms a dead-end.
103      * @return whether the record forms a dead-end
104      */
105     boolean isDeadEnd();
106 
107     /**
108      * Returns whether this lane allows the route to be followed.
109      * @param route Route; the route to follow
110      * @param gtuType GTUType; gtu type
111      * @return whether this lane allows the route to be followed
112      * @throws NetworkException if no destination node
113      */
114     boolean allowsRoute(Route route, GTUType gtuType) throws NetworkException;
115 
116     /**
117      * Returns whether the end of this lane allows the route to be followed.
118      * @param route Route; the route to follow
119      * @param gtuType GTUType; gtu type
120      * @return whether the end of this lane allows the route to be followed
121      * @throws NetworkException if no destination node
122      */
123     boolean allowsRouteAtEnd(Route route, GTUType gtuType) throws NetworkException;
124 
125 }