mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 17:36:40 +00:00
cut short endless searched on estimated wind by reducing search space to tracked time frame
This commit is contained in:
1 parent
f8fe9675da
commit
800104865b
3 files changed
+41
-12
No files matched your search
+32
-8
@@ -59,23 +59,47 @@ public class EstimatedWindFixesAsNavigableSet extends AbstractUnmodifiableNaviga
|
||||
}
|
||||
|
||||
private TimePoint lowerToResolution(Wind w) {
|
||||
return new MillisecondsTimePoint((w.getTimePoint().asMillis() - 1) / RESOLUTION_IN_MILLISECONDS
|
||||
* RESOLUTION_IN_MILLISECONDS);
|
||||
TimePoint result;
|
||||
if (w.getTimePoint().compareTo(trackedRace.getTimePointOfLastEvent()) > 0) {
|
||||
result = lowerToResolution(new DummyWind(trackedRace.getTimePointOfLastEvent()));
|
||||
} else {
|
||||
result = new MillisecondsTimePoint((w.getTimePoint().asMillis() - 1) / RESOLUTION_IN_MILLISECONDS
|
||||
* RESOLUTION_IN_MILLISECONDS);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private TimePoint floorToResolution(Wind w) {
|
||||
return new MillisecondsTimePoint(w.getTimePoint().asMillis() / RESOLUTION_IN_MILLISECONDS
|
||||
* RESOLUTION_IN_MILLISECONDS);
|
||||
TimePoint result;
|
||||
if (w.getTimePoint().compareTo(trackedRace.getTimePointOfLastEvent()) > 0) {
|
||||
result = floorToResolution(new DummyWind(trackedRace.getTimePointOfLastEvent()));
|
||||
} else {
|
||||
result = new MillisecondsTimePoint(w.getTimePoint().asMillis() / RESOLUTION_IN_MILLISECONDS
|
||||
* RESOLUTION_IN_MILLISECONDS);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private TimePoint ceilingToResolution(Wind w) {
|
||||
return new MillisecondsTimePoint(((w.getTimePoint().asMillis() - 1) / RESOLUTION_IN_MILLISECONDS + 1)
|
||||
* RESOLUTION_IN_MILLISECONDS);
|
||||
TimePoint result;
|
||||
if (w.getTimePoint().compareTo(trackedRace.getStartOfTracking()) < 0) {
|
||||
result = ceilingToResolution(new DummyWind(trackedRace.getStartOfTracking()));
|
||||
} else {
|
||||
result = new MillisecondsTimePoint(((w.getTimePoint().asMillis() - 1) / RESOLUTION_IN_MILLISECONDS + 1)
|
||||
* RESOLUTION_IN_MILLISECONDS);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private TimePoint higherToResolution(Wind w) {
|
||||
return new MillisecondsTimePoint((w.getTimePoint().asMillis() / RESOLUTION_IN_MILLISECONDS + 1)
|
||||
* RESOLUTION_IN_MILLISECONDS);
|
||||
TimePoint result;
|
||||
if (w.getTimePoint().compareTo(trackedRace.getStartOfTracking()) < 0) {
|
||||
result = higherToResolution(new DummyWind(trackedRace.getStartOfTracking()));
|
||||
} else {
|
||||
result = new MillisecondsTimePoint((w.getTimePoint().asMillis() / RESOLUTION_IN_MILLISECONDS + 1)
|
||||
* RESOLUTION_IN_MILLISECONDS);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-3
@@ -523,7 +523,8 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
|
||||
@Override
|
||||
public Wind getWind(Position p, TimePoint at, Iterable<WindSource> windSourcesToExclude) {
|
||||
return getWindWithConfidence(p, at, windSourcesToExclude).getObject();
|
||||
final WindWithConfidence<Pair<Position, TimePoint>> windWithConfidence = getWindWithConfidence(p, at, windSourcesToExclude);
|
||||
return windWithConfidence == null ? null : windWithConfidence.getObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -542,10 +543,13 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
if (!Util.contains(windSourcesToExclude, windSource)) {
|
||||
WindTrack track = getWindTrack(windSource);
|
||||
WindWithConfidence<Pair<Position, TimePoint>> windWithConfidence = track.getEstimatedWindWithConfidence(p, at);
|
||||
windFixesWithConfidences.add(windWithConfidence);
|
||||
if (windWithConfidence != null) {
|
||||
windFixesWithConfidences.add(windWithConfidence);
|
||||
}
|
||||
}
|
||||
}
|
||||
HasConfidence<ScalableWind, Wind, Pair<Position, TimePoint>> average = averager.getAverage(windFixesWithConfidences, new Pair<Position, TimePoint>(p, at));
|
||||
HasConfidence<ScalableWind, Wind, Pair<Position, TimePoint>> average = averager.getAverage(
|
||||
windFixesWithConfidences, new Pair<Position, TimePoint>(p, at));
|
||||
WindWithConfidence<Pair<Position, TimePoint>> result = new WindWithConfidenceImpl<Pair<Position,TimePoint>>(
|
||||
average.getObject(), average.getConfidence(), new Pair<Position, TimePoint>(p, at));
|
||||
return result;
|
||||
|
||||
+2
-1
@@ -121,7 +121,8 @@ public class WindTrackImpl extends TrackImpl<Wind> implements WindTrack {
|
||||
*/
|
||||
@Override
|
||||
public synchronized Wind getEstimatedWind(Position p, TimePoint at) {
|
||||
return getEstimatedWindUnsynchronized(p, at).getObject();
|
||||
final WindWithConfidence<Pair<Position, TimePoint>> estimatedWindUnsynchronized = getEstimatedWindUnsynchronized(p, at);
|
||||
return estimatedWindUnsynchronized == null ? null : estimatedWindUnsynchronized.getObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user