mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-06 12:23:55 +00:00
adjusted fix loading's "inclusive" parameter such that it only affects the end of the range
Change-Id: If8ebf61ee2943b81c1a0b09b68a64d20c1efbaf9
This commit is contained in:
1 parent
270697d704
commit
0765d330b0
6 files changed
+36
-32
No files matched your search
+1
-1
@@ -101,7 +101,7 @@ public class MongoSensorFixStoreImpl implements MongoSensorFixStore {
|
||||
queryBuilder.greaterThanEquals(loadFixesFrom.asMillis()).and(FieldNames.TIME_AS_MILLIS.name())
|
||||
.lessThanEquals(loadFixesTo.asMillis());
|
||||
} else {
|
||||
queryBuilder.greaterThan(loadFixesFrom.asMillis()).and(FieldNames.TIME_AS_MILLIS.name()).lessThan(loadFixesTo.asMillis());
|
||||
queryBuilder.greaterThanEquals(loadFixesFrom.asMillis()).and(FieldNames.TIME_AS_MILLIS.name()).lessThan(loadFixesTo.asMillis());
|
||||
}
|
||||
DBObject query = queryBuilder.get();
|
||||
DBCursor result = fixesCollection.find(query);
|
||||
|
||||
+7
-12
@@ -114,10 +114,10 @@ public class SensorFixStoreTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixesOnExclusiveBoundsArentLoaded() throws Exception {
|
||||
addBravoFix(device, FIX_TIMESTAMP, FIX_RIDE_HEIGHT);
|
||||
public void testFixesOnExclusiveEndBoundsArentLoaded() throws Exception {
|
||||
DoubleVectorFix fix = addBravoFix(device, FIX_TIMESTAMP, FIX_RIDE_HEIGHT);
|
||||
addBravoFix(device, FIX_TIMESTAMP2, FIX_RIDE_HEIGHT2);
|
||||
verifyNoFix(FIX_TIMESTAMP, FIX_TIMESTAMP2, device, false);
|
||||
verifySingleFix(fix, FIX_TIMESTAMP, FIX_TIMESTAMP2, device, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -268,22 +268,17 @@ public class SensorFixStoreTest {
|
||||
return listener;
|
||||
}
|
||||
|
||||
private void verifySingleFix(Timed expectedFix, long start, long end, DeviceIdentifier device, boolean inclusive) throws Exception {
|
||||
List<Timed> loadedFixes = loadFixes(start, end, device, inclusive);
|
||||
private void verifySingleFix(Timed expectedFix, long start, long end, DeviceIdentifier device, boolean endIsInclusive) throws Exception {
|
||||
List<Timed> loadedFixes = loadFixes(start, end, device, endIsInclusive);
|
||||
assertEquals(1, loadedFixes.size());
|
||||
assertEquals(expectedFix, loadedFixes.get(0));
|
||||
}
|
||||
|
||||
private void verifyNoFix(long start, long end, DeviceIdentifier device, boolean inclusive) throws Exception {
|
||||
List<Timed> loadedFixes = loadFixes(start, end, device, inclusive);
|
||||
assertEquals(0, loadedFixes.size());
|
||||
}
|
||||
|
||||
private List<Timed> loadFixes(long start, long end, DeviceIdentifier device, boolean inclusive)
|
||||
private List<Timed> loadFixes(long start, long end, DeviceIdentifier device, boolean endIsInclusive)
|
||||
throws TransformationException {
|
||||
List<Timed> loadedFixes = new ArrayList<>();
|
||||
|
||||
store.loadFixes(loadedFixes::add, device, new MillisecondsTimePoint(start), new MillisecondsTimePoint(end), inclusive);
|
||||
store.loadFixes(loadedFixes::add, device, new MillisecondsTimePoint(start), new MillisecondsTimePoint(end), endIsInclusive);
|
||||
return loadedFixes;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ public class FixLoaderAndTracker implements TrackingDataLoader {
|
||||
// competitor retrieved from the mapping event does not have a track in trackedRace
|
||||
try {
|
||||
sensorFixStore.loadFixes((DoubleVectorFix fix) -> mapper.addFix(track, fix), mapping.getDevice(),
|
||||
timeRangeToLoad.from(), timeRangeToLoad.to(), true);
|
||||
timeRangeToLoad.from(), timeRangeToLoad.to(), /* toIsInclusive */ false);
|
||||
} catch (NoCorrespondingServiceRegisteredException | TransformationException e) {
|
||||
logger.log(Level.WARNING, "Could not load track for competitor: " + mapping.getMappedTo()
|
||||
+ "; device: " + mapping.getDevice());
|
||||
|
||||
+10
-10
@@ -38,9 +38,9 @@ public class GPSFixStoreImpl implements GPSFixStore {
|
||||
}
|
||||
|
||||
private <FixT extends GPSFix> void loadTrack(DynamicGPSFixTrack<?, FixT> track, DeviceIdentifier device,
|
||||
TimePoint from, TimePoint to, boolean inclusive) throws NoCorrespondingServiceRegisteredException,
|
||||
TimePoint from, TimePoint to, boolean toIsInclusive) throws NoCorrespondingServiceRegisteredException,
|
||||
TransformationException {
|
||||
sensorFixStore.<FixT>loadFixes(fix->track.add(fix, /* replace */ true), device, from, to, inclusive);
|
||||
sensorFixStore.<FixT>loadFixes(fix->track.add(fix, /* replace */ true), device, from, to, toIsInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,7 +50,7 @@ public class GPSFixStoreImpl implements GPSFixStore {
|
||||
.analyze().get(competitor);
|
||||
if (mappings != null) {
|
||||
for (DeviceMapping<Competitor> mapping : mappings) {
|
||||
loadTrack(track, mapping.getDevice(), mapping.getTimeRange().from(), mapping.getTimeRange().to(), true /*inclusive*/);
|
||||
loadTrack(track, mapping.getDevice(), mapping.getTimeRange().from(), mapping.getTimeRange().to(), false /*toIsInclusive*/);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class GPSFixStoreImpl implements GPSFixStore {
|
||||
.get(mark);
|
||||
if (mappings != null) {
|
||||
for (DeviceMapping<Mark> mapping : mappings) {
|
||||
loadTrack(track, mapping.getDevice(), mapping.getTimeRange().from(), mapping.getTimeRange().to(), true /*inclusive*/);
|
||||
loadTrack(track, mapping.getDevice(), mapping.getTimeRange().from(), mapping.getTimeRange().to(), false /*toIsInclusive*/);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class GPSFixStoreImpl implements GPSFixStore {
|
||||
// /*inclusive*/);
|
||||
final TimePoint from = Util.getLatestOfTimePoints(start, mapping.getTimeRange().from());
|
||||
final TimePoint to = Util.getEarliestOfTimePoints(end, mapping.getTimeRange().to());
|
||||
loadTrack(track, mapping.getDevice(), from, to, true /* inclusive */);
|
||||
loadTrack(track, mapping.getDevice(), from, to, false /* toIsInclusive */);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class GPSFixStoreImpl implements GPSFixStore {
|
||||
throws TransformationException, NoCorrespondingServiceRegisteredException {
|
||||
final TimePoint from = Util.getLatestOfTimePoints(start, mapping.getTimeRange().from());
|
||||
final TimePoint to = Util.getEarliestOfTimePoints(end, mapping.getTimeRange().to());
|
||||
loadTrack(track, mapping.getDevice(), from, to, true /* inclusive */);
|
||||
loadTrack(track, mapping.getDevice(), from, to, false /* toIsInclusive */);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,7 +112,7 @@ public class GPSFixStoreImpl implements GPSFixStore {
|
||||
for (DeviceMapping<Mark> mapping : mappings) {
|
||||
final TimePoint from = Util.getLatestOfTimePoints(start, mapping.getTimeRange().from());
|
||||
final TimePoint to = Util.getEarliestOfTimePoints(end, mapping.getTimeRange().to());
|
||||
loadTrack(track, mapping.getDevice(), from, to, true /*inclusive*/);
|
||||
loadTrack(track, mapping.getDevice(), from, to, false /*toIsInclusive*/);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class GPSFixStoreImpl implements GPSFixStore {
|
||||
@Override
|
||||
public void loadTrack(DynamicGPSFixTrack<WithID, ?> track, DeviceMapping<WithID> mapping)
|
||||
throws NoCorrespondingServiceRegisteredException, TransformationException {
|
||||
loadTrack(track, mapping.getDevice(), mapping.getTimeRange().from(), mapping.getTimeRange().to(), true);
|
||||
loadTrack(track, mapping.getDevice(), mapping.getTimeRange().from(), mapping.getTimeRange().to(), false /* toIsInlusive */);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,9 +136,9 @@ public class GPSFixStoreImpl implements GPSFixStore {
|
||||
|
||||
@Override
|
||||
public <FixT extends GPSFix> void loadFixes(Consumer<FixT> consumer, DeviceIdentifier deviceIdentifier,
|
||||
TimePoint start, TimePoint end, boolean inclusive)
|
||||
TimePoint start, TimePoint end, boolean endIsInclusive)
|
||||
throws NoCorrespondingServiceRegisteredException, TransformationException {
|
||||
sensorFixStore.loadFixes(consumer, deviceIdentifier, start, end, inclusive);
|
||||
sensorFixStore.loadFixes(consumer, deviceIdentifier, start, end, endIsInclusive);
|
||||
}
|
||||
|
||||
}
|
||||
+15
-6
@@ -20,13 +20,22 @@ public interface SensorFixStore {
|
||||
/**
|
||||
* Loads fixes for a device in a given time range.
|
||||
*
|
||||
* @param consumer will be called for each loaded fix. Must not be <code>null</code>.
|
||||
* @param deviceIdentifier the device to load the fixes for. Must not be <code>null</code>.
|
||||
* @param start the lower bound of the time range to load. If <code>null</code>, fixes are loaded from {@link TimePoint#BeginningOfTime}.
|
||||
* @param end the upper bound of the time range to load. If <code>null</code>, fixes are loaded to {@link TimePoint#EndOfTime}.
|
||||
* @param inclusive true if fixes exactly at the bounds of the time range should be loaded, false otherwise.
|
||||
* @param consumer
|
||||
* will be called for each loaded fix. Must not be <code>null</code>.
|
||||
* @param deviceIdentifier
|
||||
* the device to load the fixes for. Must not be <code>null</code>.
|
||||
* @param start
|
||||
* the lower bound of the time range to load. If <code>null</code>, fixes are loaded from
|
||||
* {@link TimePoint#BeginningOfTime}.
|
||||
* @param end
|
||||
* the upper bound of the time range to load. If <code>null</code>, fixes are loaded to
|
||||
* {@link TimePoint#EndOfTime}.
|
||||
* @param toIsInclusive
|
||||
* true if fixes exactly at the {@code end} bounds of the time range should be loaded, false otherwise.
|
||||
* Fixes exactly on the {@code start} bounds are always loaded.
|
||||
*/
|
||||
<FixT extends Timed> void loadFixes(Consumer<FixT> consumer, DeviceIdentifier deviceIdentifier, TimePoint start, TimePoint end, boolean inclusive) throws NoCorrespondingServiceRegisteredException,
|
||||
<FixT extends Timed> void loadFixes(Consumer<FixT> consumer, DeviceIdentifier deviceIdentifier, TimePoint start, TimePoint end,
|
||||
boolean toIsInclusive) throws NoCorrespondingServiceRegisteredException,
|
||||
TransformationException;
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -471,10 +471,10 @@ public class MasterDataImportTest {
|
||||
Assert.assertEquals(registerEvent.getId(), registerEventOnTarget2.getId());
|
||||
}
|
||||
|
||||
private void verifyFix(Timed expectedFix, SensorFixStore store, TimePoint start, TimePoint end, DeviceIdentifier deviceIdentifier) {
|
||||
private void verifyFix(Timed expectedFix, SensorFixStore store, TimePoint start, TimePoint endInclusive, DeviceIdentifier deviceIdentifier) {
|
||||
List<Timed> fixes = new ArrayList<>(1);
|
||||
try {
|
||||
store.loadFixes(fixes::add, deviceIdentifier, start, end, true);
|
||||
store.loadFixes(fixes::add, deviceIdentifier, start, endInclusive, /* toIsInclusive */ true);
|
||||
assertEquals(1, fixes.size());
|
||||
assertEquals(expectedFix, fixes.get(0));
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in new issue
Block a user