1 package org.opentrafficsim.core.egtf;
2
3 import java.util.Arrays;
4 import java.util.Map;
5
6
7
8
9
10
11
12
13
14
15 public class FilterDouble implements Filter
16 {
17
18
19 private final double[] location;
20
21
22 private final double[] time;
23
24
25 private final Map<Quantity<?, ?>, double[][]> map;
26
27
28
29
30
31
32
33 protected FilterDouble(final double[] location, final double[] time, final Map<Quantity<?, ?>, double[][]> map)
34 {
35 this.location = location;
36 this.time = time;
37 this.map = map;
38 }
39
40
41 @Override
42 public double[] getLocation()
43 {
44 return this.location;
45 }
46
47
48 @Override
49 public double[] getTime()
50 {
51 return this.time;
52 }
53
54
55 @Override
56 public double[][] getSI(final Quantity<?, ?> quantity)
57 {
58 return this.map.get(quantity);
59 }
60
61
62 @Override
63 public <K> K get(final Quantity<?, K> quantity)
64 {
65 if (!this.map.containsKey(quantity))
66 {
67 throw new IllegalStateException(String.format("Filter does not contain data for quantity %s", quantity.getName()));
68 }
69 return quantity.convert(this.map.get(quantity));
70 }
71
72
73 @Override
74 public String toString()
75 {
76 return "Filter [location=" + Arrays.toString(this.location) + ", time=" + Arrays.toString(this.time) + "]";
77 }
78
79 }