mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 14:57:12 +00:00
bug 3162: fixing how the gap is calculated for one-design ranking when the leader has already finished the race
This commit is contained in:
1 parent
883ef38d90
commit
f037e457fd
2 files changed
+27
-2
No files matched your search
+1
-1
@@ -471,7 +471,7 @@ public abstract class AbstractRankingMetric implements RankingMetric {
|
||||
* started at <code>timePoint</code> yet, or <code>who</code>'s tracked leg for the last leg if <code>who</code> has
|
||||
* already finished the race at <code>timePoint</code>.
|
||||
*/
|
||||
private TrackedLegOfCompetitor getCurrentLegOrLastLegIfAlreadyFinished(Competitor who, TimePoint timePoint) {
|
||||
protected TrackedLegOfCompetitor getCurrentLegOrLastLegIfAlreadyFinished(Competitor who, TimePoint timePoint) {
|
||||
TrackedLegOfCompetitor currentLegWho = getTrackedRace().getCurrentLeg(who, timePoint);
|
||||
if (currentLegWho == null) { // already finished or not yet started; if already finished, use last leg
|
||||
final Waypoint lastWaypoint = getTrackedRace().getRace().getCourse().getLastWaypoint();
|
||||
|
||||
+26
-1
@@ -42,7 +42,32 @@ public class OneDesignRankingMetric extends AbstractRankingMetric {
|
||||
|
||||
@Override
|
||||
public Duration getGapToLeaderInOwnTime(RankingMetric.RankingInfo rankingInfo, Competitor competitor, WindLegTypeAndLegBearingCache cache) {
|
||||
return rankingInfo.getCompetitorRankingInfo().apply(competitor).getEstimatedActualDurationFromTimePointToCompetitorFarthestAhead();
|
||||
// When the competitor is in the same leg as the leader (which in this ranking metric is always the boat
|
||||
// farthest ahead) then the competitor's duration to reach the current leader's position is estimated based on the
|
||||
// competitor's average VMG on the current leg.
|
||||
// If the leader has already finished the competitor's current leg, the time when the competitor will probably
|
||||
// finish the leg is compared to the time when the leader finished the leg.
|
||||
// When the competitor has already finished the current leg this can only mean the competitor finished the race
|
||||
// because otherwise the competitor would not be considered in this leg anymore. In this case, the mark passing
|
||||
// times for finishing the leg are compared between competitor and leader.
|
||||
final Duration result;
|
||||
final TrackedLegOfCompetitor currentLegWho = getCurrentLegOrLastLegIfAlreadyFinished(competitor,
|
||||
rankingInfo.getTimePoint());
|
||||
final TrackedLegOfCompetitor currentLegTo = getCurrentLegOrLastLegIfAlreadyFinished(
|
||||
rankingInfo.getCompetitorFarthestAhead(), rankingInfo.getTimePoint());
|
||||
final TimePoint tosLegFinishingTime = currentLegTo.getFinishTime();
|
||||
if (tosLegFinishingTime != null && !tosLegFinishingTime.after(rankingInfo.getTimePoint())) {
|
||||
final TimePoint whosLegFinishingTime = currentLegWho.getFinishTime();
|
||||
if (whosLegFinishingTime != null && !whosLegFinishingTime.after(rankingInfo.getTimePoint())) {
|
||||
// both have finished the leg; this, by the way, means both have finished the race
|
||||
result = tosLegFinishingTime.until(whosLegFinishingTime);
|
||||
} else {
|
||||
result = currentLegWho.getEstimatedTimeToNextMark(rankingInfo.getTimePoint(), WindPositionMode.EXACT);
|
||||
}
|
||||
} else {
|
||||
result = rankingInfo.getCompetitorRankingInfo().apply(competitor).getEstimatedActualDurationFromTimePointToCompetitorFarthestAhead();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user