Fixed access to average speed for supplied angle and windspeed

This commit is contained in:
Frederik Petersen committed 2015-05-28 14:59:47 +02:00
1 parent 4ce4641e3d
commit 97e7a9d183
3 files changed
+8 -5

No files matched your search

@@ -165,7 +165,7 @@ public class PolarDataServiceImpl implements PolarDataService {
@Override
public PolynomialFunction getSpeedRegressionFunction(BoatClass boatClass, double trueWindAngle)
throws NotEnoughDataHasBeenAddedException {
return polarDataMiner.getSpeedRegressionFunction(boatClass, trueWindAngle);
return polarDataMiner.getSpeedRegressionFunction(boatClass, Math.abs(trueWindAngle));
}
@Override
@@ -72,10 +72,13 @@ public class GPSFixMovingWithPolarContext implements MovingAveragePolarClusterKe
private BearingWithConfidence<Void> computeTrueWindAngleAbsolute() {
BearingWithConfidenceImpl<Void> result = null;
Bearing bearing;
Bearing bearing = null;
try {
Bearing realBearing = race.getCurrentLeg(competitor, fix.getTimePoint()).getBeatAngle(fix.getTimePoint());
bearing = new DegreeBearingImpl(Math.abs(realBearing.getDegrees()));
TrackedLegOfCompetitor currentLeg = race.getCurrentLeg(competitor, fix.getTimePoint());
if (currentLeg != null) {
Bearing realBearing = currentLeg.getBeatAngle(fix.getTimePoint());
bearing = new DegreeBearingImpl(Math.abs(realBearing.getDegrees()));
}
} catch (NoWindException e) {
bearing = null;
}
@@ -67,7 +67,7 @@ public class SpeedRegressionPerAngleClusterProcessor implements Processor<Groupe
double speedSum = 0;
double numberOfSpeeds = 0;
for (int i = -5; i <= 5; i++) {
GroupKey key = createGroupKey(boatClass, new DegreeBearingImpl(trueWindAngle.getDegrees() + i));
GroupKey key = createGroupKey(boatClass, new DegreeBearingImpl(Math.abs(trueWindAngle.getDegrees()) + i));
if (regressions.containsKey(key)) {
speedSum += regressions.get(key).getOrCreatePolynomialFunction().value(windSpeed.getKnots());
numberOfSpeeds++;