solved byg 385 by returning null from getWindOnLeg if mark positions are not known;

this will cause a NoWindException in getLegType which is already caught in the wind estimator
This commit is contained in:
Axel Uhl committed 2012-03-09 10:50:26 +01:00
1 parent 33f5a9927f
commit b883acce9e
1 file changed
+10 -8
@@ -161,20 +161,22 @@ public class TrackedLegImpl implements TrackedLeg, RaceChangeListener {
}
private Wind getWindOnLeg(TimePoint at) {
Wind wind;
Position approximateLegStartPosition = getTrackedRace().getOrCreateTrack(
getLeg().getFrom().getBuoys().iterator().next()).getEstimatedPosition(at, false);
Position approximateLegEndPosition = getTrackedRace().getOrCreateTrack(
getLeg().getTo().getBuoys().iterator().next()).getEstimatedPosition(at, false);
if (approximateLegStartPosition == null || approximateLegEndPosition == null) {
throw new RuntimeException("No mark positions received yet for leg "+getLeg()+
". Can't determine wind direction since position is not known.");
wind = null;
} else {
// exclude track-based estimation; it is itself based on the leg type which is based on the getWindOnLeg
// result which
// would therefore lead to an endless recursion without further tricks being applied
wind = getWind(approximateLegStartPosition.translateGreatCircle(
approximateLegStartPosition.getBearingGreatCircle(approximateLegEndPosition),
approximateLegStartPosition.getDistance(approximateLegEndPosition).scale(0.5)), at,
getTrackedRace().getWindSources(WindSourceType.TRACK_BASED_ESTIMATION));
}
// exclude track-based estimation; it is itself based on the leg type which is based on the getWindOnLeg result which
// would therefore lead to an endless recursion without further tricks being applied
Wind wind = getWind(
approximateLegStartPosition.translateGreatCircle(approximateLegStartPosition.getBearingGreatCircle(approximateLegEndPosition),
approximateLegStartPosition.getDistance(approximateLegEndPosition).scale(0.5)), at,
getTrackedRace().getWindSources(WindSourceType.TRACK_BASED_ESTIMATION));
return wind;
}