1 package org.opentrafficsim.road.network.sampling.data;
2
3 import org.djunits.unit.DirectionUnit;
4 import org.djunits.value.ValueRuntimeException;
5 import org.djunits.value.vfloat.scalar.FloatDirection;
6 import org.djunits.value.vfloat.vector.FloatDirectionVector;
7 import org.opentrafficsim.kpi.sampling.data.ExtendedDataFloat;
8 import org.opentrafficsim.road.network.sampling.GtuDataRoad;
9
10
11
12
13
14 public class WorldDirData extends ExtendedDataFloat<DirectionUnit, FloatDirection, FloatDirectionVector, GtuDataRoad>
15 {
16
17
18
19
20 public WorldDirData()
21 {
22 super("WorldDir", "World direction", FloatDirection.class);
23 }
24
25
26 @Override
27 public FloatDirection getValue(final GtuDataRoad gtu)
28 {
29 return convertValue((float) gtu.getGtu().getLocation().dirZ);
30 }
31
32
33 @Override
34 protected FloatDirection convertValue(final float value)
35 {
36 return FloatDirection.instantiateSI(value);
37 }
38
39
40 @Override
41 protected FloatDirectionVector convert(final float[] storage) throws ValueRuntimeException
42 {
43 return new FloatDirectionVector(storage);
44 }
45
46
47 @Override
48 public FloatDirection parseValue(final String string)
49 {
50 return FloatDirection.instantiateSI(Float.valueOf(string));
51 }
52
53 }