compute current VMG only if average VMG is not available

This commit is contained in:
Axel Uhl committed 2015-05-28 14:33:09 +02:00
1 parent e4e00fa228
commit f11c534892
1 file changed
+1 -2
@@ -454,9 +454,8 @@ public abstract class AbstractRankingMetric implements RankingMetric {
private Duration getDurationToReach(final Position windwardPositionToReachInWhosCurrentLeg, TimePoint timePoint,
final TrackedLegOfCompetitor whosLeg, WindLegTypeAndLegBearingCache cache) {
final Duration toEndOfLegOrTo;
final Speed currentVMG = whosLeg.getVelocityMadeGood(timePoint, WindPositionMode.EXACT, cache);
final Speed averageVMG = whosLeg.getAverageVelocityMadeGood(timePoint, cache);
final Speed vmg = Double.isNaN(averageVMG.getKnots()) ? currentVMG : averageVMG;
final Speed vmg = Double.isNaN(averageVMG.getKnots()) ? /* default to current VMG */ whosLeg.getVelocityMadeGood(timePoint, WindPositionMode.EXACT, cache) : averageVMG;
toEndOfLegOrTo = vmg.getDuration(
whosLeg.getTrackedLeg().getWindwardDistance(
getTrackedRace().getTrack(whosLeg.getCompetitor()).getEstimatedPosition(timePoint, /* extrapolate */true),