use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.
the class VesselsInGbrMain method main.
public static void main(String[] args) throws IOException {
long t = System.currentTimeMillis();
File out = new File("target/mmsi.txt");
out.delete();
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out)))) {
Pattern pattern = Pattern.compile(".*\\.track");
List<File> list = new ArrayList<File>();
list.addAll(Files.find(new File("/media/an/binary-fixes-5-minute/2014"), pattern));
list.addAll(Files.find(new File("/media/an/binary-fixes-5-minute/2015"), pattern));
list.addAll(Files.find(new File("/media/an/binary-fixes-5-minute/2016"), pattern));
AtomicInteger count = new AtomicInteger();
//
Observable.from(list).groupBy(f -> count.getAndIncrement() % //
Runtime.getRuntime().availableProcessors()).flatMap(//
files -> vesselsInGbr(files, Schedulers.computation())).distinct(//
fix -> fix.mmsi() + fix.aisClass().name()).sorted(//
(a, b) -> Integer.compare(a.mmsi(), b.mmsi())).filter(//
fix -> MmsiValidator2.INSTANCE.isValid((long) fix.mmsi())).doOnNext(//
fix -> write(writer, fix)).toBlocking().subscribe();
}
System.out.println((System.currentTimeMillis() - t) + "ms");
}
use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.
the class DriftDetectorTest method testRule2TwoDriftersBigTimeGap.
@Test
public void testRule2TwoDriftersBigTimeGap() {
long t = 0;
// drifter
Fix f1 = createFix(90, DRIFT_SPEED_KNOTS, t);
// drifter
Fix f2 = createFix(91, DRIFT_SPEED_KNOTS, t += TimeUnit.DAYS.toMillis(1));
List<DriftCandidate> list = getCandidates(Observable.just(f1, f2));
assertTrue(list.isEmpty());
}
use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.
the class DriftDetectorTest method testTwoDriftersButDifferentMmsi.
@Test
public void testTwoDriftersButDifferentMmsi() {
long t = 0;
// drifter
Fix f1 = createFix(12344, 90, DRIFT_SPEED_KNOTS, t);
// drifter
Fix f2 = createFix(12345, 91, DRIFT_SPEED_KNOTS, t += 1);
List<DriftCandidate> list = getCandidates(Observable.just(f1, f2));
assertTrue(list.isEmpty());
}
use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.
the class DriftDetectorTest method createFix.
private static Fix createFix(int mmsi, float courseHeadingDiff, float speedKnots, long time) {
Fix f = Mockito.mock(Fix.class);
Mockito.when(f.courseOverGroundDegrees()).thenReturn(Optional.of(10.0f));
Mockito.when(f.headingDegrees()).thenReturn(Optional.of(10.0f + courseHeadingDiff));
Mockito.when(f.speedOverGroundKnots()).thenReturn(Optional.of(speedKnots));
Mockito.when(f.navigationalStatus()).thenReturn(Optional.<NavigationalStatus>empty());
Mockito.when(f.mmsi()).thenReturn(mmsi);
Mockito.when(f.fix()).thenReturn(f);
Mockito.when(f.time()).thenReturn(time);
return f;
}
use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.
the class DriftDetectorTest method testNotDriftedBecauseCogHeadingDiffTooLow.
@Test
public void testNotDriftedBecauseCogHeadingDiffTooLow() {
Fix fix = Mockito.mock(Fix.class);
Mockito.when(fix.courseOverGroundDegrees()).thenReturn(Optional.of(10.0f));
Mockito.when(fix.headingDegrees()).thenReturn(Optional.of(11.0f));
Mockito.when(fix.speedOverGroundKnots()).thenReturn(Optional.of(DRIFT_SPEED_KNOTS));
Mockito.when(fix.navigationalStatus()).thenReturn(Optional.<NavigationalStatus>empty());
assertFalse(DriftDetector.isCandidate(Options.instance()).call(fix));
}
Aggregations