View Javadoc
1   package org.opentrafficsim.road.network.lane;
2   
3   import org.djunits.value.vdouble.scalar.Direction;
4   import org.djutils.exceptions.Throw;
5   import org.opentrafficsim.core.geometry.OTSPoint3D;
6   import org.opentrafficsim.core.network.Network;
7   import org.opentrafficsim.core.network.NetworkException;
8   import org.opentrafficsim.core.network.OTSNode;
9   
10  import org.opentrafficsim.core.geometry.DirectedPoint;
11  
12  /**
13   * The Node is a point with an id and a direction. It is used in the network to connect Links.
14   * <p>
15   * Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
17   * <p>
18   * $LastChangedDate: 2019-04-25 17:00:14 +0200 (Thu, 25 Apr 2019) $, @version $Revision: 5424 $, by $Author: pknoppers $,
19   * initial version May 5, 2019 <br>
20   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
21   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
22   * @author <a href="http://www.citg.tudelft.nl">Guus Tamminga</a>
23   */
24  public class OTSRoadNode extends OTSNode
25  {
26      /** ... */
27      private static final long serialVersionUID = 20190528L;
28  
29      /** Direction of traffic at this node. */
30      private final Direction direction;
31  
32      /**
33       * Construct a new OTSRoadNode.
34       * @param network Network; the network
35       * @param id String; name of the node
36       * @param point OTSPoint3D location of the node
37       * @param direction Direction; driving direction at the node
38       * @throws NetworkException if node already exists in the network, or if name of the node is not unique.
39       */
40      public OTSRoadNode(final Network network, final String id, final OTSPoint3D point, final Direction direction)
41              throws NetworkException
42      {
43          super(network, id, point);
44          Throw.whenNull(direction, "direction cannot be null");
45          this.direction = direction;
46      }
47  
48      @Override
49      public final DirectedPoint getLocation()
50      {
51          OTSPoint3D p = getPoint();
52          return new DirectedPoint(p.x, p.y, p.z, 0, 0, this.direction.si);
53      }
54      
55  }