View Javadoc
1   package org.opentrafficsim.road.network.sampling;
2   
3   import org.opentrafficsim.core.network.NetworkException;
4   import org.opentrafficsim.kpi.interfaces.GtuDataInterface;
5   import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
6   
7   /**
8    * Gtu representation in road sampler.
9    * <p>
10   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
12   * <p>
13   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 13 okt. 2016 <br>
14   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
16   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
17   */
18  public class GtuData implements GtuDataInterface
19  {
20  
21      /** Gtu. */
22      private final LaneBasedGTU gtu;
23  
24      /**
25       * @param gtu LaneBasedGTU; gtu
26       */
27      public GtuData(final LaneBasedGTU gtu)
28      {
29          this.gtu = gtu;
30      }
31  
32      /**
33       * @return gtu.
34       */
35      public final LaneBasedGTU getGtu()
36      {
37          return this.gtu;
38      }
39  
40      /** {@inheritDoc} */
41      @Override
42      public final String getId()
43      {
44          return this.gtu.getId();
45      }
46  
47      /** {@inheritDoc} */
48      @Override
49      public final NodeData getOriginNodeData()
50      {
51          try
52          {
53              return new NodeData(this.gtu.getStrategicalPlanner().getRoute().originNode());
54          }
55          catch (NetworkException exception)
56          {
57              throw new RuntimeException("Could not get origin node.", exception);
58          }
59      }
60  
61      /** {@inheritDoc} */
62      @Override
63      public final NodeData getDestinationNodeData()
64      {
65          try
66          {
67              return new NodeData(this.gtu.getStrategicalPlanner().getRoute().destinationNode());
68          }
69          catch (NetworkException exception)
70          {
71              throw new RuntimeException("Could not get destination node.", exception);
72          }
73      }
74  
75      /** {@inheritDoc} */
76      @Override
77      public final GtuTypeData getGtuTypeData()
78      {
79          return new GtuTypeData(this.gtu.getGTUType());
80      }
81  
82      /** {@inheritDoc} */
83      @Override
84      public final RouteData getRouteData()
85      {
86          return new RouteData(this.gtu.getStrategicalPlanner().getRoute());
87      }
88  
89      /** {@inheritDoc} */
90      @Override
91      public final String toString()
92      {
93          return "GtuData [gtu=" + this.gtu + "]";
94      }
95  
96  }