mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 11:53:53 +00:00
refactored, in accordance with bug 277
This commit is contained in:
1 parent
acbd995176
commit
16da418410
3 files changed
+61
-157
No files matched your search
@@ -278,5 +278,7 @@ public interface TrackedRace {
|
||||
boolean raceIsKnownToStartUpwind();
|
||||
|
||||
void addListener(RaceChangeListener listener);
|
||||
|
||||
Distance getDistanceTraveled(Competitor competitor, TimePoint timePoint);
|
||||
|
||||
}
|
||||
+15
@@ -257,6 +257,21 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
return trackedLegs.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getDistanceTraveled(Competitor competitor, TimePoint timePoint) {
|
||||
NavigableSet<MarkPassing> markPassings = getMarkPassings(competitor);
|
||||
if (markPassings.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
TimePoint end = timePoint;
|
||||
if (markPassings.last().getWaypoint() == getRace().getCourse().getLastWaypoint()) {
|
||||
// competitor has finished race; use time point of crossing the finish line
|
||||
end = markPassings.last().getTimePoint();
|
||||
}
|
||||
return getTrack(competitor).getDistanceTraveled(markPassings.first().getTimePoint(), end);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GPSFixTrack<Competitor, GPSFixMoving> getTrack(Competitor competitor) {
|
||||
return tracks.get(competitor);
|
||||
|
||||
Reference in new issue
Block a user