Merge remote-tracking branch 'origin/master' into design2015

This commit is contained in:
Steffen Schaefer committed 2015-07-08 16:05:34 +02:00
commit bf44dd0336
7 files changed
+38 -18

No files matched your search

@@ -145,14 +145,20 @@ public class AbstractPosition implements Position {
@Override
public Distance alongTrackDistance(Position from, Bearing bearing) {
double direction = Math.signum(Math.cos(from.getBearingGreatCircle(this).getRadians() - bearing.getRadians()));
// Test if denominator gets ridiculously small; if so, the cross-track error is about 90� central angle.
// This means that the cross-track error is maximized, and that there is no way to determine how far along
// the great circle described by pos2 and bearing we should travel. This is an exception which will
// surface as a division-by-zero exception or a NaN result
return new CentralAngleDistance(direction
* Math.acos(Math.cos(from.getCentralAngleRad(this))
/ Math.cos(crossTrackError(from, bearing).getCentralAngleRad())));
final Distance result;
if (from != null && bearing != null) {
double direction = Math.signum(Math.cos(from.getBearingGreatCircle(this).getRadians() - bearing.getRadians()));
// Test if denominator gets ridiculously small; if so, the cross-track error is about 90� central angle.
// This means that the cross-track error is maximized, and that there is no way to determine how far along
// the great circle described by pos2 and bearing we should travel. This is an exception which will
// surface as a division-by-zero exception or a NaN result
result = new CentralAngleDistance(direction
* Math.acos(Math.cos(from.getCentralAngleRad(this))
/ Math.cos(crossTrackError(from, bearing).getCentralAngleRad())));
} else {
result = null;
}
return result;
}
@Override
@@ -57,11 +57,13 @@ public interface Position extends Serializable {
Distance crossTrackError(Position p, Bearing bearing);
/**
* Computes how far along the great circle starting at <code>from</code> and pointing
* to <code>bearing</code> one has to travel to reach the projection of this position
* onto the great circle described by <code>from</code> and <code>bearing</code>. Note that
* if the angle between this position and the great circle is 90 degrees then there is
* no solution, and a <code>NaN</code> or exception will result.
* Computes how far along the great circle starting at <code>from</code> and pointing to <code>bearing</code> one
* has to travel to reach the projection of this position onto the great circle described by <code>from</code> and
* <code>bearing</code>. Note that if the angle between this position and the great circle is 90 degrees then there
* is no solution, and a <code>NaN</code> or exception will result.
* <p>
*
* If either <code>from</code> or <code>bearing</code> or both are <code>null</code>, <code>null</code> is returned.
*/
Distance alongTrackDistance(Position from, Bearing bearing);
@@ -6,6 +6,10 @@ import java.util.List;
import com.sap.sailing.domain.common.MaxPointsReason;
import com.sap.sse.common.Util;
/**
* A triple holding the competitor ID, the competitor name and the {@link MaxPointReason} documenting the score for the
* competitor
*/
public interface CompetitorResults extends List<Util.Triple<Serializable, String, MaxPointsReason>> {
}
@@ -158,6 +158,8 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
RaceLog raceLogAvailable = raceLogs.get(fleet);
if (raceLogAvailable == null) {
RaceColumnRaceLogReplicator listener = new RaceColumnRaceLogReplicator(this, identifier);
// FIXME Wouldn't this skip any listener notifications that a merge below would trigger if the race log already existed?
// FIXME For example, how about the race log-provided score corrections that need application to the leaderboard and replication?
newOrLoadedRaceLog.addListener(listener);
raceLogs.put(fleet, newOrLoadedRaceLog);
} else {
@@ -344,7 +344,7 @@ public class TrackedLegImpl implements TrackedLeg {
WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache) {
final Distance preResult = getWindwardDistance(pos1, pos2, at, windPositionMode, cache);
final Distance result;
if (preResult.getMeters() >= 0) {
if (preResult == null || preResult.getMeters() >= 0) {
result = preResult;
} else {
result = new MeterDistance(-preResult.getMeters());
@@ -228,9 +228,15 @@ public class TrackedLegOfCompetitorImpl implements TrackedLegOfCompetitor {
* bearing, and the distance from the projection to the <code>mark</code> is returned. Otherwise, it is assumed that
* the leg is neither an upwind nor a downwind leg, and hence the true distance to <code>mark</code> is returned. A
* cache for wind and leg type / bearing can be passed to avoid their redundant calculation during a single
* round-trip.<p>
* round-trip.
* <p>
*
* If no wind information is available, again the true geometrical distance to <code>mark</code> is returned.
* <p>
*
* If the competitor's position or the mark's position cannot be determined, <code>null</code> is returned.
* <code>null</code> is also returned if the leg's bearing cannot be determined because for at least one of its two
* waypoints no mark has a known position.
*/
private Distance getWindwardDistanceTo(Mark mark, TimePoint at, WindPositionMode windPositionMode, WindLegTypeAndLegBearingCache cache) {
Position estimatedPosition = getTrackedRace().getTrack(getCompetitor()).getEstimatedPosition(at, false);
@@ -197,9 +197,9 @@ public interface ReplicableWithObjectInputStream<S, O extends OperationWithResul
}
/**
* Checks whether this replicable is a replica. If yes, the operation is not executed locally but instead sent to
* the master server for execution. Otherwise, {@link #applyReplicated(OperationWithResult)} is invoked which executes
* and replicates the operation immediately.
* Checks whether this replicable is a replica. If yes, the operation is executed locally and sent to the master
* server for execution. Otherwise, {@link #applyReplicated(OperationWithResult)} is invoked which executes and
* replicates the operation immediately.
*/
default <T> T apply(OperationWithResult<S, T> operation) {
boolean needToRemoveThreadLocal = false;