@Test public void testIsDriftDistanceLongEnough() { final long t0 = System.currentTimeMillis(); final long dt = 7000; Track track = new Track(219000001); track.update(t0, Position.create(56.0, 12.0), 45.0f, 12.0f, 45.1f); assertFalse(driftAnalysis.isDriftDistanceLongEnough(track)); track.update(t0+dt, Position.create(56.0001, 12.0001), 45.0f, 12.0f, 45.1f); assertFalse(driftAnalysis.isDriftDistanceLongEnough(track)); track = new Track(219000001); track.update(t0, Position.create(56.0000, 11.0000), -45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); assertFalse(driftAnalysis.isDriftDistanceLongEnough(track)); track.update(t0+dt, Position.create(56.0001, 11.0001), -45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); assertFalse(driftAnalysis.isDriftDistanceLongEnough(track)); track.update(t0+2*dt, Position.create(56.0010, 11.0010), -45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); assertFalse(driftAnalysis.isDriftDistanceLongEnough(track)); track.update(t0+3*dt, Position.create(56.0100, 11.0100), -45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); assertTrue(driftAnalysis.isDriftDistanceLongEnough(track)); }
boolean isDriftDistanceLongEnough(Track track) { TrackingReport driftStart, driftEnd; driftEnd = track.getNewestTrackingReport(); if (!isDrifting(driftEnd)) { return false; } driftStart = driftEnd; List<TrackingReport> trackingReports = track.getTrackingReports(); final int n = trackingReports.size(); for (int i = n - 1; i >= 0; i--) { TrackingReport trackingReport = trackingReports.get(i); if (isDrifting(trackingReport)) { driftStart = trackingReport; } else { break; } } final double distanceDriftedInMeters = driftStart.getPosition().rhumbLineDistanceTo(driftEnd.getPosition()); return distanceDriftedInMeters > OBSERVATION_DISTANCE_METERS; }
DriftAnalysis extends Analysis { boolean isDriftDistanceLongEnough(Track track) { TrackingReport driftStart, driftEnd; driftEnd = track.getNewestTrackingReport(); if (!isDrifting(driftEnd)) { return false; } driftStart = driftEnd; List<TrackingReport> trackingReports = track.getTrackingReports(); final int n = trackingReports.size(); for (int i = n - 1; i >= 0; i--) { TrackingReport trackingReport = trackingReports.get(i); if (isDrifting(trackingReport)) { driftStart = trackingReport; } else { break; } } final double distanceDriftedInMeters = driftStart.getPosition().rhumbLineDistanceTo(driftEnd.getPosition()); return distanceDriftedInMeters > OBSERVATION_DISTANCE_METERS; } }
DriftAnalysis extends Analysis { boolean isDriftDistanceLongEnough(Track track) { TrackingReport driftStart, driftEnd; driftEnd = track.getNewestTrackingReport(); if (!isDrifting(driftEnd)) { return false; } driftStart = driftEnd; List<TrackingReport> trackingReports = track.getTrackingReports(); final int n = trackingReports.size(); for (int i = n - 1; i >= 0; i--) { TrackingReport trackingReport = trackingReports.get(i); if (isDrifting(trackingReport)) { driftStart = trackingReport; } else { break; } } final double distanceDriftedInMeters = driftStart.getPosition().rhumbLineDistanceTo(driftEnd.getPosition()); return distanceDriftedInMeters > OBSERVATION_DISTANCE_METERS; } @Inject  DriftAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository); }
DriftAnalysis extends Analysis { boolean isDriftDistanceLongEnough(Track track) { TrackingReport driftStart, driftEnd; driftEnd = track.getNewestTrackingReport(); if (!isDrifting(driftEnd)) { return false; } driftStart = driftEnd; List<TrackingReport> trackingReports = track.getTrackingReports(); final int n = trackingReports.size(); for (int i = n - 1; i >= 0; i--) { TrackingReport trackingReport = trackingReports.get(i); if (isDrifting(trackingReport)) { driftStart = trackingReport; } else { break; } } final double distanceDriftedInMeters = driftStart.getPosition().rhumbLineDistanceTo(driftEnd.getPosition()); return distanceDriftedInMeters > OBSERVATION_DISTANCE_METERS; } @Inject  DriftAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository); @Override String toString(); @AllowConcurrentEvents @Subscribe void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent); @AllowConcurrentEvents @Subscribe void onTrackStale(TrackStaleEvent trackEvent); }
DriftAnalysis extends Analysis { boolean isDriftDistanceLongEnough(Track track) { TrackingReport driftStart, driftEnd; driftEnd = track.getNewestTrackingReport(); if (!isDrifting(driftEnd)) { return false; } driftStart = driftEnd; List<TrackingReport> trackingReports = track.getTrackingReports(); final int n = trackingReports.size(); for (int i = n - 1; i >= 0; i--) { TrackingReport trackingReport = trackingReports.get(i); if (isDrifting(trackingReport)) { driftStart = trackingReport; } else { break; } } final double distanceDriftedInMeters = driftStart.getPosition().rhumbLineDistanceTo(driftEnd.getPosition()); return distanceDriftedInMeters > OBSERVATION_DISTANCE_METERS; } @Inject  DriftAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository); @Override String toString(); @AllowConcurrentEvents @Subscribe void onSpeedOverGroundUpdated(PositionChangedEvent trackEvent); @AllowConcurrentEvents @Subscribe void onTrackStale(TrackStaleEvent trackEvent);  }