Class Route
java.lang.Object
org.opentrafficsim.core.network.route.Route
- All Implemented Interfaces:
Serializable,Identifiable
- Direct Known Subclasses:
CompleteRoute
public class Route extends Object implements Serializable, Identifiable
A Route consists of a list of Nodes. A route does not have to be complete. As long as all 'splitting' nodes are part of the
route and have a valid successor node (connected by a Link), the strategical planner is able to make a plan. An extension of
the Route class exists that contains a complete route, where all nodes on the route have to be present and connected.
Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2020-01-31 14:44:04 +0100 (Fri, 31 Jan 2020) $, @version $Revision: 6246 $, by $Author: pknoppers $,
initial version Jan 1, 2015
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description RouteaddNode(Node node)Add a node to the end of the node list.Routeclone(Network newNetwork, SimulatorInterface.TimeDoubleUnit newSimulator)Clone the Route.booleancontains(Node node)NodedestinationNode()StringgetId()NodegetNode(int i)List<Node>getNodes()intindexOf(Node node)Return the index of a Node in this Route, or -1 if this Route does not contain the specified Node.NodeoriginNode()intsize()StringtoString()voidverify()Verify that there are normal (non Connectors) between adjacent nodes, except at start and end (where Connectors are OK.
-
Constructor Details
-
Method Details
-
verify
public void verify()Verify that there are normal (non Connectors) between adjacent nodes, except at start and end (where Connectors are OK. -
addNode
Add a node to the end of the node list.- Parameters:
node- Node; the node to add.- Returns:
- Route; this route for method chaining
- Throws:
NetworkException- in case node could not be added to the route.
-
getNodes
- Returns:
- nodes.
-
getNode
- Parameters:
i- int; the index of the node to obtain- Returns:
- node i.
- Throws:
NetworkException- if i < 0 or i > size
-
originNode
- Returns:
- the first node of the route.
- Throws:
NetworkException- when the list has no nodes.
-
size
public final int 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:
- 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- Node; the Node to find- Returns:
- int;
-
contains
- Parameters:
node- Node; the Node to find- Returns:
- whether the route contains this node (quick using LinkedHashSet);
-
getId
- Specified by:
getIdin interfaceIdentifiable- Returns:
- name.
-
toString
-
clone
public Route clone(Network newNetwork, SimulatorInterface.TimeDoubleUnit newSimulator) throws NetworkExceptionClone the Route.- Parameters:
newNetwork- Network; the new networknewSimulator- SimulatorInterface.TimeDoubleUnit; the new simulator for this network- Returns:
- a clone of this route
- Throws:
NetworkException- in case the cloning fails
-