Class Route
java.lang.Object
org.opentrafficsim.core.network.route.Route
- All Implemented Interfaces:
Identifiable
A route is defined as a series of nodes. Each pair of consecutive nodes should have a link valid for the given direction and
GTU type.
Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal RouteAdd a node to the end of the node list.final booleanReturns whether the node is contained.final booleancontainsLink(Link link) Determine if this Route contains the specified Link.final NodeReturns destination node.booleanfinal StringgetId()final NodegetNode(int i) Returns node at index.getNodes()Returns nodes.inthashCode()final intReturn the index of a Node in this Route, or -1 if this Route does not contain the specified Node.final NodeReturns origin node.final intsize()Returns size.toString()voidverify()Verify that there are normal (non Connectors) between adjacent nodes, except at start and end (where Connectors are OK.
-
Constructor Details
-
Route
Create an empty route for the given GtuType.- Parameters:
id- the name of the routegtuType- the GtuType for which this is a route
-
Route
Create a route based on an initial list of nodes.
This constructor makes a defensive copy of the provided List.- Parameters:
id- the name of the route.gtuType- the GtuType for which this is a routenodes- the initial list of nodes.- Throws:
NetworkException- if intermediate nodes are missing in the route.
-
-
Method Details
-
verify
Verify that there are normal (non Connectors) between adjacent nodes, except at start and end (where Connectors are OK.- Throws:
NetworkException- checks links between adjacent nodes.
-
addNode
Add a node to the end of the node list.- Parameters:
node- the node to add.- Returns:
- this route for method chaining
- Throws:
NetworkException- in case node could not be added to the route.
-
getNodes
Returns nodes.- Returns:
- nodes.
-
getNode
Returns node at index.- Parameters:
i- the index of the node to obtain- Returns:
- node i.
- Throws:
NetworkException- if i < 0 or i > size
-
originNode
Returns origin node.- Returns:
- the first node of the route.
- Throws:
NetworkException- when the list has no nodes.
-
size
public final int size()Returns size.- Returns:
- the number of nodes in the list. If the list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
-
destinationNode
Returns destination node.- Returns:
- the last node of the route.
- Throws:
NetworkException- when the list has no nodes.
-
indexOf
Return the index of a Node in this Route, or -1 if this Route does not contain the specified Node.
If this route contains the Node more than once, the index of the first is returned.- Parameters:
node- the Node to find- Returns:
- returns index of node.
-
contains
Returns whether the node is contained.- Parameters:
node- the Node to find- Returns:
- whether the route contains this node (quick using LinkedHashSet);
-
getId
- Specified by:
getIdin interfaceIdentifiable- Returns:
- name.
-
containsLink
Determine if this Route contains the specified Link.- Parameters:
link- the link to check in the route.- Returns:
- whether the link is part of the route or not.
-
hashCode
public int hashCode() -
equals
-
toString
-