mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 17:36:40 +00:00
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:
1 parent
33f5a9927f
commit
b883acce9e
1 file changed
+10
-8
+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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user