fixed calculation bug in TimeOnTimeAndDistanceRankingMetric

This commit is contained in:
Axel Uhl committed 2015-05-20 17:50:17 +02:00
1 parent cf09647e00
commit 2d11ab9a31
3 files changed
+6 -8

No files matched your search

@@ -1662,9 +1662,6 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
getLegGapToLegLeaderInOwnTime(trackedLeg, timePoint, cache);
result.gapToLeaderInSeconds = gapToLeaderInOwnTime == null ? null : gapToLeaderInOwnTime.asSeconds();
if (result.gapToLeaderInSeconds != null) {
// FIXME problem: asking just after the beginning of the leg yields very different values from asking for the end of the previous leg.
// This is because for the previous leg it's decided based on the mark passings; for the next (current) leg it's decided based on
// windward distance and VMG
Duration gapAtEndOfPreviousLeg = getGapAtEndOfPreviousLeg(trackedLeg, cache);
if (gapAtEndOfPreviousLeg != null) {
result.gapChangeSinceLegStartInSeconds = result.gapToLeaderInSeconds - gapAtEndOfPreviousLeg.asSeconds();
@@ -355,17 +355,18 @@ public abstract class AbstractRankingMetric implements RankingMetric {
final Competitor who = legWho.getCompetitor();
final Competitor to = legTo.getCompetitor();
if (who == to) {
// the same competitor requires no time to reach its own position; it's already there...
// if legWho hasFinished at timePoint already, the duration will have to be negative, even if who==to
// the same competitor requires no time to reach its own position; it's already there;
// however, if the competitor has already finished the leg at or before timePoint, the duration will
// have to be negative, even if who==to
if (legWho.hasFinishedLeg(timePoint)) {
result = legWho.getFinishTime().until(timePoint);
result = timePoint.until(legWho.getFinishTime());
} else {
result = Duration.NULL;
}
} else {
assert getTrackedRace().getRace().getCourse().getIndexOfWaypoint(legWho.getLeg().getFrom()) <= getTrackedRace()
.getRace().getCourse().getIndexOfWaypoint(legTo.getLeg().getFrom());
final Duration toEndOfLegOrTo = getPredictedDurationToEndOfLegOrTo(timePoint, legWho, legTo, cache);
final Duration toEndOfLegOrTo = getPredictedDurationToEndOfLegOrTo(timePoint, legWho, legWho.getTrackedLeg().getTrackedLeg(to), cache);
final Duration durationForSubsequentLegsToReachAtEqualPerformance;
if (legWho.getLeg() == legTo.getLeg()) {
durationForSubsequentLegsToReachAtEqualPerformance = Duration.NULL;
@@ -267,7 +267,7 @@ public class TimeOnTimeAndDistanceRankingMetric extends AbstractRankingMetric {
final double g_who = timeOnDistanceFactorInSecondsPerNauticalMileWho==null?0:timeOnDistanceFactorInSecondsPerNauticalMileWho.asSeconds();
final Duration t_who = new MillisecondsDurationImpl(Double.valueOf(
(1./d_to.inTime(t_to.times(f_to)).getMetersPerSecond() / Mile.METERS_PER_NAUTICAL_MILE - g_to + g_who)
(1./(d_to.inTime(t_to.times(f_to)).getMetersPerSecond() / Mile.METERS_PER_NAUTICAL_MILE) - g_to + g_who)
* d_who.getNauticalMiles() / f_who * 1000.).longValue());
return t_who;
}