mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-25 06:58:39 +00:00
fixed Expedition wind declination correction test; VeryCompactWindFixImpl has less accuracy than the test demanded
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ public abstract class DeclinationImporter {
|
||||
result.notifyAll();
|
||||
}
|
||||
} catch (IOException | ParserConfigurationException | SAXException e) {
|
||||
logger.log(Level.FINE, "Exception while trying to load magnetic declination online", e);
|
||||
logger.log(Level.INFO, "Exception while trying to load magnetic declination online", e);
|
||||
synchronized (result) {
|
||||
result.notifyAll(); // wake up waiter; no result will show up anymore
|
||||
}
|
||||
|
||||
+10
-7
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user