1 package org.opentrafficsim.road.network.sampling;
2
3 import org.opentrafficsim.core.network.NetworkException;
4 import org.opentrafficsim.kpi.interfaces.GtuData;
5 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
6
7
8
9
10
11
12
13
14
15
16
17 public class GtuDataRoad implements GtuData
18 {
19
20
21 private final LaneBasedGtu gtu;
22
23
24
25
26 public GtuDataRoad(final LaneBasedGtu gtu)
27 {
28 this.gtu = gtu;
29 }
30
31
32
33
34 public final LaneBasedGtu getGtu()
35 {
36 return this.gtu;
37 }
38
39
40 @Override
41 public final String getId()
42 {
43 return this.gtu.getId();
44 }
45
46
47 @Override
48 public final String getOriginId()
49 {
50 try
51 {
52 return this.gtu.getStrategicalPlanner().getRoute().originNode().getId();
53 }
54 catch (NetworkException exception)
55 {
56 throw new RuntimeException("Could not get origin node.", exception);
57 }
58 }
59
60
61 @Override
62 public final String getDestinationId()
63 {
64 try
65 {
66 return this.gtu.getStrategicalPlanner().getRoute().destinationNode().getId();
67 }
68 catch (NetworkException exception)
69 {
70 throw new RuntimeException("Could not get destination node.", exception);
71 }
72 }
73
74
75 @Override
76 public final String getGtuId()
77 {
78 return this.gtu.getType().getId();
79 }
80
81
82 @Override
83 public final String getRouteId()
84 {
85 return this.gtu.getStrategicalPlanner().getRoute().getId();
86 }
87
88
89 @Override
90 public final String toString()
91 {
92 return "GtuData [gtu=" + this.gtu + "]";
93 }
94
95 }