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 @Override
44 public final String getId()
45 {
46 return this.gtu.getId();
47 }
48
49
50 @Override
51 public final NodeDataInterface getOriginNodeData()
52 {
53 try
54 {
55 return new NodeData(this.gtu.getStrategicalPlanner().getRoute().originNode());
56 }
57 catch (NetworkException exception)
58 {
59 throw new RuntimeException("Could not get origin node.", exception);
60 }
61 }
62
63
64 @Override
65 public final NodeDataInterface getDestinationNodeData()
66 {
67 try
68 {
69 return new NodeData(this.gtu.getStrategicalPlanner().getRoute().destinationNode());
70 }
71 catch (NetworkException exception)
72 {
73 throw new RuntimeException("Could not get destination node.", exception);
74 }
75 }
76
77
78 @Override
79 public final GtuTypeDataInterface getGtuTypeData()
80 {
81 return new GtuTypeData(this.gtu.getGTUType());
82 }
83
84
85 @Override
86 public final RouteDataInterface getRouteData()
87 {
88 return new RouteData(this.gtu.getStrategicalPlanner().getRoute());
89 }
90
91
92 @Override
93 public final String toString()
94 {
95 return "GtuData [gtu=" + this.gtu + "]";
96 }
97
98 }