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