753892a2bad490018ae54e9210560be5657d92a6
java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/CourseChangeBasedTrackApproximationTest.java
| ... | ... | @@ -69,15 +69,22 @@ public class CourseChangeBasedTrackApproximationTest { |
| 69 | 69 | @Test |
| 70 | 70 | public void testDirectionChangeJustAboveThreshold() { |
| 71 | 71 | final Duration samplingInterval = Duration.ONE_SECOND; |
| 72 | - final double aBitOverMinimumManeuverAngleDegrees = boatClass.getManeuverDegreeAngleThreshold() * 1.2; |
|
| 72 | + final double aBitOverMinimumManeuverAngleDegrees = boatClass.getManeuverDegreeAngleThreshold() * 1.5; |
|
| 73 | 73 | final TimePoint start = TimePoint.of(10000l); |
| 74 | 74 | final Speed speed = new KnotSpeedImpl(5.0); |
| 75 | 75 | GPSFixMoving next = fix(start.asMillis(), 0, 0, speed.getKnots(), 0); |
| 76 | 76 | track.add(next); |
| 77 | 77 | // perform aBitOverMinimumManeuverAngleDegrees within five fixes: |
| 78 | 78 | final int NUMBER_OF_FIXES_FOR_MANEUVER = 5; |
| 79 | + double cog = 0.0; |
|
| 79 | 80 | for (int i=0; i<NUMBER_OF_FIXES_FOR_MANEUVER; i++) { |
| 80 | - next = travel(next, samplingInterval.asMillis(), speed.getKnots(), ((double) i+1.0)/((double) NUMBER_OF_FIXES_FOR_MANEUVER) * aBitOverMinimumManeuverAngleDegrees); |
|
| 81 | + cog = ((double) i+1.0)/((double) NUMBER_OF_FIXES_FOR_MANEUVER) * aBitOverMinimumManeuverAngleDegrees; |
|
| 82 | + next = travel(next, samplingInterval.asMillis(), speed.getKnots(), cog); |
|
| 83 | + track.add(next); |
|
| 84 | + } |
|
| 85 | + // now go straight for the maneuver duration to ensure that the approximation has read buffered fixes up to and including the end of the maneuver: |
|
| 86 | + for (int i=0; i<boatClass.getApproximateManeuverDurationInMilliseconds()/1000; i++) { |
|
| 87 | + next = travel(next, Duration.ONE_SECOND.asMillis(), speed.getKnots(), cog); |
|
| 81 | 88 | track.add(next); |
| 82 | 89 | } |
| 83 | 90 | final Iterable<GPSFixMoving> oneManeuverCandidate = approximation.approximate(start, start.plus(samplingInterval.times(NUMBER_OF_FIXES_FOR_MANEUVER))); |
| ... | ... | @@ -117,6 +124,11 @@ public class CourseChangeBasedTrackApproximationTest { |
| 117 | 124 | next = travel(next, samplingInterval.asMillis(), speed.getKnots(), cog); |
| 118 | 125 | track.add(next); |
| 119 | 126 | } |
| 127 | + // now go straight for the maneuver duration to ensure that the approximation has read buffered fixes up to and including the end of the maneuver: |
|
| 128 | + for (int i=0; i<boatClass.getApproximateManeuverDurationInMilliseconds()/1000; i++) { |
|
| 129 | + next = travel(next, Duration.ONE_SECOND.asMillis(), speed.getKnots(), cog); |
|
| 130 | + track.add(next); |
|
| 131 | + } |
|
| 120 | 132 | final Iterable<GPSFixMoving> oneManeuverCandidate = approximation.approximate(start, start.plus(samplingInterval.times(NUMBER_OF_FIXES_FOR_NON_MANEUVER+NUMBER_OF_FIXES_FOR_MANEUVER))); |
| 121 | 133 | assertFalse(Util.isEmpty(oneManeuverCandidate)); |
| 122 | 134 | assertEquals(1, Util.size(oneManeuverCandidate)); |