mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-03 10:53:49 +00:00
made safe for empty wind tracks
This commit is contained in:
1 parent
337cf37bb8
commit
4468e905d6
2 files changed
+14
-3
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -19,6 +20,12 @@ import com.sap.sailing.domain.tracking.impl.WindTrackImpl;
|
||||
|
||||
public class WindTest {
|
||||
private static final int AVERAGING_INTERVAL_MILLIS = 30000 /* 30s averaging interval */;
|
||||
|
||||
@Test
|
||||
public void testEmptyTrackYieldsNullAsWindEstimate() {
|
||||
WindTrack track = new WindTrackImpl(AVERAGING_INTERVAL_MILLIS);
|
||||
assertNull(track.getEstimatedWind(new DegreePosition(0, 0), MillisecondsTimePoint.now()));
|
||||
}
|
||||
|
||||
/**
|
||||
* If the wind track has areas with no data, and wind information is requested for such an interval,
|
||||
|
||||
+7
-3
@@ -138,7 +138,7 @@ public class WindTrackImpl extends TrackImpl<Wind> implements WindTrack {
|
||||
} else {
|
||||
beforeWind = null;
|
||||
}
|
||||
} else {
|
||||
} else if (afterWind != null) {
|
||||
if (afterIntervalStart == null) {
|
||||
afterIntervalStart = afterWind.getTimePoint();
|
||||
}
|
||||
@@ -154,8 +154,12 @@ public class WindTrackImpl extends TrackImpl<Wind> implements WindTrack {
|
||||
}
|
||||
}
|
||||
} while (beforeIntervalLength + afterIntervalLength < millisecondsOverWhichToAverage && (beforeWind != null || afterWind != null));
|
||||
SpeedWithBearing avgWindSpeed = new KnotSpeedWithBearingImpl(knotSum / count, new DegreeBearingImpl(bearingDegSum/count));
|
||||
return new WindImpl(p, at, avgWindSpeed);
|
||||
if (count == 0) {
|
||||
return null;
|
||||
} else {
|
||||
SpeedWithBearing avgWindSpeed = new KnotSpeedWithBearingImpl(knotSum / count, new DegreeBearingImpl(bearingDegSum/count));
|
||||
return new WindImpl(p, at, avgWindSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user