View Javadoc
1   package org.opentrafficsim.water.network;
2   
3   import java.util.Map;
4   import java.util.SortedMap;
5   import java.util.TreeMap;
6   
7   import org.djunits.value.vdouble.scalar.Length;
8   import org.opentrafficsim.core.dsol.OTSDEVSSimulator;
9   import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
10  import org.opentrafficsim.core.geometry.OTSLine3D;
11  import org.opentrafficsim.core.gtu.GTUType;
12  import org.opentrafficsim.core.network.LinkType;
13  import org.opentrafficsim.core.network.LongitudinalDirectionality;
14  import org.opentrafficsim.core.network.Network;
15  import org.opentrafficsim.core.network.NetworkException;
16  import org.opentrafficsim.core.network.OTSLink;
17  import org.opentrafficsim.core.network.OTSNode;
18  import org.opentrafficsim.water.network.infra.Obstacle;
19  import org.opentrafficsim.water.transfer.Terminal;
20  
21  /**
22   * A waterway, i.e. a river, canal or sailable route on a lake or sea.
23   * <p>
24   * Copyright (c) 2013-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
25   * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
26   * </p>
27   * <p>
28   * Based on software from the IDVV project, which is Copyright (c) 2013 Rijkswaterstaat - Dienst Water, Verkeer en Leefomgeving
29   * and licensed without restrictions to Delft University of Technology, including the right to sub-license sources and derived
30   * products to third parties.
31   * </p>
32   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
33   * initial version Nov 6, 2016 <br>
34   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
35   */
36  public class Waterway extends OTSLink
37  {
38      /** */
39      private static final long serialVersionUID = 20150927L;
40  
41      /** name. */
42      private final String name;
43  
44      /** current; positive direction is along the design line. */
45      private double current;
46  
47      /** list of obstacles, sorted on distance along the design line. */
48      private SortedMap<Length, Obstacle> obstacles = new TreeMap<>();
49  
50      /** list of terminals, sorted on distance along the design line. */
51      private SortedMap<Length, Terminal> terminals = new TreeMap<>();
52  
53      /**
54       * Construct a new waterway.
55       * @param network the network.
56       * @param id the waterway id
57       * @param name the name
58       * @param startNode start node (directional)
59       * @param endNode end node (directional)
60       * @param linkType Link type to indicate compatibility with GTU types
61       * @param designLine the OTSLine3D design line of the Link
62       * @param simulator the simulator to schedule events on
63       * @param directionality to indicate the general direction of the waterway (FORWARD = in the direction of the design line;
64       *            BACKWARD is in the opposite direction; BOTH is a waterway that can be used in both directions; NONE is a
65       *            waterway that cannot be used for sailing.
66       * @throws NetworkException when waterway with this id already exists
67       */
68      @SuppressWarnings("checkstyle:parameternumber")
69      public Waterway(final Network network, final String id, final String name, final OTSNode startNode, final OTSNode endNode,
70              final LinkType linkType, final OTSLine3D designLine, final OTSDEVSSimulatorInterface simulator,
71              final LongitudinalDirectionality directionality) throws NetworkException
72      {
73          super(network, id, startNode, endNode, linkType, designLine, simulator, directionality);
74          this.name = name;
75      }
76  
77      /**
78       * Construct a new waterway.
79       * @param network the network.
80       * @param id the waterway id
81       * @param name the name
82       * @param startNode start node (directional)
83       * @param endNode end node (directional)
84       * @param linkType Link type to indicate compatibility with GTU types
85       * @param designLine the OTSLine3D design line of the Link
86       * @param simulator the simujlator to schedule events on
87       * @param directionalityMap the directions for different type of ships; it might be that all or certain types of ships are
88       *            only allowed to use a canal in one direction. Furthermore, the directions can limit waterways for certain
89       *            classes of ships. Set the LongitudinalDirectionality to NONE for ships that are not allowed to sail this
90       *            waterway.
91       * @throws NetworkException when waterway with this id already exists
92       */
93      @SuppressWarnings("checkstyle:parameternumber")
94      public Waterway(final Network network, final String id, final String name, final OTSNode startNode, final OTSNode endNode,
95              final LinkType linkType, final OTSLine3D designLine, final OTSDEVSSimulatorInterface simulator,
96              final Map<GTUType, LongitudinalDirectionality> directionalityMap) throws NetworkException
97      {
98          super(network, id, startNode, endNode, linkType, designLine, simulator, directionalityMap);
99          this.name = name;
100     }
101 
102     /**
103      * @return name
104      */
105     public final String getName()
106     {
107         return this.name;
108     }
109 
110 }