Package org.opentrafficsim.core.network
Interface Network
-
- All Superinterfaces:
Definitions,EventProducerInterface,Identifiable
- All Known Implementing Classes:
ExpansionNetwork,OTSNetwork
public interface Network extends Definitions, EventProducerInterface, Identifiable
Interface that defines what information a Network should be able to provide about Nodes, Links, Routes, etc..Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2020-08-11 11:54:51 +0200 (Tue, 11 Aug 2020) $, @version $Revision: 6530 $, by $Author: averbraeck $, initial version Jul 22, 2015
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers, Guus Tamminga
-
-
Field Summary
Fields Modifier and Type Field Description static TimedEventTypeANIMATION_GENERATOR_ADD_EVENTThe timed event type for pub/sub indicating the addition of an GTUGenerator implementing object.static TimedEventTypeANIMATION_GENERATOR_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an GTUGenerator implementing object.static TimedEventTypeANIMATION_GTU_ADD_EVENTThe timed event type for pub/sub indicating the addition of a GTU to this Network.static TimedEventTypeANIMATION_GTU_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a GTU from this Network.static TimedEventTypeANIMATION_INVISIBLE_OBJECT_ADD_EVENTThe timed event type for pub/sub indicating the addition of an InvisibleObjectInterface implementing object.static TimedEventTypeANIMATION_INVISIBLE_OBJECT_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an InvisibleObjectInterface implementing object.static TimedEventTypeANIMATION_LINK_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Link.static TimedEventTypeANIMATION_LINK_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Link.static TimedEventTypeANIMATION_NODE_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Node.static TimedEventTypeANIMATION_NODE_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Node.static TimedEventTypeANIMATION_OBJECT_ADD_EVENTThe timed event type for pub/sub indicating the addition of an ObjectInterface implementing object.static TimedEventTypeANIMATION_OBJECT_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an ObjectInterface implementing object.static TimedEventTypeANIMATION_ROUTE_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Route for a gtuType.static TimedEventTypeANIMATION_ROUTE_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Route for a gtuType.static TimedEventTypeGENERATOR_ADD_EVENTThe timed event type for pub/sub indicating the addition of a GTUGenerator to this Network.static TimedEventTypeGENERATOR_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a GTUGenerator from this Network.static TimedEventTypeGTU_ADD_EVENTThe timed event type for pub/sub indicating the addition of a GTU to this Network.static TimedEventTypeGTU_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a GTU from this Network.static TimedEventTypeINVISIBLE_OBJECT_ADD_EVENTThe timed event type for pub/sub indicating the addition of an InvisibleObjectInterface implementing object.static TimedEventTypeINVISIBLE_OBJECT_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an InvisibleObjectInterface implementing object.static TimedEventTypeLINK_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Link.static TimedEventTypeLINK_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Link.static TimedEventTypeNODE_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Node.static TimedEventTypeNODE_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Node.static TimedEventTypeOBJECT_ADD_EVENTThe timed event type for pub/sub indicating the addition of an ObjectInterface implementing object.static TimedEventTypeOBJECT_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of an ObjectInterface implementing object.static TimedEventTypeROUTE_ADD_EVENTThe timed event type for pub/sub indicating the addition of a Route for a gtuType.static TimedEventTypeROUTE_REMOVE_EVENTThe timed event type for pub/sub indicating the removal of a Route for a gtuType.-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidaddInvisibleObject(InvisibleObjectInterface object)Add an ObjectInterface implementing object to this Network.voidaddLink(Link link)Register a link in this Network.voidaddNode(Node node)Register a node in this Network.voidaddObject(ObjectInterface object)Add an ObjectInterface implementing object to this Network.voidaddRoute(GtuType gtuType, Route route)Add a route to this Network.voidbuildGraph(GtuType gtuType)(Re)build the underlying graph for the given GTUType.booleancontainsInvisibleObject(String objectId)Test whether an invisible object with the given id is present in this Network.booleancontainsInvisibleObject(InvisibleObjectInterface object)Test whether the invisible object is present in this Network.booleancontainsLink(String link)Test whether a link with a given id is present in this Network.booleancontainsLink(Link link)Test whether a link is present in this Network.booleancontainsNode(String nodeId)Test whether a node with a given id is present in this Network.booleancontainsNode(Node node)Test whether a node is present in this Network.booleancontainsObject(String objectId)Test whether an object with the given id is present in this Network.booleancontainsObject(ObjectInterface object)Test whether the object is present in this Network.booleancontainsRoute(GtuType gtuType, String routeId)Determine whether a route with the given id exists in this Network for the given GTUType.booleancontainsRoute(GtuType gtuType, Route route)Determine whether the provided route exists in this Network for the given GTUType.ImmutableMap<String,Route>getDefinedRouteMap(GtuType gtuType)Return an immutable map of routes that exist in this Network for the GTUType.ImmutableMap<String,InvisibleObjectInterface>getInvisibleObjectMap()Return an immutable map of all InvisibleObject implementing objects in this Network.ImmutableMap<String,InvisibleObjectInterface>getInvisibleObjectMap(Class<InvisibleObjectInterface> objectType)Return an immutable map of all InvisibleObject implementing objects in this Network that are of type objectType, or any sub type thereof.LinkgetLink(String linkId)Retrieve a node with a given id from this Network, or null if the id cannot be found.LinkgetLink(String nodeId1, String nodeId2)Find a link between node1 and node2 and return it if it exists in this Network.LinkgetLink(Node node1, Node node2)Find a link between node1 and node2 and return it if it exists in this Network.ImmutableMap<String,Link>getLinkMap()Provide an immutable map of link ids to links in this Network.NodegetNode(String nodeId)Retrieve a node with a given id from this Network, or null if the id cannot be found.ImmutableMap<String,Node>getNodeMap()Return an immutable map of node ids to nodes in this Network.<T extends ObjectInterface>
TgetObject(Class<T> objectType, String objectId)Retrieve the object of a specific type with a specific id.ImmutableMap<String,ObjectInterface>getObjectMap()Return an immutable map of all ObjectInterface implementing objects in this Network.<T extends ObjectInterface>
ImmutableMap<String,T>getObjectMap(Class<T> objectType)Return an immutable map of all ObjectInterface implementing objects in this Network that are of type objectType, or any sub type thereof.RoutegetRoute(GtuType gtuType, String routeId)Return the route with a specific id for a specific GTUType, or null if no route with that id for that GTUType exists in this Network.Set<Route>getRoutesBetween(GtuType gtuType, Node nodeFrom, Node nodeTo)Return the the shortest route for a specific GTUType between two nodes in this Network, via a list of intermediate nodes.default CompleteRoutegetShortestRouteBetween(GtuType gtuType, Node nodeFrom, Node nodeTo)Calculate the shortest route between two nodes in this Network.default CompleteRoutegetShortestRouteBetween(GtuType gtuType, Node nodeFrom, Node nodeTo, List<Node> nodesVia)Calculate the shortest route between two nodes in this Network, via a list of intermediate nodes.CompleteRoutegetShortestRouteBetween(GtuType gtuType, Node nodeFrom, Node nodeTo, List<Node> nodesVia, LinkWeight linkWeight)Calculate the shortest route between two nodes in this Network, via a list of intermediate nodes.CompleteRoutegetShortestRouteBetween(GtuType gtuType, Node nodeFrom, Node nodeTo, LinkWeight linkWeight)Calculate the shortest route between two nodes in this Network.OTSSimulatorInterfacegetSimulator()Retrieve the simulator.voidremoveInvisibleObject(InvisibleObjectInterface object)Remove an ObjectInterface implementing object form this Network.voidremoveLink(Link link)Unregister a link from this Network.voidremoveNode(Node node)Unregister a node from this Network.voidremoveObject(ObjectInterface object)Remove an ObjectInterface implementing object form this Network.voidremoveRoute(GtuType gtuType, Route route)Remove the route from this Network, e.g.-
Methods inherited from interface org.opentrafficsim.core.definitions.Definitions
addDefaultGtuTypes, addDefaultLinkTypes, addGtuType, addLinkType, getGtuType, getGtuType, getGtuTypes, getLinkType, getLinkType, getLinkTypes
-
Methods inherited from interface org.djutils.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypesWithListeners, getSourceId, hasListeners, numberOfListeners, removeListener
-
Methods inherited from interface org.opentrafficsim.base.Identifiable
getId
-
-
-
-
Field Detail
-
ANIMATION_NODE_ADD_EVENT
static final TimedEventType ANIMATION_NODE_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Node.
Payload: Node node (not an array, just an Object)
-
ANIMATION_NODE_REMOVE_EVENT
static final TimedEventType ANIMATION_NODE_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Node.
Payload: Node node (not an array, just an Object)
-
ANIMATION_LINK_ADD_EVENT
static final TimedEventType ANIMATION_LINK_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Link.
Payload: Link link (not an array, just an Object)
-
ANIMATION_LINK_REMOVE_EVENT
static final TimedEventType ANIMATION_LINK_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Link.
Payload: Link link (not an array, just an Object)
-
ANIMATION_OBJECT_ADD_EVENT
static final TimedEventType ANIMATION_OBJECT_ADD_EVENT
The timed event type for pub/sub indicating the addition of an ObjectInterface implementing object.
Payload: StaticObject object (not an array, just an Object)
-
ANIMATION_OBJECT_REMOVE_EVENT
static final TimedEventType ANIMATION_OBJECT_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an ObjectInterface implementing object.
Payload: StaticObject object (not an array, just an Object)
-
ANIMATION_INVISIBLE_OBJECT_ADD_EVENT
static final TimedEventType ANIMATION_INVISIBLE_OBJECT_ADD_EVENT
The timed event type for pub/sub indicating the addition of an InvisibleObjectInterface implementing object.
TODO: explain why invisible objects have associated animation events (or remove them from this Network interface)
Payload: InvisibleObject object (not an array, just an Object)
-
ANIMATION_INVISIBLE_OBJECT_REMOVE_EVENT
static final TimedEventType ANIMATION_INVISIBLE_OBJECT_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an InvisibleObjectInterface implementing object.
Payload: InvisibleObject object (not an array, just an Object)
-
ANIMATION_ROUTE_ADD_EVENT
static final TimedEventType ANIMATION_ROUTE_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Route for a gtuType.
Payload: [GTUType gtuType, Route route]
-
ANIMATION_ROUTE_REMOVE_EVENT
static final TimedEventType ANIMATION_ROUTE_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Route for a gtuType.
Payload: [GTUType gtuType, Route route]
-
ANIMATION_GTU_ADD_EVENT
static final TimedEventType ANIMATION_GTU_ADD_EVENT
The timed event type for pub/sub indicating the addition of a GTU to this Network.
Payload: GTU gtu (not an array, just an Object)
-
ANIMATION_GTU_REMOVE_EVENT
static final TimedEventType ANIMATION_GTU_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a GTU from this Network.
Payload: GTU gtu (not an array, just an Object)
-
ANIMATION_GENERATOR_ADD_EVENT
static final TimedEventType ANIMATION_GENERATOR_ADD_EVENT
The timed event type for pub/sub indicating the addition of an GTUGenerator implementing object.
Payload: AbstractGTUGenerator object (not an array, just an Object)
TODO: there seems to be no specific class or interface for these that can be specified in the ObjectDescriptor
-
ANIMATION_GENERATOR_REMOVE_EVENT
static final TimedEventType ANIMATION_GENERATOR_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an GTUGenerator implementing object.
Payload: AbstractGTUGenerator object (not an array, just an Object)
TODO: there seems to be no specific class or interface for these that can be specified in the ObjectDescriptor
-
NODE_ADD_EVENT
static final TimedEventType NODE_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Node.
Payload: String nodeId (not an array, just a String)
-
NODE_REMOVE_EVENT
static final TimedEventType NODE_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Node.
Payload: String nodeId (not an array, just a String)
-
LINK_ADD_EVENT
static final TimedEventType LINK_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Link.
Payload: String linkId (not an array, just a String)
-
LINK_REMOVE_EVENT
static final TimedEventType LINK_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Link.
Payload: String linkId (not an array, just a String)
-
OBJECT_ADD_EVENT
static final TimedEventType OBJECT_ADD_EVENT
The timed event type for pub/sub indicating the addition of an ObjectInterface implementing object.
Payload: String ObjectId (not an array, just a String)
-
OBJECT_REMOVE_EVENT
static final TimedEventType OBJECT_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an ObjectInterface implementing object.
Payload: String objectId (not an array, just a String)
-
INVISIBLE_OBJECT_ADD_EVENT
static final TimedEventType INVISIBLE_OBJECT_ADD_EVENT
The timed event type for pub/sub indicating the addition of an InvisibleObjectInterface implementing object.
Payload: String ObjectId (not an array, just a String)
-
INVISIBLE_OBJECT_REMOVE_EVENT
static final TimedEventType INVISIBLE_OBJECT_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of an InvisibleObjectInterface implementing object.
Payload: String objectId (not an array, just a String)
-
ROUTE_ADD_EVENT
static final TimedEventType ROUTE_ADD_EVENT
The timed event type for pub/sub indicating the addition of a Route for a gtuType.
Payload: [String gtuTypeId, String routeId]
-
ROUTE_REMOVE_EVENT
static final TimedEventType ROUTE_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a Route for a gtuType.
Payload: [String gtuTypeId, String routeId]
-
GTU_ADD_EVENT
static final TimedEventType GTU_ADD_EVENT
The timed event type for pub/sub indicating the addition of a GTU to this Network.
Payload: String gtuId (not an array, just a String)
-
GTU_REMOVE_EVENT
static final TimedEventType GTU_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a GTU from this Network.
Payload: String gtuId (not an array, just a String)
-
GENERATOR_ADD_EVENT
static final TimedEventType GENERATOR_ADD_EVENT
The timed event type for pub/sub indicating the addition of a GTUGenerator to this Network.
Payload: String generatorName (not an array, just a String)
-
GENERATOR_REMOVE_EVENT
static final TimedEventType GENERATOR_REMOVE_EVENT
The timed event type for pub/sub indicating the removal of a GTUGenerator from this Network.
Payload: String generatorName (not an array, just a String)
-
-
Method Detail
-
getSimulator
OTSSimulatorInterface getSimulator()
Retrieve the simulator.- Returns:
- OTSSimulatorInterface; the simulator
-
getNodeMap
ImmutableMap<String,Node> getNodeMap()
Return an immutable map of node ids to nodes in this Network.- Returns:
- ImmutableMap<String>; an immutable map of nodes
-
addNode
void addNode(Node node) throws NetworkException
Register a node in this Network.- Parameters:
node- Node; the node to add to this Network.- Throws:
NetworkException- if node already exists in this Network, or if name of the node is not unique
-
removeNode
void removeNode(Node node) throws NetworkException
Unregister a node from this Network.- Parameters:
node- Node; the node to remove from this Network.- Throws:
NetworkException- if node does not exist in this Network.
-
containsNode
boolean containsNode(Node node)
Test whether a node is present in this Network.- Parameters:
node- Node; the node to search for in this Network- Returns:
- boolean; true if the node is registered in this Network; false if the node is not registered in this Network
-
containsNode
boolean containsNode(String nodeId)
Test whether a node with a given id is present in this Network.- Parameters:
nodeId- String; the id of the node to search for in this Network- Returns:
- boolean; true if a node with the given id exists in this Network; false if no node with the given id exists in this Network
-
getNode
Node getNode(String nodeId)
Retrieve a node with a given id from this Network, or null if the id cannot be found.- Parameters:
nodeId- String; the id of the node to search for in this Network- Returns:
- Node; the node or null if not present
-
getLinkMap
ImmutableMap<String,Link> getLinkMap()
Provide an immutable map of link ids to links in this Network.- Returns:
- ImmutableMap<String>; the an immutable map of links
-
addLink
void addLink(Link link) throws NetworkException
Register a link in this Network.- Parameters:
link- Link; the link to add to this Network- Throws:
NetworkException- if link already exists in this Network, if name of the link is not unique, or if the start node or the end node of the link are not registered in this Network.
-
removeLink
void removeLink(Link link) throws NetworkException
Unregister a link from this Network.- Parameters:
link- Link; the link to remove from this Network- Throws:
NetworkException- if link does not exist in this Network.
-
containsLink
boolean containsLink(Link link)
Test whether a link is present in this Network.- Parameters:
link- Link; the link to search for in this Network- Returns:
- boolean; true if the link is in this Network; false if the link is not in this Network
-
containsLink
boolean containsLink(String link)
Test whether a link with a given id is present in this Network.- Parameters:
link- String; the id of the link to search for in this Network- Returns:
- boolean; true if a link with the given id exists in this Network; false if no link with the given id exists in this Network
-
getLink
Link getLink(String linkId)
Retrieve a node with a given id from this Network, or null if the id cannot be found.- Parameters:
linkId- String; the id of the link to search for in this Network- Returns:
- Link; the link with the given id, or null if no link with the given id exists in this Network
-
getLink
Link getLink(Node node1, Node node2)
Find a link between node1 and node2 and return it if it exists in this Network. If not, return null.- Parameters:
node1- Node; first nodenode2- Node; second node- Returns:
- Link; the link between node1 and node2 in this Network or null if no such link exists in this Network
-
getLink
Link getLink(String nodeId1, String nodeId2) throws NetworkException
Find a link between node1 and node2 and return it if it exists in this Network. If not, return null.- Parameters:
nodeId1- String; id of the first nodenodeId2- String; id of the second node- Returns:
- Link; the link between node1 and node2 in this Network or null if no such link exists in this Network
- Throws:
NetworkException- if the node(s) cannot be found by their id
-
getObjectMap
ImmutableMap<String,ObjectInterface> getObjectMap()
Return an immutable map of all ObjectInterface implementing objects in this Network.- Returns:
- ImmutableMap<String, ObjectInterface>; the immutable map of all ObjectInterface implementing objects in the Network
-
getObjectMap
<T extends ObjectInterface> ImmutableMap<String,T> getObjectMap(Class<T> objectType)
Return an immutable map of all ObjectInterface implementing objects in this Network that are of type objectType, or any sub type thereof.- Type Parameters:
T- type of object- Parameters:
objectType- Class<T>; the (sub-)type of ObjectInterface that the returned map is reduced to- Returns:
- ImmutableMap<String, ObjectInterface>; the immutable map of all ObjectInterface implementing objects in this Network that are of the type objectType, or any sub-type thereof
-
getObject
<T extends ObjectInterface> T getObject(Class<T> objectType, String objectId)
Retrieve the object of a specific type with a specific id.- Type Parameters:
T- object type- Parameters:
objectType- Class<T>; object type classobjectId- String; id of object- Returns:
- T; the object of given type with given id,
nullif no such object exists in this Network
-
addObject
void addObject(ObjectInterface object) throws NetworkException
Add an ObjectInterface implementing object to this Network.- Parameters:
object- ObjectInterface; the object that implements ObjectInterface- Throws:
NetworkException- if the object already exists in this Network, or the name of the object is not unique.
-
removeObject
void removeObject(ObjectInterface object) throws NetworkException
Remove an ObjectInterface implementing object form this Network.- Parameters:
object- ObjectInterface; the object that implements ObjectInterface- Throws:
NetworkException- if the object does not exist in this Network.
-
containsObject
boolean containsObject(ObjectInterface object)
Test whether the object is present in this Network.- Parameters:
object- ObjectInterface; the object that is tested for presence- Returns:
- boolean; true if the object is present in this Network; false if the object is not present in this Network
-
containsObject
boolean containsObject(String objectId)
Test whether an object with the given id is present in this Network. Note that the objectId should be the fullId of the object. E.g., for lanes this means prefixing link id, etc.- Parameters:
objectId- String; the id that is tested for presence- Returns:
- boolean; true if an object with the given id is present in this Network; false if no object with the given id is present in this Network
-
getInvisibleObjectMap
ImmutableMap<String,InvisibleObjectInterface> getInvisibleObjectMap()
Return an immutable map of all InvisibleObject implementing objects in this Network.- Returns:
- ImmutableMap<String, ObjectInterface>; the immutable map of all ObjectInterface implementing objects in the Network
-
getInvisibleObjectMap
ImmutableMap<String,InvisibleObjectInterface> getInvisibleObjectMap(Class<InvisibleObjectInterface> objectType)
Return an immutable map of all InvisibleObject implementing objects in this Network that are of type objectType, or any sub type thereof.- Parameters:
objectType- Class<InvisibleObjectInterface>; the (sub-)type of InvisibleObject that the returned map is reduced to- Returns:
- ImmutableMap<String, InvisibleObject>; the immutable map of all InvisibleObject implementing objects in the Network that are of the type objectType, or any sub type thereof
-
addInvisibleObject
void addInvisibleObject(InvisibleObjectInterface object) throws NetworkException
Add an ObjectInterface implementing object to this Network.- Parameters:
object- InvisibleObjectInterface; the object that implements ObjectInterface- Throws:
NetworkException- if link already exists in this Network, if name of the object is not unique.
-
removeInvisibleObject
void removeInvisibleObject(InvisibleObjectInterface object) throws NetworkException
Remove an ObjectInterface implementing object form this Network.- Parameters:
object- InvisibleObjectInterface; the object that implements ObjectInterface- Throws:
NetworkException- if the object does not exist in this Network.
-
containsInvisibleObject
boolean containsInvisibleObject(InvisibleObjectInterface object)
Test whether the invisible object is present in this Network.- Parameters:
object- InvisibleObjectInterface; the object that is tested for presence- Returns:
- boolean; whether the invisible object is present in this Network
-
containsInvisibleObject
boolean containsInvisibleObject(String objectId)
Test whether an invisible object with the given id is present in this Network. Note that the objectId should be the fullId of the object; including lane ids, link ids, etc.- Parameters:
objectId- String; the id that is tested for presence- Returns:
- boolean; whether an invisible object with the given id is present in this Network
-
getDefinedRouteMap
ImmutableMap<String,Route> getDefinedRouteMap(GtuType gtuType)
Return an immutable map of routes that exist in this Network for the GTUType.- Parameters:
gtuType- GtuType; the GTUType for which to retrieve the defined routes- Returns:
- ImmutableMap<String, Route>; an immutable map of routes in this Network for the given GTUType, or an empty ImmutableMap if no routes are defined for the given GTUType.
-
addRoute
void addRoute(GtuType gtuType, Route route) throws NetworkException
Add a route to this Network.- Parameters:
gtuType- GtuType; the GTUType for which to add a routeroute- Route; the route to add to this Network.- Throws:
NetworkException- if route already exists in this Network, or if name of the route is not unique, or if one of the nodes of the route is not registered in this Network.
-
removeRoute
void removeRoute(GtuType gtuType, Route route) throws NetworkException
Remove the route from this Network, e.g. because of road maintenance.- Parameters:
gtuType- GtuType; the GTUType for which to remove a routeroute- Route; the route to remove from this Network.- Throws:
NetworkException- if route does not exist in this Network.
-
getRoute
Route getRoute(GtuType gtuType, String routeId)
Return the route with a specific id for a specific GTUType, or null if no route with that id for that GTUType exists in this Network.- Parameters:
gtuType- GtuType; the GTUType for which to retrieve a route based on its id.routeId- String; the route to search for in this Network.- Returns:
- Route; the route or null if no such route exists in this Network
-
containsRoute
boolean containsRoute(GtuType gtuType, Route route)
Determine whether the provided route exists in this Network for the given GTUType.- Parameters:
gtuType- GtuType; the GTUType for which to check whether the route existsroute- Route; the route to check for- Returns:
- boolean; true if the route exists in this Network for the given GTUType, or false if no such route exists in this Network
-
containsRoute
boolean containsRoute(GtuType gtuType, String routeId)
Determine whether a route with the given id exists in this Network for the given GTUType.- Parameters:
gtuType- GtuType; the GTUType for which to check whether the route existsrouteId- String; the id of the route to check for- Returns:
- boolean; true if a route with the given id exists in this Network for the given GTUType; false if no such route exists in this Network
-
getRoutesBetween
Set<Route> getRoutesBetween(GtuType gtuType, Node nodeFrom, Node nodeTo)
Return the the shortest route for a specific GTUType between two nodes in this Network, via a list of intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in this Network, null is returned.- Parameters:
gtuType- GtuType; the GTUType for which to retrieve the defined routesnodeFrom- Node; the start node.nodeTo- Node; the end node.- Returns:
- Set<Route>; a set with routes from the start Node to the end Node in this Network for the specified GTUType; if no route can be found, an empty set is returned.
-
buildGraph
void buildGraph(GtuType gtuType)
(Re)build the underlying graph for the given GTUType.- Parameters:
gtuType- GtuType; the GTUType for which to (re)build the graph
-
getShortestRouteBetween
default CompleteRoute getShortestRouteBetween(GtuType gtuType, Node nodeFrom, Node nodeTo) throws NetworkException
Calculate the shortest route between two nodes in this Network. If no path exists from the start node to the end node in this Network, null is returned. This method returns a CompleteRoute, which includes all nodes to get from start to end. In case the graph for the GTUType has not yet been built, this method will call the buildGraph method.- Parameters:
gtuType- GtuType; the GTUType for which to calculate the shortest routenodeFrom- Node; the start nodenodeTo- Node; the end node- Returns:
- CompleteRoute; the shortest route from nodeFrom to nodeTo in this Network for the specified GTUType. If no such path exists in this Network, null is returned
- Throws:
NetworkException- in case nodes cannot be added to the route, e.g. because they are not directly connected. This can be the case when the links in this Network have changed, but the graph has not been rebuilt. TODO ensure that that NetworkException cannot happen by clearing the graph when the network is changed.
-
getShortestRouteBetween
CompleteRoute getShortestRouteBetween(GtuType gtuType, Node nodeFrom, Node nodeTo, LinkWeight linkWeight) throws NetworkException
Calculate the shortest route between two nodes in this Network. If no path exists from the start node to the end node in this Network, null is returned. This method returns a CompleteRoute, which includes all nodes to get from start to end. This method recalculates the graph.- Parameters:
gtuType- GtuType; the GTUType for which to calculate the shortest routenodeFrom- Node; the start nodenodeTo- Node; the end nodelinkWeight- LinkWeight; link weight- Returns:
- CompleteRoute; the shortest route from nodeFrom to nodeTo in this Network for the specified GTUType. If no path exists in this Network from the start node to the end node for the GTUType, null is returned.
- Throws:
NetworkException- in case nodes cannot be added to the route, e.g. because they are not directly connected. This can be the case when the links in this Network have changed, but the graph has not been rebuilt. TODO ensure that that NetworkException cannot happen by clearing the graph when the network is changed.
-
getShortestRouteBetween
default CompleteRoute getShortestRouteBetween(GtuType gtuType, Node nodeFrom, Node nodeTo, List<Node> nodesVia) throws NetworkException
Calculate the shortest route between two nodes in this Network, via a list of intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in this Network, null is returned. This method returns a CompleteRoute, which includes all nodes to get from start to end. In case the graph for the GTUType has not yet been built, this method will call the buildGraph method.- Parameters:
gtuType- GtuType; the GTUType for which to calculate the shortest routenodeFrom- Node; the start nodenodeTo- Node; the end nodenodesVia- List<Node>; a number of nodes that the GTU has to pass between nodeFrom and nodeTo in the given order- Returns:
- CompleteRoute; the shortest route between two nodes in this Network, via the intermediate nodes. If no path exists from nodeFrom to nodeTo via nodesVia in this Network, null is returned.
- Throws:
NetworkException- in case nodes cannot be added to the route, e.g. because they are not directly connected. This can be the case when the links in this Network have changed, but the graph has not been rebuilt. TODO ensure that that NetworkException cannot happen by clearing the graph when the network is changed.
-
getShortestRouteBetween
CompleteRoute getShortestRouteBetween(GtuType gtuType, Node nodeFrom, Node nodeTo, List<Node> nodesVia, LinkWeight linkWeight) throws NetworkException
Calculate the shortest route between two nodes in this Network, via a list of intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in this Network, null is returned. This method returns a CompleteRoute, which includes all nodes to get from start to end. This method recalculates the graph.- Parameters:
gtuType- GtuType; the GTUType for which to calculate the shortest routenodeFrom- Node; the start nodenodeTo- Node; the end nodenodesVia- List<Node>; a number of nodes that the GTU has to pass between nodeFrom and nodeTo in the given orderlinkWeight- LinkWeight; link weight- Returns:
- CompleteRoute; the shortest route between two nodes in this Network, via the intermediate nodes. If no path exists from the start node to the end node via the intermediate nodes in this Network, null is returned.
- Throws:
NetworkException- in case nodes cannot be added to the route, e.g. because they are not directly connected. This can be the case when the links in this Network have changed, but the graph has not been rebuilt. TODO explain how that is possible if this method recalculates the graph.
-
-