Interface Network

    • 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 node
        node2 - 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 node
        nodeId2 - 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 class
        objectId - String; id of object
        Returns:
        T; the object of given type with given id, null if 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 route
        route - 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 route
        route - 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 exists
        route - 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 exists
        routeId - 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 routes
        nodeFrom - 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 route
        nodeFrom - Node; the start node
        nodeTo - 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 route
        nodeFrom - Node; the start node
        nodeTo - Node; the end node
        linkWeight - 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 route
        nodeFrom - Node; the start node
        nodeTo - Node; the end node
        nodesVia - 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 route
        nodeFrom - Node; the start node
        nodeTo - Node; the end node
        nodesVia - List<Node>; a number of nodes that the GTU has to pass between nodeFrom and nodeTo in the given order
        linkWeight - 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.