diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLegOfCompetitor.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLegOfCompetitor.java index 81a05134a42..ab392d08e85 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLegOfCompetitor.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLegOfCompetitor.java @@ -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 null 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); diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedLegOfCompetitorImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedLegOfCompetitorImpl.java index da51a322494..c8108107af8 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedLegOfCompetitorImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedLegOfCompetitorImpl.java @@ -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) {