8a59e04a7b5a4378b0ab31c4f92f88873f932065
java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/tracking/WithEstimatedSpeedCache.java
| ... | ... | @@ -12,6 +12,6 @@ public interface WithEstimatedSpeedCache { |
| 12 | 12 | |
| 13 | 13 | void invalidateEstimatedSpeedCache(); |
| 14 | 14 | |
| 15 | - void cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed); |
|
| 15 | + SpeedWithBearing cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed); |
|
| 16 | 16 | |
| 17 | 17 | } |
java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/tracking/impl/AbstractCompactGPSFixImpl.java
| ... | ... | @@ -84,7 +84,7 @@ public abstract class AbstractCompactGPSFixImpl extends AbstractGPSFixImpl { |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | @Override |
| 87 | - public void invalidateCache() { |
|
| 87 | + public synchronized void invalidateCache() { |
|
| 88 | 88 | whatIsCached &= ~IS_VALIDITY_CACHED; |
| 89 | 89 | } |
| 90 | 90 | |
| ... | ... | @@ -104,12 +104,13 @@ public abstract class AbstractCompactGPSFixImpl extends AbstractGPSFixImpl { |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | @Override |
| 107 | - public void invalidateEstimatedSpeedCache() { |
|
| 107 | + public synchronized void invalidateEstimatedSpeedCache() { |
|
| 108 | 108 | whatIsCached &= ~IS_ESTIMATED_SPEED_CACHED; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | @Override |
| 112 | - public void cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 112 | + public synchronized SpeedWithBearing cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 113 | 113 | whatIsCached |= IS_ESTIMATED_SPEED_CACHED; |
| 114 | + return super.cacheEstimatedSpeed(estimatedSpeed); |
|
| 114 | 115 | } |
| 115 | 116 | } |
java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/tracking/impl/AbstractGPSFixImpl.java
| ... | ... | @@ -96,6 +96,7 @@ public abstract class AbstractGPSFixImpl implements GPSFix { |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | @Override |
| 99 | - public void cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 99 | + public SpeedWithBearing cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 100 | + return estimatedSpeed; |
|
| 100 | 101 | } |
| 101 | 102 | } |
java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/tracking/impl/PreciseCompactGPSFixImpl.java
| ... | ... | @@ -97,9 +97,9 @@ public class PreciseCompactGPSFixImpl extends AbstractCompactGPSFixImpl { |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | @Override |
| 100 | - public void cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 100 | + public SpeedWithBearing cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 101 | 101 | cachedEstimatedSpeedBearingInDegrees = estimatedSpeed.getBearing().getDegrees(); |
| 102 | 102 | cachedEstimatedSpeedInKnots = estimatedSpeed.getKnots(); |
| 103 | - super.cacheEstimatedSpeed(estimatedSpeed); |
|
| 103 | + return super.cacheEstimatedSpeed(estimatedSpeed); |
|
| 104 | 104 | } |
| 105 | 105 | } |
java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/tracking/impl/PreciseCompactGPSFixMovingImpl.java
| ... | ... | @@ -154,9 +154,9 @@ public class PreciseCompactGPSFixMovingImpl extends AbstractCompactGPSFixMovingI |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | @Override |
| 157 | - public void cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 157 | + public SpeedWithBearing cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 158 | 158 | cachedEstimatedSpeedBearingInDegrees = estimatedSpeed.getBearing().getDegrees(); |
| 159 | 159 | cachedEstimatedSpeedInKnots = estimatedSpeed.getKnots(); |
| 160 | - super.cacheEstimatedSpeed(estimatedSpeed); |
|
| 160 | + return super.cacheEstimatedSpeed(estimatedSpeed); |
|
| 161 | 161 | } |
| 162 | 162 | } |
java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/tracking/impl/VeryCompactGPSFixImpl.java
| ... | ... | @@ -7,10 +7,12 @@ import com.sap.sailing.domain.common.AbstractPosition; |
| 7 | 7 | import com.sap.sailing.domain.common.Position; |
| 8 | 8 | import com.sap.sailing.domain.common.SpeedWithBearing; |
| 9 | 9 | import com.sap.sailing.domain.common.impl.AbstractSpeedWithAbstractBearingImpl; |
| 10 | +import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl; |
|
| 10 | 11 | import com.sap.sailing.domain.common.tracking.GPSFix; |
| 11 | 12 | import com.sap.sse.common.AbstractBearing; |
| 12 | 13 | import com.sap.sse.common.Bearing; |
| 13 | 14 | import com.sap.sse.common.TimePoint; |
| 15 | +import com.sap.sse.common.impl.DegreeBearingImpl; |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * A compact representation of a GPS fix which collects all primitive-typed attributes in one object to avoid |
| ... | ... | @@ -116,13 +118,17 @@ public class VeryCompactGPSFixImpl extends AbstractCompactGPSFixImpl { |
| 116 | 118 | * uncached. |
| 117 | 119 | */ |
| 118 | 120 | @Override |
| 119 | - public void cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 121 | + public synchronized SpeedWithBearing cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 120 | 122 | try { |
| 121 | 123 | cachedEstimatedSpeedInKnotsScaled = CompactPositionHelper.getKnotSpeedScaled(estimatedSpeed); |
| 122 | 124 | cachedEstimatedSpeedBearingInDegreesScaled = CompactPositionHelper.getDegreeBearingScaled(estimatedSpeed.getBearing()); |
| 123 | 125 | super.cacheEstimatedSpeed(estimatedSpeed); |
| 126 | + final SpeedWithBearing veryCompactEstimatedSpeed = getCachedEstimatedSpeed(); |
|
| 127 | + return new KnotSpeedWithBearingImpl(veryCompactEstimatedSpeed.getKnots(), |
|
| 128 | + new DegreeBearingImpl(veryCompactEstimatedSpeed.getBearing().getDegrees())); |
|
| 124 | 129 | } catch (CompactionNotPossibleException e) { |
| 125 | 130 | logger.log(Level.FINER, "Cannot cache estimated speed "+estimatedSpeed+" in compact fix:", e); |
| 131 | + return estimatedSpeed; |
|
| 126 | 132 | } |
| 127 | 133 | } |
| 128 | 134 | } |
java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/tracking/impl/VeryCompactGPSFixMovingImpl.java
| ... | ... | @@ -7,10 +7,12 @@ import com.sap.sailing.domain.common.AbstractPosition; |
| 7 | 7 | import com.sap.sailing.domain.common.Position; |
| 8 | 8 | import com.sap.sailing.domain.common.SpeedWithBearing; |
| 9 | 9 | import com.sap.sailing.domain.common.impl.AbstractSpeedWithAbstractBearingImpl; |
| 10 | +import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl; |
|
| 10 | 11 | import com.sap.sailing.domain.common.tracking.GPSFixMoving; |
| 11 | 12 | import com.sap.sse.common.AbstractBearing; |
| 12 | 13 | import com.sap.sse.common.Bearing; |
| 13 | 14 | import com.sap.sse.common.TimePoint; |
| 15 | +import com.sap.sse.common.impl.DegreeBearingImpl; |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * A memory-conserving representation of a {@link GPSFixMoving} object that produces the fine-grained |
| ... | ... | @@ -187,13 +189,17 @@ public class VeryCompactGPSFixMovingImpl extends AbstractCompactGPSFixMovingImpl |
| 187 | 189 | * uncached. |
| 188 | 190 | */ |
| 189 | 191 | @Override |
| 190 | - public void cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 192 | + public synchronized SpeedWithBearing cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 191 | 193 | try { |
| 192 | 194 | cachedEstimatedSpeedInKnotsScaled = CompactPositionHelper.getKnotSpeedScaled(estimatedSpeed); |
| 193 | 195 | cachedEstimatedSpeedBearingInDegreesScaled = CompactPositionHelper.getDegreeBearingScaled(estimatedSpeed.getBearing()); |
| 194 | 196 | super.cacheEstimatedSpeed(estimatedSpeed); |
| 197 | + final SpeedWithBearing veryCompactEstimatedSpeed = getCachedEstimatedSpeed(); |
|
| 198 | + return new KnotSpeedWithBearingImpl(veryCompactEstimatedSpeed.getKnots(), |
|
| 199 | + new DegreeBearingImpl(veryCompactEstimatedSpeed.getBearing().getDegrees())); |
|
| 195 | 200 | } catch (CompactionNotPossibleException e) { |
| 196 | 201 | logger.log(Level.FINER, "Cannot cache estimated speed "+estimatedSpeed+" in compact fix:", e); |
| 202 | + return estimatedSpeed; |
|
| 197 | 203 | } |
| 198 | 204 | } |
| 199 | 205 | } |
java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/GPSFixTrackImpl.java
| ... | ... | @@ -275,7 +275,8 @@ public abstract class GPSFixTrackImpl<ItemType, FixType extends GPSFix> extends |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | @Override |
| 278 | - public void cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 278 | + public SpeedWithBearing cacheEstimatedSpeed(SpeedWithBearing estimatedSpeed) { |
|
| 279 | + return estimatedSpeed; |
|
| 279 | 280 | } |
| 280 | 281 | } |
| 281 | 282 | |
| ... | ... | @@ -633,8 +634,7 @@ public abstract class GPSFixTrackImpl<ItemType, FixType extends GPSFix> extends |
| 633 | 634 | getMillisecondsOverWhichToAverageSpeed() / 2, /* minimumConfidence */ 0.00000001)); // half confidence if half averaging interval apart |
| 634 | 635 | if (estimatedSpeed != null) { |
| 635 | 636 | if (ceil != null && ceil.getTimePoint().equals(at)) { |
| 636 | - ceil.cacheEstimatedSpeed(estimatedSpeed.getObject()); |
|
| 637 | - result = ceil.getCachedEstimatedSpeed(); // this way, should the fix apply compaction, we will still return consistent (compacted) results |
|
| 637 | + result = ceil.cacheEstimatedSpeed(estimatedSpeed.getObject()); // this way, should the fix apply compaction, we will still return consistent (compacted) results |
|
| 638 | 638 | } else { |
| 639 | 639 | result = estimatedSpeed.getObject(); |
| 640 | 640 | } |