mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-10 21:02:40 +00:00
Merge remote-tracking branch 'origin/maneuver_refactoring'
This commit is contained in:
commit
8fd27a2e5c
4 files changed
+92
-28
No files matched your search
+22
-10
@@ -17,37 +17,49 @@ public interface ManeuverCurveWithUnstableCourseAndSpeedWithEstimationData
|
||||
/**
|
||||
* Gets the average speed and course measured from the end of the previous maneuver until the start of this
|
||||
* maneuver. The mentioned maneuver start and end refer to
|
||||
* {@link Maneuver#getManeuverCurveWithStableSpeedAndCourseBoundaries(). If there are no previous maneuvers, or the
|
||||
* previous maneuver end is not before the start of this maneuver with a distance of at least one second, the result
|
||||
* will be {@null}.
|
||||
* {@link Maneuver#getManeuverCurveWithStableSpeedAndCourseBoundaries(). If there are no previous maneuvers, the
|
||||
* result will be {@null}.
|
||||
*/
|
||||
SpeedWithBearing getAverageSpeedWithBearingBefore();
|
||||
|
||||
/**
|
||||
* Gets the duration from the end of the previous maneuver until the start of this maneuver. The mentioned maneuver
|
||||
* start and end refer to {@link Maneuver#getManeuverCurveWithStableSpeedAndCourseBoundaries(). If there are no
|
||||
* previous maneuvers, or the previous maneuver end is not before the start of this maneuver with a distance of at
|
||||
* least one second, the result will be {@null}.
|
||||
* previous maneuvers, the result will be {@null}.
|
||||
*/
|
||||
Duration getDurationFromPreviousManeuverEndToManeuverStart();
|
||||
|
||||
/**
|
||||
* Gets the number of GPS-fixes recorded from the end of the previous maneuver until the start of this maneuver. The
|
||||
* mentioned maneuver start and end refer to {@link Maneuver#getManeuverCurveWithStableSpeedAndCourseBoundaries().
|
||||
* If there are no previous maneuvers, or the previous maneuver end is not before the start of this maneuver with a
|
||||
* distance of at least one second, the result will be zero.
|
||||
*/
|
||||
int getGpsFixesCountFromPreviousManeuverEndToManeuverStart();
|
||||
|
||||
/**
|
||||
* Gets the average speed and course measured from the end of this maneuver until the start of the next maneuver.
|
||||
* Both mentioned maneuver start and end refer to
|
||||
* {@link Maneuver#getManeuverCurveWithStableSpeedAndCourseBoundaries(). If there are no following maneuvers, or the
|
||||
* the maneuver end of this maneuver is not before the start of the next maneuver with a distance of at least one
|
||||
* second, the result will be {@null}.
|
||||
* {@link Maneuver#getManeuverCurveWithStableSpeedAndCourseBoundaries(). If there are no following maneuvers, the
|
||||
* result will be {@null}.
|
||||
*/
|
||||
SpeedWithBearing getAverageSpeedWithBearingAfter();
|
||||
|
||||
/**
|
||||
* Gets the duration from the end of this maneuver until the start of the next maneuver. Both mentioned maneuver
|
||||
* start and end refer to {@link Maneuver#getManeuverCurveWithStableSpeedAndCourseBoundaries(). If there are no
|
||||
* following maneuvers, or the the maneuver end of this maneuver is not before the start of the next maneuver with a
|
||||
* distance of at least one second, the result will be {@null}.
|
||||
* following maneuvers, the result will be {@null}.
|
||||
*/
|
||||
Duration getDurationFromManeuverEndToNextManeuverStart();
|
||||
|
||||
/**
|
||||
* Gets the number of GPS-fixes recorded from the end of this maneuver until the start of the next maneuver. Both
|
||||
* mentioned maneuver start and end refer to {@link Maneuver#getManeuverCurveWithStableSpeedAndCourseBoundaries().
|
||||
* If there are no following maneuvers, or the the maneuver end of this maneuver is not before the start of the next
|
||||
* maneuver with a distance of at least one second, the result will be zero.
|
||||
*/
|
||||
int getGpsFixesCountFromManeuverEndToNextManeuverStart();
|
||||
|
||||
/**
|
||||
* Gets the number of GPS-fixes contained within the maneuver curve.
|
||||
*/
|
||||
|
||||
+21
-6
@@ -20,21 +20,26 @@ public class ManeuverCurveWithUnstableCourseAndSpeedWithEstimationDataImpl exten
|
||||
private final Distance distanceSailedIfNotManeuvering;
|
||||
private final Distance distanceSailedTowardMiddleAngleProjectionIfNotManeuvering;
|
||||
private final int gpsFixesCount;
|
||||
private final int gpsFixesCountFromPreviousManeuverEndToManeuverStart;
|
||||
private final int gpsFixesCountFromManeuverEndToNextManeuverStart;
|
||||
|
||||
public ManeuverCurveWithUnstableCourseAndSpeedWithEstimationDataImpl(TimePoint timePointBefore,
|
||||
TimePoint timePointAfter, SpeedWithBearing speedWithBearingBefore, SpeedWithBearing speedWithBearingAfter,
|
||||
double directionChangeInDegrees, Speed lowestSpeed,
|
||||
SpeedWithBearing averageSpeedWithBearingBefore, Duration durationFromPreviousManeuverEndToManeuverStart,
|
||||
SpeedWithBearing averageSpeedWithBearingAfter, Duration durationFromManeuverEndToNextManeuverStart,
|
||||
double directionChangeInDegrees, Speed lowestSpeed, SpeedWithBearing averageSpeedWithBearingBefore,
|
||||
Duration durationFromPreviousManeuverEndToManeuverStart,
|
||||
int gpsFixesCountFromPreviousManeuverEndToManeuverStart, SpeedWithBearing averageSpeedWithBearingAfter,
|
||||
Duration durationFromManeuverEndToNextManeuverStart, int gpsFixesCountFromManeuverEndToNextManeuverStart,
|
||||
Distance distanceSailedWithinManeuver, Distance distanceSailedWithinManeuverTowardMiddleAngleProjection,
|
||||
Distance distanceSailedIfNotManeuvering,
|
||||
Distance distanceSailedTowardMiddleAngleProjectionIfNotManeuvering, int gpsFixesCount) {
|
||||
Distance distanceSailedIfNotManeuvering, Distance distanceSailedTowardMiddleAngleProjectionIfNotManeuvering,
|
||||
int gpsFixesCount) {
|
||||
super(timePointBefore, timePointAfter, speedWithBearingBefore, speedWithBearingAfter, directionChangeInDegrees,
|
||||
lowestSpeed);
|
||||
this.averageSpeedWithBearingBefore = averageSpeedWithBearingBefore;
|
||||
this.durationFromPreviousManeuverEndToManeuverStart = durationFromPreviousManeuverEndToManeuverStart;
|
||||
this.gpsFixesCountFromPreviousManeuverEndToManeuverStart = gpsFixesCountFromPreviousManeuverEndToManeuverStart;
|
||||
this.averageSpeedWithBearingAfter = averageSpeedWithBearingAfter;
|
||||
this.durationFromManeuverEndToNextManeuverStart = durationFromManeuverEndToNextManeuverStart;
|
||||
this.gpsFixesCountFromManeuverEndToNextManeuverStart = gpsFixesCountFromManeuverEndToNextManeuverStart;
|
||||
this.distanceSailedWithinManeuver = distanceSailedWithinManeuver;
|
||||
this.distanceSailedWithinManeuverTowardMiddleAngleProjection = distanceSailedWithinManeuverTowardMiddleAngleProjection;
|
||||
this.distanceSailedIfNotManeuvering = distanceSailedIfNotManeuvering;
|
||||
@@ -81,10 +86,20 @@ public class ManeuverCurveWithUnstableCourseAndSpeedWithEstimationDataImpl exten
|
||||
public Distance getDistanceSailedTowardMiddleAngleProjectionIfNotManeuvering() {
|
||||
return distanceSailedTowardMiddleAngleProjectionIfNotManeuvering;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getGpsFixesCount() {
|
||||
return gpsFixesCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGpsFixesCountFromPreviousManeuverEndToManeuverStart() {
|
||||
return gpsFixesCountFromPreviousManeuverEndToManeuverStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGpsFixesCountFromManeuverEndToNextManeuverStart() {
|
||||
return gpsFixesCountFromManeuverEndToNextManeuverStart;
|
||||
}
|
||||
|
||||
}
|
||||
+43
-12
@@ -277,16 +277,42 @@ public class ManeuverDetectorImpl implements ManeuverDetector {
|
||||
}
|
||||
int gpsFixCountWithinMainCurve = 0;
|
||||
int gpsFixCountWithinWholeCurve = 0;
|
||||
int gpsFixesCountFromPreviousManeuver = 0;
|
||||
int gpsFixesCountToNextManeuver = 0;
|
||||
try {
|
||||
track.lockForRead();
|
||||
for (GPSFixMoving fix : track.getFixes(
|
||||
maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries().getTimePointBefore(), true,
|
||||
maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries().getTimePointAfter(), true)) {
|
||||
if (!fix.getTimePoint().before(maneuverCurve.getMainCurveBoundaries().getTimePointBefore())
|
||||
&& !fix.getTimePoint().after(maneuverCurve.getMainCurveBoundaries().getTimePointAfter())) {
|
||||
++gpsFixCountWithinMainCurve;
|
||||
previousManeuverCurve != null && previousManeuverCurve
|
||||
.getManeuverCurveWithStableSpeedAndCourseBoundaries().getTimePointAfter()
|
||||
.before(maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries()
|
||||
.getTimePointBefore())
|
||||
? previousManeuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries()
|
||||
.getTimePointAfter()
|
||||
: maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries()
|
||||
.getTimePointBefore(),
|
||||
true,
|
||||
nextManeuverCurve != null && nextManeuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries()
|
||||
.getTimePointBefore()
|
||||
.after(maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries()
|
||||
.getTimePointAfter())
|
||||
? nextManeuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries()
|
||||
.getTimePointBefore()
|
||||
: maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries()
|
||||
.getTimePointAfter(),
|
||||
true)) {
|
||||
if (fix.getTimePoint().before(
|
||||
maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries().getTimePointBefore())) {
|
||||
++gpsFixesCountFromPreviousManeuver;
|
||||
} else if (fix.getTimePoint().after(
|
||||
maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries().getTimePointAfter())) {
|
||||
++gpsFixesCountToNextManeuver;
|
||||
} else {
|
||||
if (!fix.getTimePoint().before(maneuverCurve.getMainCurveBoundaries().getTimePointBefore())
|
||||
&& !fix.getTimePoint().after(maneuverCurve.getMainCurveBoundaries().getTimePointAfter())) {
|
||||
++gpsFixCountWithinMainCurve;
|
||||
}
|
||||
++gpsFixCountWithinWholeCurve;
|
||||
}
|
||||
++gpsFixCountWithinWholeCurve;
|
||||
}
|
||||
} finally {
|
||||
track.unlockAfterRead();
|
||||
@@ -338,8 +364,9 @@ public class ManeuverDetectorImpl implements ManeuverDetector {
|
||||
maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries().getDirectionChangeInDegrees(),
|
||||
maneuverCurve.getManeuverCurveWithStableSpeedAndCourseBoundaries().getLowestSpeed(),
|
||||
durationAndAvgSpeedWithBearingBefore.getB(), durationAndAvgSpeedWithBearingBefore.getA(),
|
||||
durationAndAvgSpeedWithBearingAfter.getB(), durationAndAvgSpeedWithBearingAfter.getA(),
|
||||
distanceSailedWithinManeuver, projectedManeuverLoss.getDistanceSailed(), distanceSailedIfNotManeuvering,
|
||||
gpsFixesCountFromPreviousManeuver, durationAndAvgSpeedWithBearingAfter.getB(),
|
||||
durationAndAvgSpeedWithBearingAfter.getA(), gpsFixesCountToNextManeuver, distanceSailedWithinManeuver,
|
||||
projectedManeuverLoss.getDistanceSailed(), distanceSailedIfNotManeuvering,
|
||||
projectedManeuverLoss.getDistanceSailedIfNotManeuvering(), gpsFixCountWithinWholeCurve);
|
||||
TimePoint maneuverTimePoint = maneuverCurve.getMainCurveBoundaries().getTimePoint();
|
||||
Position maneuverPosition = track.getEstimatedPosition(maneuverTimePoint, /* extrapolate */false);
|
||||
@@ -511,9 +538,12 @@ public class ManeuverDetectorImpl implements ManeuverDetector {
|
||||
* <code>to</code>, or else the list of maneuver spots with corresponding maneuvers detected.
|
||||
*/
|
||||
protected List<ManeuverSpot> detectManeuvers(TimePoint earliestManeuverStart, TimePoint latestManeuverEnd) {
|
||||
return detectManeuvers(trackedRace.approximate(competitor,
|
||||
trackedRace.getRace().getBoatOfCompetitor(competitor).getBoatClass().getMaximumDistanceForCourseApproximation(),
|
||||
earliestManeuverStart, latestManeuverEnd), earliestManeuverStart, latestManeuverEnd);
|
||||
return detectManeuvers(
|
||||
trackedRace.approximate(competitor,
|
||||
trackedRace.getRace().getBoatOfCompetitor(competitor).getBoatClass()
|
||||
.getMaximumDistanceForCourseApproximation(),
|
||||
earliestManeuverStart, latestManeuverEnd),
|
||||
earliestManeuverStart, latestManeuverEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,7 +622,8 @@ public class ManeuverDetectorImpl implements ManeuverDetector {
|
||||
if (lastCourseChangeDirection != newCourseChangeDirection) {
|
||||
return false;
|
||||
}
|
||||
Distance threeHullLengths = trackedRace.getRace().getBoatOfCompetitor(competitor).getBoatClass().getHullLength().scale(3);
|
||||
Distance threeHullLengths = trackedRace.getRace().getBoatOfCompetitor(competitor).getBoatClass().getHullLength()
|
||||
.scale(3);
|
||||
if (currentFix.getTimePoint().asMillis()
|
||||
- previousFix.getTimePoint().asMillis() > getApproximateManeuverDuration().asMillis()
|
||||
&& currentFix.getPosition().getDistance(previousFix.getPosition()).compareTo(threeHullLengths) > 0) {
|
||||
|
||||
+6
@@ -19,6 +19,8 @@ public class ManeuverCurveWithUnstableCourseAndSpeedWithEstimationDataJsonSerial
|
||||
public final static String AVERAGE_COURSE_AFTER_IN_DEGREES = "averageCourseAfterInDegrees";
|
||||
public final static String DURATION_FROM_PREVIOUS_MANEUVER_IN_SECONDS = "durationFromPreviousManeuverInSeconds";
|
||||
public final static String DURATION_TO_NEXT_MANEUVER_IN_SECONDS = "durationToNextManeuverInSeconds";
|
||||
public final static String GPS_FIXES_COUNT_FROM_PREVIOUS_MANEUVER_IN_SECONDS = "gpsFixesCountFromPreviousManeuver";
|
||||
public final static String GPS_FIXES_COUNT_TO_NEXT_MANEUVER_IN_SECONDS = "gpsFixesCountToNextManeuver";
|
||||
public static final String GPS_FIXES_COUNT = "gpsFixesCount";
|
||||
|
||||
@Override
|
||||
@@ -41,6 +43,10 @@ public class ManeuverCurveWithUnstableCourseAndSpeedWithEstimationDataJsonSerial
|
||||
curve.getDurationFromManeuverEndToNextManeuverStart() == null ? null
|
||||
: curve.getDurationFromManeuverEndToNextManeuverStart().asSeconds());
|
||||
result.put(GPS_FIXES_COUNT, curve.getGpsFixesCount());
|
||||
result.put(GPS_FIXES_COUNT_FROM_PREVIOUS_MANEUVER_IN_SECONDS,
|
||||
curve.getGpsFixesCountFromPreviousManeuverEndToManeuverStart());
|
||||
result.put(GPS_FIXES_COUNT_TO_NEXT_MANEUVER_IN_SECONDS,
|
||||
curve.getGpsFixesCountFromManeuverEndToNextManeuverStart());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user