mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 03:13:49 +00:00
formatting, comments and minor refactoring in TrackedRaceImpl.getDistanceToStartLine, avoiding unnecessary call to getBearingGreatCircle for null positions
Change-Id: I069b999df47350077fe9e8e16217f36dd9a1e6df
This commit is contained in:
1 parent
01020a504b
commit
d785e662a0
2 files changed
+9
-7
No files matched your search
@@ -20,7 +20,10 @@ public interface Position extends Serializable {
|
||||
Distance getDistance(Position p);
|
||||
|
||||
/**
|
||||
* The bearing from this position towards <code>p</code> on a great circle
|
||||
* The bearing from this position towards <code>p</code> on a great circle.
|
||||
*
|
||||
* @return {@code null} if {@code p} is {@code null}, otherwise the bearing from {@code this} {@link Position} to
|
||||
* {@code p} along a great circle
|
||||
*/
|
||||
Bearing getBearingGreatCircle(Position p);
|
||||
|
||||
|
||||
+5
-6
@@ -3455,26 +3455,25 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl
|
||||
if (startWaypoint == null) {
|
||||
result = null;
|
||||
} else {
|
||||
Position competitorPosition = getTrack(competitor).getEstimatedPosition(timePoint, /* extrapolate */false);
|
||||
Position competitorPosition = getTrack(competitor).getEstimatedPosition(timePoint, /* extrapolate */ false);
|
||||
if (competitorPosition == null) {
|
||||
result = null;
|
||||
} else {
|
||||
Iterable<Mark> marks = startWaypoint.getControlPoint().getMarks();
|
||||
Iterator<Mark> marksIterator = marks.iterator();
|
||||
Mark first = marksIterator.next();
|
||||
Position firstPosition = getOrCreateTrack(first).getEstimatedPosition(timePoint, /* extrapolate */false);
|
||||
Position firstPosition = getOrCreateTrack(first).getEstimatedPosition(timePoint, /* extrapolate */ false);
|
||||
if (firstPosition == null) {
|
||||
result = null;
|
||||
} else {
|
||||
if (marksIterator.hasNext()) {
|
||||
// it's a line / gate
|
||||
Mark second = marksIterator.next();
|
||||
Position secondPosition = getOrCreateTrack(second).getEstimatedPosition(timePoint, /* extrapolate */
|
||||
false);
|
||||
final Bearing bearingGreatCircle = firstPosition.getBearingGreatCircle(secondPosition);
|
||||
if (bearingGreatCircle == null) {
|
||||
Position secondPosition = getOrCreateTrack(second).getEstimatedPosition(timePoint, /* extrapolate */ false);
|
||||
if (secondPosition == null) {
|
||||
result = null;
|
||||
} else {
|
||||
final Bearing bearingGreatCircle = firstPosition.getBearingGreatCircle(secondPosition);
|
||||
Position competitorProjectedOntoStartLine = competitorPosition.projectToLineThrough(
|
||||
firstPosition, bearingGreatCircle);
|
||||
result = competitorPosition.getDistance(competitorProjectedOntoStartLine);
|
||||
|
||||
Reference in new issue
Block a user