GTUDirectionality.java

  1. package org.opentrafficsim.core.gtu;

  2. /**
  3.  * Longitudinal driving directions for a GTU. The driving directions can be used on a link or a lane. The two possible values
  4.  * are <code>DIR_PLUS</code> and <code>DIR_MINUS</code>.
  5.  * <p>
  6.  * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
  7.  * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
  8.  * <p>
  9.  * $LastChangedDate: 2015-11-11 13:25:26 +0100 (Wed, 11 Nov 2015) $, @version $Revision: 1548 $, by $Author: averbraeck $,
  10.  * initial version Nov 11, 2015 <br>
  11.  * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
  12.  * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
  13.  */
  14. public enum GTUDirectionality
  15. {
  16.     /**
  17.      * Driving direction matches the direction of the graph, increasing fractional position when driving in this direction.
  18.      */
  19.     DIR_PLUS,
  20.     /**
  21.      * Driving direction opposite to the direction of the graph, decreasing fractional position when driving in this direction.
  22.      */
  23.     DIR_MINUS;

  24.     /**
  25.      * @return whether the gtu drives in the design direction on the link
  26.      */
  27.     public boolean isPlus()
  28.     {
  29.         return this.equals(DIR_PLUS);
  30.     }

  31.     /**
  32.      * @return whether the gtu drives against the design direction on the link
  33.      */
  34.     public boolean isMinus()
  35.     {
  36.         return this.equals(DIR_MINUS);
  37.     }

  38.     /**
  39.      * Returns the flipped direction.
  40.      * @return GTUDirectionality; flipped direction.
  41.      */
  42.     public GTUDirectionality flip()
  43.     {
  44.         return isPlus() ? DIR_MINUS : DIR_PLUS;
  45.     }
  46. }