mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-01 08:40:52 +00:00
Implemented methods to get the distance from the start line and the speed
of a competitor x seconds before the start of race from a TrackedRace.
This commit is contained in:
1 parent
71207dd6a0
commit
78e78f98a6
2 files changed
+48
-6
No files matched your search
@@ -18,6 +18,7 @@ import com.sap.sailing.domain.common.LegType;
|
||||
import com.sap.sailing.domain.common.NoWindException;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.Tack;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.TimingConstants;
|
||||
@@ -550,6 +551,21 @@ public interface TrackedRace extends Serializable {
|
||||
*/
|
||||
Distance getStartAdvantage(Competitor competitor, double secondsIntoTheRace);
|
||||
|
||||
/**
|
||||
* Tells how far the given <code>competitor</code> was from the start line at the time point of the given seconds before the start.
|
||||
* <p>
|
||||
*
|
||||
* The distance to the line is calculated by projecting the competitor's position onto the line orthogonally and
|
||||
* computing the distance of the projected position and the competitor's position.
|
||||
* <p
|
||||
* .
|
||||
*
|
||||
* Should the course be empty, <code>null</code> is returned. If the course's first waypoint is not a line or gate,
|
||||
* the geometric distance between the first waypoint and the competitor's position at <code>timePoint</code> is
|
||||
* returned. If the competitor's position cannot be determined, <code>null</code> is returned.
|
||||
*/
|
||||
Distance getDistanceToStartLine(Competitor competitor, double secondsBeforeRaceStart);
|
||||
|
||||
/**
|
||||
* Tells how far the given <code>competitor</code> was from the start line at the given <code>timePoint</code>.
|
||||
* Using the {@link #getStartOfRace() race start time} for <code>timePoint</code>, this tells the competitor's
|
||||
@@ -573,4 +589,9 @@ public interface TrackedRace extends Serializable {
|
||||
* If the competitor hasn't started yet, <code>null</code> is returned.
|
||||
*/
|
||||
Distance getDistanceFromStarboardSideOfStartLineWhenPassingStart(Competitor competitor);
|
||||
|
||||
/**
|
||||
* The estimated speed of the competitor at the time point of the given seconds before the start of race.
|
||||
*/
|
||||
Speed getSpeed(Competitor competitor, double secondsBeforeRaceStart);
|
||||
}
|
||||
+27
-6
@@ -57,6 +57,7 @@ import com.sap.sailing.domain.common.NoWindException;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.domain.common.RegattaNameAndRaceName;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.Tack;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.TimingConstants;
|
||||
@@ -1038,12 +1039,6 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getStartAdvantage(Competitor competitor, double secondsIntoTheRace) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarkPassing getMarkPassing(Competitor competitor, Waypoint waypoint) {
|
||||
final NavigableSet<MarkPassing> markPassings = getMarkPassings(competitor);
|
||||
@@ -2411,6 +2406,22 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
public RaceLog getRaceLog(Serializable identifier) {
|
||||
return attachedRaceLogs.get(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getStartAdvantage(Competitor competitor, double secondsIntoTheRace) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getDistanceToStartLine(Competitor competitor, double secondsBeforeRaceStart) {
|
||||
if (getStartOfRace() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TimePoint beforeStart = new MillisecondsTimePoint(getStartOfRace().asMillis() - (long) (secondsBeforeRaceStart * 1000));
|
||||
return getDistanceToStartLine(competitor, beforeStart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getDistanceToStartLine(Competitor competitor, TimePoint timePoint) {
|
||||
@@ -2451,6 +2462,16 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Speed getSpeed(Competitor competitor, double secondsBeforeRaceStart) {
|
||||
if (getStartOfRace() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TimePoint beforeStart = new MillisecondsTimePoint(getStartOfRace().asMillis() - (long) (secondsBeforeRaceStart * 1000));
|
||||
return getTrack(competitor).getEstimatedSpeed(beforeStart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Distance getDistanceFromStarboardSideOfStartLineWhenPassingStart(Competitor competitor) {
|
||||
|
||||
Reference in new issue
Block a user