AbstractValueProvider implements ValueProvider { protected static double angularAverage(double angle1, double angle2) { if (inQuadrant1(angle1) && inQuadrant4(angle2)) { angle2 = angle2 - 360.0; } else if (inQuadrant1(angle2) && inQuadrant4(angle1)) { angle1 = angle1 - 360.0; } return (angle1 + angle2) / 2.0; }  @Override byte getValue(int seqnum, byte noDataValue); @Override short getValue(int seqnum, short noDataValue); @Override int getValue(int seqnum, int noDataValue); @Override float getValue(int seqnum, float noDataValue);  }
@Test public void testAngularAverage() throws Exception { assertEquals(0.0, AbstractValueProvider.angularAverage(89.0, 91.0), 90.0); assertEquals(0.0, AbstractValueProvider.angularAverage(91.0, 89.0), 90.0); assertEquals(0.0, AbstractValueProvider.angularAverage(179.0, 181.0), 180.0); assertEquals(0.0, AbstractValueProvider.angularAverage(181.0, 179.0), 180.0); assertEquals(0.0, AbstractValueProvider.angularAverage(269.0, 271.0), 270.0); assertEquals(0.0, AbstractValueProvider.angularAverage(271.0, 269.0), 270.0); assertEquals(0.0, AbstractValueProvider.angularAverage(1.0, 359.0), 0.0); assertEquals(0.0, AbstractValueProvider.angularAverage(359.0, 1.0), 0.0); }