mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 05:11:04 +00:00
fixes Bug 99 by slightly modifying the specification of TrackedLegOfCompetitor.getTimeInMilliseconds
This commit is contained in:
1 parent
32cc72e7dd
commit
4d518e7bc0
2 files changed
+12
-9
No files matched your search
+4
-2
@@ -15,8 +15,10 @@ public interface TrackedLegOfCompetitor {
|
||||
Competitor getCompetitor();
|
||||
|
||||
/**
|
||||
* How long did it take the competitor to complete this {@link #getLeg() leg}? If the competitor hasn't finished the
|
||||
* leg yet, -1 is returned.
|
||||
* How much time did the {@link #getCompetitor competitor} spend in this {@link #getLeg() leg} at
|
||||
* <code>timePoint</code>? If the competitor hasn't started the leg yet at <code>timePoint</code>, 0 is returned. If the
|
||||
* competitor has finished the leg already at <code>timePoint</code>, the time it took the competitor to
|
||||
* complete the leg is returned.
|
||||
*/
|
||||
long getTimeInMilliSeconds(TimePoint timePoint);
|
||||
|
||||
|
||||
+8
-7
@@ -59,15 +59,16 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
|
||||
|
||||
@Override
|
||||
public long getTimeInMilliSeconds(TimePoint timePoint) {
|
||||
long result = -1;
|
||||
MarkPassing passedEndWaypoint = getTrackedRace().getMarkPassing(getCompetitor(), getTrackedLeg().getLeg().getTo());
|
||||
if (passedEndWaypoint != null) {
|
||||
MarkPassing passedStartWaypoint = getTrackedRace().getMarkPassing(getCompetitor(), getTrackedLeg().getLeg().getFrom());
|
||||
if (passedStartWaypoint != null) {
|
||||
long result = 0;
|
||||
MarkPassing passedStartWaypoint = getTrackedRace().getMarkPassing(getCompetitor(),
|
||||
getTrackedLeg().getLeg().getFrom());
|
||||
if (passedStartWaypoint != null) {
|
||||
MarkPassing passedEndWaypoint = getTrackedRace().getMarkPassing(getCompetitor(),
|
||||
getTrackedLeg().getLeg().getTo());
|
||||
if (passedEndWaypoint != null) {
|
||||
result = passedEndWaypoint.getTimePoint().asMillis() - passedStartWaypoint.getTimePoint().asMillis();
|
||||
} else {
|
||||
throw new RuntimeException(""+getCompetitor()+" passed waypoint at end of leg "+
|
||||
getLeg()+" without having passed waypoint at beginning of leg");
|
||||
result = timePoint.asMillis() - passedStartWaypoint.getTimePoint().asMillis();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user