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   
9   
10  
11  
12  
13  
14  
15  
16  
17  
18  public class GtuData implements GtuDataInterface
19  {
20  
21      
22      private final LaneBasedGTU gtu;
23  
24      
25  
26  
27      public GtuData(final LaneBasedGTU gtu)
28      {
29          this.gtu = gtu;
30      }
31  
32      
33  
34  
35      public final LaneBasedGTU getGtu()
36      {
37          return this.gtu;
38      }
39  
40      
41      @Override
42      public final String getId()
43      {
44          return this.gtu.getId();
45      }
46  
47      
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      
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      
76      @Override
77      public final GtuTypeData getGtuTypeData()
78      {
79          return new GtuTypeData(this.gtu.getGTUType());
80      }
81  
82      
83      @Override
84      public final RouteData getRouteData()
85      {
86          return new RouteData(this.gtu.getStrategicalPlanner().getRoute());
87      }
88  
89      
90      @Override
91      public final String toString()
92      {
93          return "GtuData [gtu=" + this.gtu + "]";
94      }
95  
96  }