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.kpi.interfaces.GtuTypeDataInterface;
6 import org.opentrafficsim.kpi.interfaces.NodeDataInterface;
7 import org.opentrafficsim.kpi.interfaces.RouteDataInterface;
8 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
9
10
11
12
13
14
15
16
17
18
19
20 public class GtuData implements GtuDataInterface
21 {
22
23
24 private final LaneBasedGTU gtu;
25
26
27
28
29 public GtuData(final LaneBasedGTU gtu)
30 {
31 this.gtu = gtu;
32 }
33
34
35
36
37 public final LaneBasedGTU getGtu()
38 {
39 return this.gtu;
40 }
41
42
43
44 @Override
45 public final String getId()
46 {
47 return this.gtu.getId();
48 }
49
50
51 @Override
52 public final NodeDataInterface getOriginNodeData()
53 {
54 try
55 {
56 return new NodeData(this.gtu.getStrategicalPlanner().getRoute().originNode());
57 }
58 catch (NetworkException exception)
59 {
60 throw new RuntimeException("Could not get origin node.", exception);
61 }
62 }
63
64
65 @Override
66 public final NodeDataInterface getDestinationNodeData()
67 {
68 try
69 {
70 return new NodeData(this.gtu.getStrategicalPlanner().getRoute().destinationNode());
71 }
72 catch (NetworkException exception)
73 {
74 throw new RuntimeException("Could not get destination node.", exception);
75 }
76 }
77
78
79 @Override
80 public final GtuTypeDataInterface getGtuTypeData()
81 {
82 return new GtuTypeData(this.gtu.getGTUType());
83 }
84
85
86 @Override
87 public final RouteDataInterface getRouteData()
88 {
89 return new RouteData(this.gtu.getStrategicalPlanner().getRoute());
90 }
91
92
93 @Override
94 public final String toString()
95 {
96 return "GtuData [gtu=" + this.gtu + "]";
97 }
98
99 }