bug5918: including cache

This commit is contained in:
Lisa
2023-11-29 14:11:18 +01:00
parent 19cde5e58a
commit 3ddbca91c7
2 changed files with 13 additions and 4 deletions
@@ -343,10 +343,15 @@ public interface TrackedLegOfCompetitor extends Serializable {
TimePoint getTimePointNotAfterFinishingOfLeg(TimePoint timePoint);
/**
* If the bearing between the cog and the next waypoint is smaller then the one between cog and wind direction
* If the bearing between cog and the next waypoint is smaller then the one between cog and wind direction
* {@link TackType#LONGTACK longtack} is returned, if it is bigger {@link TackType#SHORTTACK shorttack}. For other cases <code>null</code> is returned.
*/
TackType getTackType(TimePoint timePoint) throws NoWindException;
/**
* Same as {@link #getTackType(TimePoint timePoint)}, only that a cache for leg type calculation is passed.
*/
TackType getTackType(TimePoint timePoint, WindLegTypeAndLegBearingAndORCPerformanceCurveCache cache) throws NoWindException;
Double getExpeditionAWA(TimePoint at);
Double getExpeditionAWS(TimePoint at);
@@ -1246,6 +1246,11 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
@Override
public TackType getTackType(TimePoint timePoint) throws NoWindException {
return getTackType(timePoint, new LeaderboardDTOCalculationReuseCache(timePoint));
}
@Override
public TackType getTackType(TimePoint timePoint, WindLegTypeAndLegBearingAndORCPerformanceCurveCache cache) throws NoWindException {
final TackType result;
final Position competitorPosition = getTrackedRace().getTrack(competitor).getEstimatedPosition(timePoint,
/* extrapolate */ true);
@@ -1254,11 +1259,10 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
if (start != null && timePoint.after(start.getTimePoint())) {
final MarkPassing end = getMarkPassingForLegEnd();
if (end != null && timePoint.before(end.getTimePoint())) {
final Position waypointPosition = getTrackedRace().getApproximatePosition(getLeg().getTo(),
timePoint);
final Position waypointPosition = cache.getApproximatePosition(getTrackedRace(), getLeg().getTo(), timePoint);
final Bearing cog = getSpeedOverGround(timePoint).getBearing();
final Bearing bearingToWaypoint = competitorPosition.getBearingGreatCircle(waypointPosition);
final Bearing bearingWind = getTrackedRace().getWind(competitorPosition, timePoint).getFrom();
final Bearing bearingWind = cache.getWind(getTrackedRace(), competitor, timePoint).getFrom();
final Bearing diffWindToBoat = bearingWind.getDifferenceTo(cog).abs();
final Bearing diffMarkToBoat = bearingToWaypoint.getDifferenceTo(cog).abs();
if (diffMarkToBoat.compareTo(diffWindToBoat) < 0) {