use MarkPositionCacheAtTimePoint also for target time estimation

Change-Id: Ia496ea6eeac44cb8adde7de5d065a5b155c56c0f
This commit is contained in:
Axel Uhl committed 2016-09-29 16:55:49 +02:00
1 parent ceb4805693
commit db5f3201b9
3 files changed
+7 -3

No files matched your search

@@ -164,7 +164,8 @@ public interface TrackedLeg extends Serializable {
* is not available
* @throws NoWindException no wind available. unable to determine legtypes for given timepoint
*/
Duration getEstimatedTimeToComplete(PolarDataService polarDataService, TimePoint timepoint) throws NotEnoughDataHasBeenAddedException, NoWindException;
Duration getEstimatedTimeToComplete(PolarDataService polarDataService, TimePoint timepoint, MarkPositionAtTimePointCache markPositionCache)
throws NotEnoughDataHasBeenAddedException, NoWindException;
/**
* Computes the windward distance (for upwind/downwind legs) or the along-course distance (for reaching legs) at a reference time point
@@ -513,8 +513,10 @@ public class TrackedLegImpl implements TrackedLeg {
}
@Override
public Duration getEstimatedTimeToComplete(PolarDataService polarDataService, TimePoint timepoint)
public Duration getEstimatedTimeToComplete(PolarDataService polarDataService, TimePoint timepoint, MarkPositionAtTimePointCache markPositionCache)
throws NotEnoughDataHasBeenAddedException, NoWindException {
assert timepoint.equals(markPositionCache.getTimePoint());
assert getTrackedRace() == markPositionCache.getTrackedRace();
Position centralPosition = trackedRace.getCenterOfCourse(timepoint);
Wind wind = trackedRace.getWind(centralPosition, timepoint, getTrackedRace().getWindSources(WindSourceType.TRACK_BASED_ESTIMATION));
Position from = trackedRace.getApproximatePosition(leg.getFrom(), timepoint);
@@ -3896,8 +3896,9 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
throw new NotEnoughDataHasBeenAddedException("Target time estimation failed. No polar service available.");
}
Duration durationOfAllLegs = Duration.NULL;
final MarkPositionAtTimePointCache markPositionCache = new MarkPositionAtTimePointCacheImpl(this, timepoint);
for (TrackedLeg leg : trackedLegs.values()) {
Duration durationOfLeg = leg.getEstimatedTimeToComplete(polarDataService, timepoint);
Duration durationOfLeg = leg.getEstimatedTimeToComplete(polarDataService, timepoint, markPositionCache);
durationOfAllLegs = durationOfAllLegs.plus(durationOfLeg);
}
return durationOfAllLegs;