Merge branch 'master' into tracapi

This commit is contained in:
Axel Uhl committed 2014-04-24 12:34:20 +02:00
commit d7e22da5f4
4 files changed
+37 -10

No files matched your search

@@ -1,13 +1,22 @@
package com.sap.sailing.domain.tracking.impl;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.WindSourceType;
import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sailing.domain.tracking.Wind;
import com.sap.sailing.domain.tracking.WindWithConfidence;
import com.sap.sailing.domain.tracking.impl.TrackBasedEstimationWindTrackImpl.EstimatedWindFixesAsNavigableSet;
/**
* A wind track that delivers the result of
* {@link TrackedRace#getWind(com.sap.sailing.domain.common.Position, com.sap.sailing.domain.common.TimePoint)},
* using a {@link CombinedWindAsNavigableSet} as its internal raw fixes collection. Resolution of raw fixes is set to 10s.
* As the result of {@link TrackedRace#getWind(com.sap.sailing.domain.common.Position, com.sap.sailing.domain.common.TimePoint)}
* is already a smoothened, outlier-removed and averaged value, the averaging methods {@link #getAveragedWind(Position, TimePoint)}
* and {@link #getAveragedWindWithConfidence(Position, TimePoint)} are redefined such that they immediately delegate
* to {@link TrackedRace#getWindWithConfidence(Position, TimePoint)}.
*
* @author Axel Uhl (d043530)
*
@@ -37,5 +46,14 @@ public class CombinedWindTrackImpl extends VirtualWindTrackImpl {
public long getMillisecondsOverWhichToAverageWind() {
return 2*getInternalRawFixes().getResolutionInMilliseconds()+2;
}
@Override
public Wind getAveragedWind(Position p, TimePoint at) {
return getTrackedRace().getWind(p, at);
}
@Override
public WindWithConfidence<Pair<Position, TimePoint>> getAveragedWindWithConfidence(Position p, TimePoint at) {
return getTrackedRace().getWindWithConfidence(p, at);
}
}
@@ -47,6 +47,11 @@ public abstract class VirtualWindFixesAsNavigableSet extends AbstractUnmodifiabl
this(track, trackedRace, null, null, resolutionInMilliseconds);
}
/**
* Compute the {@link Wind} fix for the specified position and time point to deliver in this virtual track.
*/
abstract protected Wind getWind(Position p, TimePoint timePoint);
public long getResolutionInMilliseconds() {
return resolutionInMilliseconds;
}
@@ -153,11 +158,6 @@ public abstract class VirtualWindFixesAsNavigableSet extends AbstractUnmodifiabl
return timePoint.compareTo(getFrom()) < 0 ? null : getWind(w.getPosition(), timePoint);
}
/**
* Compute the {@link Wind} fix for the specified position and time point to deliver in this virtual track.
*/
abstract protected Wind getWind(Position p, TimePoint timePoint);
@Override
public Wind floor(Wind w) {
TimePoint timePoint = floorToResolution(w.getTimePoint());
@@ -42,10 +42,7 @@ public abstract class VirtualWindTrackImpl extends WindTrackImpl {
}
/**
* This redefinition avoids very long searches in case <code>at</code> is before the race start or after the race's
* newest event. Should <code>at</code> be out of this range, it is set to the closest border of this range before
* calling the base class's implementation. If either race start or time of newest event are not known, the known
* time point is used instead. If both time points are not known, <code>null</code> is returned immediately.
* Delegates to {@link #getAveragedWindUnsynchronized(Position, TimePoint)}
*/
@Override
public Wind getAveragedWind(Position p, TimePoint at) {
@@ -53,6 +50,12 @@ public abstract class VirtualWindTrackImpl extends WindTrackImpl {
return windWithConfidence == null ? null : windWithConfidence.getObject();
}
/**
* This redefinition avoids very long searches in case <code>at</code> is before the race start or after the race's
* newest event. Should <code>at</code> be out of this range, it is set to the closest border of this range before
* calling the base class's implementation. If either race start or time of newest event are not known, the known
* time point is used instead. If both time points are not known, <code>null</code> is returned immediately.
*/
@Override
public WindWithConfidence<Pair<Position, TimePoint>> getAveragedWindWithConfidence(Position p, TimePoint at) {
WindWithConfidence<Pair<Position, TimePoint>> result = null;
@@ -165,6 +165,12 @@ public class WindTrackImpl extends TrackImpl<Wind> implements WindTrack {
/**
* This method implements the functionality of the {@link #getAveragedWind(Position, TimePoint)} interface method.
* It does so by collecting (smoothened, outliers removed)) wind fixes around the <code>at</code> time point up to
* an interval length as specified by {@link #getMillisecondsOverWhichToAverageWind()}. At least one fix that is
* closest to <code>at</code> will be picked up. If the track is empty, <code>null</code> is returned. Otherwise,
* the wind fixes in the interval constructed are averaged using a {@link ConfidenceBasedWindAverager}.
*
* <p>
* However, not being <code>synchronized</code>, it does not obtain this object's monitor. Subclasses may use this
* carefully if they can guarantee there are no concurrency issues with the internal fixes while iterating over the
* result of {@link #getInternalFixes()}.