@Test public void testFindNearByTracks() throws Exception { Set<Track> nearByTracks = analysis.findNearByTracks(tracks, track, maxTimestampDeviationMillis, maxDistanceDeviationMeters); assertEquals(3, nearByTracks.size()); assertTrue(nearByTracks.contains(oldNearbyTrack)); assertTrue(nearByTracks.contains(newNearbyTrack)); assertTrue(nearByTracks.contains(distantNearbyTrack)); }
Set<Track> findNearByTracks(Collection<Track> candidateTracks, Track nearToTrack, int maxTimestampDeviationMillis, int maxDistanceDeviationMeters) { Set<Track> nearbyTracks = Collections.EMPTY_SET; TrackingReport positionReport = nearToTrack.getNewestTrackingReport(); if (positionReport != null) { final long timestamp = positionReport.getTimestamp(); nearbyTracks = candidateTracks.parallelStream().filter(candidateTrack -> candidateTrack.getMmsi() != nearToTrack.getMmsi() && candidateTrack.getTimeOfLastPositionReport() > 0L && candidateTrack.getTimeOfLastPositionReport() > timestamp - maxTimestampDeviationMillis && candidateTrack.getTimeOfLastPositionReport() < timestamp + maxTimestampDeviationMillis && candidateTrack.getPosition().distanceTo(nearToTrack.getPosition(), CoordinateSystem.CARTESIAN) < maxDistanceDeviationMeters ).collect(toSet()); } return nearbyTracks; }
CloseEncounterAnalysis extends PeriodicAnalysis { Set<Track> findNearByTracks(Collection<Track> candidateTracks, Track nearToTrack, int maxTimestampDeviationMillis, int maxDistanceDeviationMeters) { Set<Track> nearbyTracks = Collections.EMPTY_SET; TrackingReport positionReport = nearToTrack.getNewestTrackingReport(); if (positionReport != null) { final long timestamp = positionReport.getTimestamp(); nearbyTracks = candidateTracks.parallelStream().filter(candidateTrack -> candidateTrack.getMmsi() != nearToTrack.getMmsi() && candidateTrack.getTimeOfLastPositionReport() > 0L && candidateTrack.getTimeOfLastPositionReport() > timestamp - maxTimestampDeviationMillis && candidateTrack.getTimeOfLastPositionReport() < timestamp + maxTimestampDeviationMillis && candidateTrack.getPosition().distanceTo(nearToTrack.getPosition(), CoordinateSystem.CARTESIAN) < maxDistanceDeviationMeters ).collect(toSet()); } return nearbyTracks; } }
CloseEncounterAnalysis extends PeriodicAnalysis { Set<Track> findNearByTracks(Collection<Track> candidateTracks, Track nearToTrack, int maxTimestampDeviationMillis, int maxDistanceDeviationMeters) { Set<Track> nearbyTracks = Collections.EMPTY_SET; TrackingReport positionReport = nearToTrack.getNewestTrackingReport(); if (positionReport != null) { final long timestamp = positionReport.getTimestamp(); nearbyTracks = candidateTracks.parallelStream().filter(candidateTrack -> candidateTrack.getMmsi() != nearToTrack.getMmsi() && candidateTrack.getTimeOfLastPositionReport() > 0L && candidateTrack.getTimeOfLastPositionReport() > timestamp - maxTimestampDeviationMillis && candidateTrack.getTimeOfLastPositionReport() < timestamp + maxTimestampDeviationMillis && candidateTrack.getPosition().distanceTo(nearToTrack.getPosition(), CoordinateSystem.CARTESIAN) < maxDistanceDeviationMeters ).collect(toSet()); } return nearbyTracks; } @Inject  CloseEncounterAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository, SafetyZoneService safetyZoneService); }
CloseEncounterAnalysis extends PeriodicAnalysis { Set<Track> findNearByTracks(Collection<Track> candidateTracks, Track nearToTrack, int maxTimestampDeviationMillis, int maxDistanceDeviationMeters) { Set<Track> nearbyTracks = Collections.EMPTY_SET; TrackingReport positionReport = nearToTrack.getNewestTrackingReport(); if (positionReport != null) { final long timestamp = positionReport.getTimestamp(); nearbyTracks = candidateTracks.parallelStream().filter(candidateTrack -> candidateTrack.getMmsi() != nearToTrack.getMmsi() && candidateTrack.getTimeOfLastPositionReport() > 0L && candidateTrack.getTimeOfLastPositionReport() > timestamp - maxTimestampDeviationMillis && candidateTrack.getTimeOfLastPositionReport() < timestamp + maxTimestampDeviationMillis && candidateTrack.getPosition().distanceTo(nearToTrack.getPosition(), CoordinateSystem.CARTESIAN) < maxDistanceDeviationMeters ).collect(toSet()); } return nearbyTracks; } @Inject  CloseEncounterAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository, SafetyZoneService safetyZoneService); @Override String toString(); }
CloseEncounterAnalysis extends PeriodicAnalysis { Set<Track> findNearByTracks(Collection<Track> candidateTracks, Track nearToTrack, int maxTimestampDeviationMillis, int maxDistanceDeviationMeters) { Set<Track> nearbyTracks = Collections.EMPTY_SET; TrackingReport positionReport = nearToTrack.getNewestTrackingReport(); if (positionReport != null) { final long timestamp = positionReport.getTimestamp(); nearbyTracks = candidateTracks.parallelStream().filter(candidateTrack -> candidateTrack.getMmsi() != nearToTrack.getMmsi() && candidateTrack.getTimeOfLastPositionReport() > 0L && candidateTrack.getTimeOfLastPositionReport() > timestamp - maxTimestampDeviationMillis && candidateTrack.getTimeOfLastPositionReport() < timestamp + maxTimestampDeviationMillis && candidateTrack.getPosition().distanceTo(nearToTrack.getPosition(), CoordinateSystem.CARTESIAN) < maxDistanceDeviationMeters ).collect(toSet()); } return nearbyTracks; } @Inject  CloseEncounterAnalysis(Configuration configuration, AppStatisticsService statisticsService, EventEmittingTracker trackingService, EventRepository eventRepository, SafetyZoneService safetyZoneService); @Override String toString();  }