1 package org.opentrafficsim.core.egtf.typed;
2
3 import org.djunits.unit.DurationUnit;
4 import org.djunits.unit.LengthUnit;
5 import org.djunits.value.StorageType;
6 import org.djunits.value.vdouble.vector.DurationVector;
7 import org.djunits.value.vdouble.vector.LengthVector;
8 import org.djutils.exceptions.Try;
9 import org.opentrafficsim.core.egtf.Filter;
10 import org.opentrafficsim.core.egtf.Quantity;
11
12
13
14
15
16
17
18
19
20
21
22
23 public class TypedFilter implements Filter
24 {
25
26
27 private final Filter filter;
28
29
30
31
32
33 TypedFilter(final Filter filter)
34 {
35 this.filter = filter;
36 }
37
38
39 @Override
40 public double[] getLocation()
41 {
42 return this.filter.getLocation();
43 }
44
45
46
47
48
49 public LengthVector getLocationVector()
50 {
51 return Try.assign(() -> new LengthVector(getLocation(), LengthUnit.SI, StorageType.DENSE),
52 "Exception while creating LengthVector");
53 }
54
55
56 @Override
57 public double[] getTime()
58 {
59 return this.filter.getTime();
60 }
61
62
63
64
65
66 public DurationVector getTimeVector()
67 {
68 return Try.assign(() -> new DurationVector(getTime(), DurationUnit.SI, StorageType.DENSE),
69 "Exception while creating DurationVector");
70 }
71
72
73 @Override
74 public double[][] getSI(final Quantity<?, ?> quantity)
75 {
76 return this.filter.getSI(quantity);
77 }
78
79
80 @Override
81 public <K> K get(final Quantity<?, K> quantity)
82 {
83 return this.filter.get(quantity);
84 }
85
86
87 @Override
88 public String toString()
89 {
90 return "TypedFilter [filter=" + this.filter + "]";
91 }
92
93 }