|
57 | 57 | @Category(NeedsCdmUnitTest.class) |
58 | 58 | public class TestIntervalsTimeCoords2D { |
59 | 59 | private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); |
| 60 | + private static final double TOLERANCE = 1e-6; |
60 | 61 |
|
61 | 62 | @Parameterized.Parameters(name = "{0}") |
62 | 63 | public static Collection<Object[]> getTestParameters() throws IOException { |
@@ -113,19 +114,26 @@ public void checkTimeIntervalCoordinates() throws Exception { |
113 | 114 | Variable interval = best.findVariableLocal(dimBounds); |
114 | 115 | assertThat(interval != null).isTrue(); |
115 | 116 |
|
| 117 | + Variable coordinate = best.findVariableLocal(dim.getShortName()); |
| 118 | + assertThat(coordinate != null).isTrue(); |
| 119 | + |
116 | 120 | Array data = interval.read(); |
117 | 121 | IndexIterator iter = data.getIndexIterator(); |
| 122 | + Array coordinateData = coordinate.read(); |
| 123 | + IndexIterator coordinateIter = coordinateData.getIndexIterator(); |
118 | 124 | int idx = 0; |
119 | 125 | while (iter.hasNext()) { |
120 | 126 | int start = iter.getIntNext(); |
121 | 127 | int end = iter.getIntNext(); |
| 128 | + double coordinateValue = coordinateIter.getDoubleNext(); |
122 | 129 | if (start != bounds[idx][0] || end != bounds[idx][1]) { |
123 | 130 | logger.error("bounds " + interval.getFullName() + " for file " + filename + ", parameter " + var.getFullName() |
124 | 131 | + " failed"); |
125 | 132 | logger.error("interval " + start + " - " + end + " known " + bounds[idx][0] + " - " + bounds[idx][0]); |
126 | 133 | } |
127 | 134 | assertThat(start).isEqualTo(bounds[idx][0]); |
128 | 135 | assertThat(end).isEqualTo(bounds[idx][1]); |
| 136 | + assertThat(coordinateValue).isWithin(TOLERANCE).of((start + end) / 2.0); |
129 | 137 | idx++; |
130 | 138 | } |
131 | 139 |
|
|
0 commit comments