1 package org.opentrafficsim.core.network; 2 3 import java.io.Serializable; 4 import java.util.Set; 5 6 import org.djutils.immutablecollections.ImmutableSet; 7 import org.opentrafficsim.base.Identifiable; 8 import org.opentrafficsim.core.animation.Drawable; 9 import org.opentrafficsim.core.geometry.OTSPoint3D; 10 import org.opentrafficsim.core.gtu.GTUType; 11 12 import nl.tudelft.simulation.dsol.animation.Locatable; 13 14 /** 15 * The Node is a point with an id. It is used in the network to connect Links. 16 * <p> 17 * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 18 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>. 19 * <p> 20 * $LastChangedDate: 2019-02-27 07:19:36 +0100 (Wed, 27 Feb 2019) $, @version $Revision: 5014 $, by $Author: averbraeck $, 21 * initial version Aug 19, 2014 <br> 22 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 23 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a> 24 * @author <a href="http://www.citg.tudelft.nl">Guus Tamminga</a> 25 */ 26 public interface Node extends Locatable, Serializable, Identifiable, Drawable 27 { 28 /** 29 * Return the network in which this link is registered. Cannot be null. 30 * @return Network; the network in which this link is registered 31 */ 32 Network getNetwork(); 33 34 /** @return node id. */ 35 @Override 36 String getId(); 37 38 /** @return point. */ 39 OTSPoint3D getPoint(); 40 41 /** 42 * Add a link to this Node. 43 * @param link Link; the link to add. 44 */ 45 void addLink(Link link); 46 47 /** 48 * Remove a link from this Node. 49 * @param link Link; the link to remove. 50 */ 51 void removeLink(Link link); 52 53 /** @return a safe copy of the links connected to this Node */ 54 ImmutableSet<Link> getLinks(); 55 56 /** 57 * Determine the links connecting from the previous link via this Node for the given GTU type. 58 * @param gtuType GTUType; the GTU type to determine the next links for 59 * @param prevLink Link; the incoming link to the Node 60 * @return a set of links connecting from the previous link via this Node for the given GTU type 61 * @throws NetworkException if the incoming link is not connected to this node for the given GTU type 62 */ 63 Set<Link> nextLinks(GTUType gtuType, Link prevLink) throws NetworkException; 64 65 /** 66 * Check if the current node is linked to the given Node in the specified direction for the given GTUType. This can mean 67 * there is a Link from this node to toNode, and the LongitudinalDirectionality for the Link between this node and toNode is 68 * FORWARD or BOTH; or there is a Link from toNode to this node, and the LongitudinalDirectionality for the Link between 69 * toNode and this node is BACKWARD or BOTH for the provided GTUType. 70 * @param gtuType GTUType; the GTU type to check the connection for. 71 * @param toNode Node; the to node 72 * @return whether two nodes are linked in the specified direction. 73 */ 74 boolean isDirectionallyConnectedTo(GTUType gtuType, Node toNode); 75 76 }