fixed Expedition wind declination correction test; VeryCompactWindFixImpl has less accuracy than the test demanded

This commit is contained in:
Axel Uhl
2020-04-09 14:35:05 +02:00
parent 510485f711
commit 03c0e35591
2 changed files with 11 additions and 8 deletions
@@ -76,8 +76,8 @@ public class UDPExpeditionReceiverTest {
private String[] validLines;
private String[] someValidWithFourInvalidLines;
final List<ExpeditionMessage> messages = new ArrayList<ExpeditionMessage>();
final int PORT = 9876;
private final List<ExpeditionMessage> messages = new ArrayList<ExpeditionMessage>();
private final int PORT = 9929;
private DatagramPacket packet;
private DatagramSocket socket;
private byte[] buf;
@@ -447,17 +447,20 @@ public class UDPExpeditionReceiverTest {
String[] lines = new String[validLines.length+1];
lines[0] = "#0,1,7.900,2,-42.0,3,25.90,9,323.0,13,326.0,48,54.511867,49,10.152700,50,340.3,146,40348.578310*25";
System.arraycopy(validLines, 0, lines, 1, validLines.length);
// ensure declination service has 2011 loaded (which takes a few seconds)
// ensure declination service has 2010 and 2011 loaded (which takes a few seconds)
declinationService.getDeclination(
new MillisecondsTimePoint(new SimpleDateFormat("yyyy-MM-dd").parse("2010-07-01").getTime()),
new DegreePosition(54, 9), /* timeoutForOnlineFetchInMilliseconds */10000);
declinationService.getDeclination(
new MillisecondsTimePoint(new SimpleDateFormat("yyyy-MM-dd").parse("2011-07-01").getTime()),
new DegreePosition(54, 9), /* timeoutForOnlineFetchInMilliseconds */3000);
new DegreePosition(54, 9), /* timeoutForOnlineFetchInMilliseconds */10000);
sendAndWaitABit(lines);
Thread.sleep(3000); // wait until at least the declination was received
assertEquals(lines.length, messages.size());
// note that the tracks are ordered by timestamps; however, not all Expedition messages have an original timestamp.
// So, some of them are timestamped with "now" which shuffles ordering. We keep track of the matched wind fixes in
// a map
Set<Wind> matched = new HashSet<Wind>();
final Set<Wind> matched = new HashSet<>();
// now assert that wind bearings have undergone declination correction
Position lastKnownPosition = null;
for (ExpeditionMessage m : messages) {
@@ -466,13 +469,13 @@ public class UDPExpeditionReceiverTest {
}
if (m.getTrueWind() != null) {
Declination declination = declinationService.getDeclination(m.getTimePoint(), lastKnownPosition,
/* timeoutForOnlineFetchInMilliseconds */5000);
/* timeoutForOnlineFetchInMilliseconds */10000);
race.getWindTrack().lockForRead();
try {
for (Wind recordedWind : race.getWindTrack().getRawFixes()) {
if (Math.abs(m.getTrueWindBearing().getDegrees()
+ declination.getBearingCorrectedTo(m.getTimePoint()).getDegrees()
- recordedWind.getBearing().getDegrees()) <= 0.0000001) {
- recordedWind.getBearing().getDegrees()) <= 0.01) { // not more precise due to the use of VeryCompactWindFix in wind track
matched.add(recordedWind);
break;
}