fec2015f71f026d8ef360ee4676fca3410977a26
java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/CourseChangeBasedTrackApproximationTest.java
| ... | ... | @@ -37,7 +37,7 @@ public class CourseChangeBasedTrackApproximationTest { |
| 37 | 37 | final CompetitorWithBoat competitor = TrackBasedTest.createCompetitorWithBoat("Someone"); |
| 38 | 38 | track = new DynamicGPSFixMovingTrackImpl<Competitor>(competitor, |
| 39 | 39 | /* millisecondsOverWhichToAverage */5000, /* lossless compaction */true); |
| 40 | - approximation = new CourseChangeBasedTrackApproximation(track, competitor.getBoat().getBoatClass(), /* logFixes */ false); |
|
| 40 | + approximation = new CourseChangeBasedTrackApproximation(track, competitor.getBoat().getBoatClass()); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | @Test |
java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/CourseChangeBasedTrackApproximationWithTracTracDataTest.java
| ... | ... | @@ -9,6 +9,7 @@ import java.net.URI; |
| 9 | 9 | import java.net.URISyntaxException; |
| 10 | 10 | import java.net.URL; |
| 11 | 11 | import java.util.Iterator; |
| 12 | +import java.util.Random; |
|
| 12 | 13 | |
| 13 | 14 | import org.junit.jupiter.api.BeforeEach; |
| 14 | 15 | import org.junit.jupiter.api.Test; |
| ... | ... | @@ -44,9 +45,10 @@ public class CourseChangeBasedTrackApproximationWithTracTracDataTest extends Onl |
| 44 | 45 | assertFalse(Util.isEmpty(getTrackedRace().getRace().getCompetitors())); |
| 45 | 46 | do { |
| 46 | 47 | competitors = getTrackedRace().getRace().getCompetitors(); |
| 47 | - sampleCompetitor = (CompetitorWithBoat) Util.first(Util.filter(competitors, c->c.getName().equals("Anton"))); // TODO "Anton" was offending for fixes indexed 71-73 (0-based) |
|
| 48 | - short TODO; |
|
| 49 | -// sampleCompetitor = (CompetitorWithBoat) Util.get(competitors, new Random().nextInt(Util.size(competitors))); |
|
| 48 | + // To pick a single competitor, e.g., for debugging, use the following line: |
|
| 49 | + // sampleCompetitor = (CompetitorWithBoat) Util.first(Util.filter(competitors, c->c.getName().equals("Anton"))); |
|
| 50 | + // To pick a random competitor, use the following line: |
|
| 51 | + sampleCompetitor = (CompetitorWithBoat) Util.get(competitors, new Random().nextInt(Util.size(competitors))); |
|
| 50 | 52 | sampleTrack = getTrackedRace().getTrack(sampleCompetitor); |
| 51 | 53 | } while (sampleTrack.isEmpty()); |
| 52 | 54 | } |
| ... | ... | @@ -70,10 +72,9 @@ public class CourseChangeBasedTrackApproximationWithTracTracDataTest extends Onl |
| 70 | 72 | final DynamicGPSFixTrack<Competitor, GPSFixMoving> trackCopy = new DynamicGPSFixMovingTrackImpl<Competitor>( |
| 71 | 73 | sampleCompetitor, |
| 72 | 74 | /* millisecondsOverWhichToAverage */ boatClass.getApproximateManeuverDurationInMilliseconds()); |
| 73 | - final CourseChangeBasedTrackApproximation earlyInitApproximation = new CourseChangeBasedTrackApproximation(trackCopy, sampleCompetitor.getBoat().getBoatClass(), /* logFixes */ true); |
|
| 75 | + final CourseChangeBasedTrackApproximation earlyInitApproximation = new CourseChangeBasedTrackApproximation(trackCopy, sampleCompetitor.getBoat().getBoatClass()); |
|
| 74 | 76 | final TimePoint from = sampleTrack.getFirstRawFix().getTimePoint(); |
| 75 | 77 | final TimePoint to = sampleTrack.getLastRawFix().getTimePoint(); |
| 76 | - System.out.println("approxId,fixTimeMillis,validityCached,speedCached,COG,SOG"); |
|
| 77 | 78 | sampleTrack.lockForRead(); |
| 78 | 79 | try { |
| 79 | 80 | for (final GPSFixMoving fix : sampleTrack.getRawFixes()) { |
| ... | ... | @@ -82,7 +83,7 @@ public class CourseChangeBasedTrackApproximationWithTracTracDataTest extends Onl |
| 82 | 83 | } finally { |
| 83 | 84 | sampleTrack.unlockAfterRead(); |
| 84 | 85 | } |
| 85 | - final CourseChangeBasedTrackApproximation lateInitApproximation = new CourseChangeBasedTrackApproximation(trackCopy, sampleCompetitor.getBoat().getBoatClass(), /* logFixes */ true); |
|
| 86 | + final CourseChangeBasedTrackApproximation lateInitApproximation = new CourseChangeBasedTrackApproximation(trackCopy, sampleCompetitor.getBoat().getBoatClass()); |
|
| 86 | 87 | assertEquals(earlyInitApproximation.getNumberOfFixesAdded(), lateInitApproximation.getNumberOfFixesAdded(), "Number of fixes added to approximators differs"); |
| 87 | 88 | final Iterable<GPSFixMoving> earlyInitResult = earlyInitApproximation.approximate(from, to); |
| 88 | 89 | final Iterable<GPSFixMoving> lateInitResult = lateInitApproximation.approximate(from, to); |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/CourseChangeBasedTrackApproximation.java
| ... | ... | @@ -135,15 +135,7 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra |
| 135 | 135 | private final double maneuverAngleInDegreesThreshold; |
| 136 | 136 | private Duration windowDuration; |
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * For debugging purposes, this flag can be set to {@code true} through the constructor, which will then log all |
|
| 140 | - * fixes' values about estimated COG/SOG when moving from the {@link #queueOfNewFixes} into the {@link #window}. |
|
| 141 | - * This is particularly helpful to analyze the influence of seeing or not seeing newer fixes on the track. |
|
| 142 | - */ |
|
| 143 | - private final boolean logFixes; |
|
| 144 | - |
|
| 145 | - FixWindow(boolean logFixes) { |
|
| 146 | - this.logFixes = logFixes; |
|
| 138 | + FixWindow() { |
|
| 147 | 139 | this.window = new LinkedList<>(); |
| 148 | 140 | this.queueOfNewFixes = new LinkedList<>(); |
| 149 | 141 | this.speedForFixesInWindow = new LinkedList<>(); |
| ... | ... | @@ -250,13 +242,6 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra |
| 250 | 242 | assert window.isEmpty() || !next.getTimePoint().before(window.peekFirst().getTimePoint()); |
| 251 | 243 | final GPSFixMoving result; |
| 252 | 244 | final SpeedWithBearing nextSpeed = next.isEstimatedSpeedCached() ? next.getCachedEstimatedSpeed() : track.getEstimatedSpeed(next.getTimePoint()); |
| 253 | - if (logFixes) { |
|
| 254 | - // CSV logging: approxId, fixIndex, fixTimeMillis, validityCached, speedCached, COG, SOG |
|
| 255 | - System.out.println(System.identityHashCode(this) + "," + next.getTimePoint().asMillis() + "," |
|
| 256 | - + next.isValidityCached() + "," + next.isEstimatedSpeedCached() + "," |
|
| 257 | - + (nextSpeed == null ? "null" : nextSpeed.getBearing().getDegrees()) + "," |
|
| 258 | - + (nextSpeed == null ? "null" : nextSpeed.getKnots())); |
|
| 259 | - } |
|
| 260 | 245 | if (nextSpeed != null) { |
| 261 | 246 | numberOfFixesAdded++; |
| 262 | 247 | int insertPosition = window.size(); |
| ... | ... | @@ -413,10 +398,10 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra |
| 413 | 398 | } |
| 414 | 399 | } |
| 415 | 400 | |
| 416 | - public CourseChangeBasedTrackApproximation(GPSFixTrack<Competitor, GPSFixMoving> track, BoatClass boatClass, boolean logFixes) { |
|
| 401 | + public CourseChangeBasedTrackApproximation(GPSFixTrack<Competitor, GPSFixMoving> track, BoatClass boatClass) { |
|
| 417 | 402 | this.track = track; |
| 418 | 403 | this.boatClass = boatClass; |
| 419 | - this.fixWindow = new FixWindow(logFixes); |
|
| 404 | + this.fixWindow = new FixWindow(); |
|
| 420 | 405 | this.maneuverCandidates = new TreeSet<>(TimedComparator.INSTANCE); |
| 421 | 406 | track.addListener(this); |
| 422 | 407 | addAllFixesOfTrack(); |
| ... | ... | @@ -474,7 +459,7 @@ public class CourseChangeBasedTrackApproximation implements Serializable, GPSTra |
| 474 | 459 | if (fixWindow.isAtOrAfterFirst(fix.getTimePoint())) { |
| 475 | 460 | addFix(fix); |
| 476 | 461 | } else { |
| 477 | - final FixWindow outOfOrderWindow = new FixWindow(/* logFixes */ false); |
|
| 462 | + final FixWindow outOfOrderWindow = new FixWindow(); |
|
| 478 | 463 | final Duration maximumWindowLength = outOfOrderWindow.getMaximumWindowLength(); |
| 479 | 464 | // fix is an out-of-order delivery; construct a new FixWindow and analyze the track around the new fix. |
| 480 | 465 | // A time range around the fix is constructed that will be re-scanned. The time range covers at least |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java
| ... | ... | @@ -585,7 +585,7 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl |
| 585 | 585 | markPassingsForCompetitor.put(competitor, new ConcurrentSkipListSet<MarkPassing>(MarkPassingByTimeComparator.INSTANCE)); |
| 586 | 586 | final DynamicGPSFixMovingTrackImpl<Competitor> track = new DynamicGPSFixMovingTrackImpl<Competitor>(competitor, millisecondsOverWhichToAverageSpeed); |
| 587 | 587 | tracks.put(competitor, track); |
| 588 | - maneuverApproximators.put(competitor, new CourseChangeBasedTrackApproximation(track, race.getBoatOfCompetitor(competitor).getBoatClass(), /* logFixes */ false)); |
|
| 588 | + maneuverApproximators.put(competitor, new CourseChangeBasedTrackApproximation(track, race.getBoatOfCompetitor(competitor).getBoatClass())); |
|
| 589 | 589 | } |
| 590 | 590 | markPassingsForWaypoint = new ConcurrentHashMap<Waypoint, NavigableSet<MarkPassing>>(); |
| 591 | 591 | for (Waypoint waypoint : race.getCourse().getWaypoints()) { |