fixed NOAA tests after the world magnetic model was updated

This commit is contained in:
Axel Uhl
2019-12-11 15:34:06 +01:00
parent efa7b56222
commit d07b98e67d
2 changed files with 14 additions and 18 deletions
@@ -21,28 +21,24 @@ public abstract class DeclinationImportTest<I extends DeclinationImporter> exten
@Test
public void importSimpleDeclination() throws IOException, ParseException, ParserConfigurationException, SAXException {
Declination record = importer.importRecord(new DegreePosition(53, 3),
new MillisecondsTimePoint(simpleDateFormat.parse("2016-05-27").getTime()));
assertEquals(0.26307, record.getBearing().getDegrees(), 0.05);
new MillisecondsTimePoint(simpleDateFormat.parse("2020-04-17").getTime()));
assertEquals(1.03748, record.getBearing().getDegrees(), 0.05);
assertEquals(0.14795, record.getAnnualChange().getDegrees(), 0.05);
}
@Test
public void importSouthernHemisphereDeclination() throws IOException, ParseException, ParserConfigurationException, SAXException {
long start = System.currentTimeMillis();
Declination record = importer.importRecord(new DegreePosition(-10, 3),
new MillisecondsTimePoint(simpleDateFormat.parse("2017-05-27").getTime()));
System.out.println("took "+(System.currentTimeMillis()-start)+"ms");
assertEquals(-8.44581, record.getBearing().getDegrees(), 0.2);
assertEquals(0.17712, record.getAnnualChange().getDegrees(), 0.2);
new MillisecondsTimePoint(simpleDateFormat.parse("2019-12-14").getTime()));
assertEquals(-7.8071, record.getBearing().getDegrees(), 0.05);
assertEquals(0.17712, record.getAnnualChange().getDegrees(), 0.05);
}
@Test
public void readOnlineOrFromFile() throws IOException, ClassNotFoundException, ParseException {
Declination declination = importer.getDeclination(new DegreePosition(53, 3),
new MillisecondsTimePoint(simpleDateFormat.parse("2018-05-27").getTime()),
new MillisecondsTimePoint(simpleDateFormat.parse("2019-12-12").getTime()),
/* timeoutForOnlineFetchInMilliseconds */ 10000);
assertNotNull(declination);
System.out.println(declination);
}
}
@@ -21,23 +21,23 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
public abstract class SimpleDeclinationTest<I extends DeclinationImporter> extends AbstractDeclinationTest<I> {
@Test
public void testSimpleCorrection() throws IOException, ParseException, ParserConfigurationException, SAXException {
final MillisecondsTimePoint timePoint = new MillisecondsTimePoint(simpleDateFormat.parse("2019-05-27").getTime());
final MillisecondsTimePoint timePoint = new MillisecondsTimePoint(simpleDateFormat.parse("2019-12-10").getTime());
Declination record = importer.importRecord(new DegreePosition(53, 3), timePoint);
assertEquals(0.70594, record.getBearing().getDegrees(), 0.2);
assertEquals(0.14745, record.getAnnualChange().getDegrees(), 0.2);
assertEquals(0.96886, record.getBearing().getDegrees(), 0.1);
assertEquals(0.19616, record.getAnnualChange().getDegrees(), 0.01);
TimePoint oneYearLater = timePoint.plus(Duration.ONE_YEAR);
Bearing bearing = record.getBearingCorrectedTo(oneYearLater);
assertEquals(0.70594+0.14745, bearing.getDegrees(), 0.2);
assertEquals(0.96886+record.getAnnualChange().getDegrees(), bearing.getDegrees(), 0.1);
}
@Test
public void testBackwardCorrection() throws IOException, ParseException, ParserConfigurationException, SAXException {
final MillisecondsTimePoint timePoint = new MillisecondsTimePoint(simpleDateFormat.parse("2019-05-27").getTime());
final MillisecondsTimePoint timePoint = new MillisecondsTimePoint(simpleDateFormat.parse("2019-12-11").getTime());
Declination record = importer.importRecord(new DegreePosition(53, 3), timePoint);
assertEquals(0.70594, record.getBearing().getDegrees(), 0.2);
assertEquals(0.14745, record.getAnnualChange().getDegrees(), 0.2);
assertEquals(0.96886, record.getBearing().getDegrees(), 0.1);
assertEquals(0.19616, record.getAnnualChange().getDegrees(), 0.01);
TimePoint oneYearEarlier = timePoint.minus(Duration.ONE_YEAR);
Bearing bearing = record.getBearingCorrectedTo(oneYearEarlier);
assertEquals(0.70594-0.14745, bearing.getDegrees(), 0.2);
assertEquals(0.96886-record.getAnnualChange().getDegrees(), bearing.getDegrees(), 0.1);
}
}