@Test public void testIsSustainedDrift() { final long t0 = System.currentTimeMillis(); final long dt = 7000; Track track = new Track(219000001); for (int i=0; i < 100; i++) { track.update(t0+i*dt, Position.create(56.0 + 0.001*i, 12.0 + 0.001*i), 45.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); assertFalse(driftAnalysis.isSustainedDrift(track)); } track = new Track(219000001); int i=0; while (i*dt < driftAnalysis.OBSERVATION_PERIOD_MINUTES*60*1000) { track.update(t0 + i*dt, Position.create(56.0 + i*0.0001, 12.0 + i*0.0001), -54.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); assertFalse(driftAnalysis.isSustainedDrift(track)); i++; } track = new Track(219000001); i=0; while (i*dt < driftAnalysis.OBSERVATION_PERIOD_MINUTES*60*1000) { track.update(t0 + i*dt, Position.create(56.0 + i*0.00001, 12.0 + i*0.00001), -54.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); assertFalse(driftAnalysis.isSustainedDrift(track)); i++; } track.update(t0 + i*dt, Position.create(56.0 + i*0.00001, 12.0 + i*0.00001), -54.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); System.out.println("Track drifted " + track.getNewestTrackingReport().getPosition().rhumbLineDistanceTo(track.getOldestTrackingReport().getPosition()) + " meters in " + i*dt/1000/60 + " minutes"); assertFalse(driftAnalysis.isSustainedDrift(track)); track = new Track(219000001); i=0; while (i*dt < driftAnalysis.OBSERVATION_PERIOD_MINUTES*60*1000) { track.update(t0 + i*dt, Position.create(56.0 + i*0.0001, 12.0 + i*0.0001), -54.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); assertFalse(driftAnalysis.isSustainedDrift(track)); i++; } track.update(t0 + i*dt, Position.create(56.0 + i*0.0001, 12.0 + i*0.0001), -54.0f, (float) (driftAnalysis.SPEED_LOW_MARK + 0.5), 45.1f); System.out.println("Track drifted " + track.getNewestTrackingReport().getPosition().rhumbLineDistanceTo(track.getOldestTrackingReport().getPosition()) + " meters in " + i*dt/1000/60 + " minutes"); assertTrue(driftAnalysis.isSustainedDrift(track)); }
boolean isSustainedDrift(Track track) { if (!isTrackedForLongEnough(track)) { LOG.debug(nameOrMmsi(track.getShipName(), track.getMmsi()) + " not observed for long enough to consider sustained drift."); return false; } return isDriftPeriodLongEnough(track) && isDriftDistanceLongEnough(track); }
DriftAnalysis extends Analysis { boolean isSustainedDrift(Track track) { if (!isTrackedForLongEnough(track)) { LOG.debug(nameOrMmsi(track.getShipName(), track.getMmsi()) + " not observed for long enough to consider sustained drift."); return false; } return isDriftPeriodLongEnough(track) && isDriftDistanceLongEnough(track); } }
DriftAnalysis extends Analysis { boolean isSustainedDrift(Track track) { if (!isTrackedForLongEnough(track)) { LOG.debug(nameOrMmsi(track.getShipName(), track.getMmsi()) + " not observed for long enough to consider sustained drift."); return false; } return isDriftPeriodLongEnough(track) && isDriftDistanceLongEnough(track); } @Inject  DriftAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository); }
DriftAnalysis extends Analysis { boolean isSustainedDrift(Track track) { if (!isTrackedForLongEnough(track)) { LOG.debug(nameOrMmsi(track.getShipName(), track.getMmsi()) + " not observed for long enough to consider sustained drift."); return false; } return isDriftPeriodLongEnough(track) && isDriftDistanceLongEnough(track); } @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 isSustainedDrift(Track track) { if (!isTrackedForLongEnough(track)) { LOG.debug(nameOrMmsi(track.getShipName(), track.getMmsi()) + " not observed for long enough to consider sustained drift."); return false; } return isDriftPeriodLongEnough(track) && isDriftDistanceLongEnough(track); } @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);  }