OTSRoadNode.java

  1. package org.opentrafficsim.road.network.lane;

  2. import org.djunits.value.vdouble.scalar.Direction;
  3. import org.djutils.exceptions.Throw;
  4. import org.opentrafficsim.core.geometry.DirectedPoint;
  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.  * The Node is a point with an id and a direction. It is used in the network to connect Links.
  11.  * <p>
  12.  * Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  13.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  14.  * <p>
  15.  * $LastChangedDate: 2019-04-25 17:00:14 +0200 (Thu, 25 Apr 2019) $, @version $Revision: 5424 $, by $Author: pknoppers $,
  16.  * initial version May 5, 2019 <br>
  17.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  18.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  19.  * @author <a href="http://www.citg.tudelft.nl">Guus Tamminga</a>
  20.  */
  21. public class OTSRoadNode extends OTSNode
  22. {
  23.     /** ... */
  24.     private static final long serialVersionUID = 20190528L;

  25.     /** Direction of traffic at this node. */
  26.     private final Direction direction;

  27.     /**
  28.      * Construct a new OTSRoadNode.
  29.      * @param network Network; the network
  30.      * @param id String; name of the node
  31.      * @param point OTSPoint3D location of the node
  32.      * @param direction Direction; driving direction at the node
  33.      * @throws NetworkException if node already exists in the network, or if name of the node is not unique.
  34.      */
  35.     public OTSRoadNode(final Network network, final String id, final OTSPoint3D point, final Direction direction)
  36.             throws NetworkException
  37.     {
  38.         super(network, id, point);
  39.         Throw.whenNull(direction, "direction cannot be null");
  40.         this.direction = direction;
  41.     }

  42.     @Override
  43.     public final DirectedPoint getLocation()
  44.     {
  45.         OTSPoint3D p = getPoint();
  46.         return new DirectedPoint(p.x, p.y, p.z, 0, 0, this.direction.si);
  47.     }
  48.    
  49. }