bug6209: count fixes actually added to the approximator

This commit is contained in:
Axel Uhl committed 2026-01-28 18:48:36 +01:00
1 parent b546c6b3e4
commit f6d9b8aefb
2 files changed
+14 -5

No files matched your search

@@ -47,11 +47,13 @@ public class CourseChangeBasedTrackApproximationTest extends OnlineTracTracBased
new URL("file:///" + new File("resources/event_20110609_KielerWoch-505_Race_2.txt").getCanonicalPath()),
/* liveUri */ null, /* storedUri */ storedUri,
new ReceiverType[] { ReceiverType.RACECOURSE, ReceiverType.RAWPOSITIONS });
getTrackedRace().waitUntilNotLoading();
assertFalse(Util.isEmpty(getTrackedRace().getRace().getCompetitors()));
final DynamicGPSFixTrack<Competitor, GPSFixMoving> sampleTrack = getTrackedRace().getTrack(getTrackedRace().getRace().getCompetitors().iterator().next());
final Competitor sampleCompetitor = getTrackedRace().getRace().getCompetitors().iterator().next();
final DynamicGPSFixTrack<Competitor, GPSFixMoving> sampleTrack = getTrackedRace().getTrack(sampleCompetitor);
sampleTrack.lockForRead();
try {
assertFalse(Util.isEmpty(sampleTrack.getRawFixes()));
assertFalse(Util.isEmpty(sampleTrack.getRawFixes()), "Track of competitor "+sampleCompetitor.getName()+" is empty");
} finally {
sampleTrack.unlockAfterRead();
}
@@ -93,6 +95,7 @@ public class CourseChangeBasedTrackApproximationTest extends OnlineTracTracBased
sampleTrack.unlockAfterRead();
}
final CourseChangeBasedTrackApproximation lateInitApproximation = new CourseChangeBasedTrackApproximation(trackCopy, sampleCompetitor.getBoat().getBoatClass());
assertEquals(earlyInitApproximation.getNumberOfFixesAdded(), lateInitApproximation.getNumberOfFixesAdded(), "Number of fixes added to approximators differs");
final Iterable<GPSFixMoving> earlyInitResult = earlyInitApproximation.approximate(from, to);
final Iterable<GPSFixMoving> lateInitResult = lateInitApproximation.approximate(from, to);
assertEquals(Util.size(earlyInitResult), Util.size(lateInitResult), "Different numbers of approximation points for competitor "+sampleCompetitor.getName());
@@ -62,9 +62,10 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
/**
* The set needs no special synchronization; all methods on this {@link CourseChangeBasedTrackApproximation} object
* that may mutate it are {@code synchronized} methods.
* that may read or mutate it are {@code synchronized} methods.
*/
private final NavigableSet<GPSFixMoving> maneuverCandidates;
private int numberOfFixesAdded;
/**
* The fix window consists of the list of fixes, a corresponding list with the course changes at each fix within the
@@ -155,6 +156,7 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
final GPSFixMoving result;
final SpeedWithBearing nextSpeed = next.isEstimatedSpeedCached() ? next.getCachedEstimatedSpeed() : track.getEstimatedSpeed(next.getTimePoint());
if (nextSpeed != null) {
numberOfFixesAdded++;
int insertPosition = window.size();
GPSFixMoving previous;
SpeedWithBearing previousSpeed;
@@ -340,7 +342,7 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
private synchronized void addAllFixesOfTrack() {
track.lockForRead();
try {
for (final GPSFixMoving fix : track.getFixes()) {
for (final GPSFixMoving fix : track.getRawFixes()) {
addFix(fix);
}
} finally {
@@ -363,6 +365,10 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
}
}
public int getNumberOfFixesAdded() {
return numberOfFixesAdded;
}
/**
* We want the listener relationship with the track to be serialized, e.g., during initial load / replication
*/
@@ -417,7 +423,7 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra
}
/**
* Precondition: the caller holds at least a read lock on {@link #maneuverCandidatesLock}
* Precondition: the caller owns this object's monitor ({@code synchronized})
*/
private GPSFixMoving getExistingManeuverCandidateInRange(TimeRange leftPartOfTimeRangeToReScan) {
final GPSFixMoving firstCandidateAtOrAfterStartOfTimeRange = maneuverCandidates.ceiling(