Search in sources :

Example 16 with Fix

use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.

the class DriftDetectorTest method testRule3FourDriftersBigTimeGapBetweenTwoAndThree.

@Test
public void testRule3FourDriftersBigTimeGapBetweenTwoAndThree() {
    long t = 0;
    // drifter
    Fix f1 = createFix(90, DRIFT_SPEED_KNOTS, t);
    // drifter
    Fix f2 = createFix(91, DRIFT_SPEED_KNOTS, t += 1);
    // drifter
    Fix f3 = createFix(92, DRIFT_SPEED_KNOTS, t += testOptions.expiryAgeMs() + 1);
    // drifter
    Fix f4 = createFix(93, DRIFT_SPEED_KNOTS, t += 1);
    List<DriftCandidate> list = getCandidates(Observable.just(f1, f2, f3, f4));
    assertEquals(4, list.size());
    assertTrue(f1 == list.get(0).fix());
    assertTrue(f2 == list.get(1).fix());
    assertTrue(f3 == list.get(2).fix());
    assertTrue(f4 == list.get(3).fix());
    assertEquals(f1.time(), list.get(0).driftingSince());
    assertEquals(f1.time(), list.get(1).driftingSince());
    assertEquals(f3.time(), list.get(2).driftingSince());
    assertEquals(f3.time(), list.get(3).driftingSince());
}
Also used : Fix(au.gov.amsa.risky.format.Fix) Test(org.junit.Test)

Example 17 with Fix

use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.

the class DriftDetectorTest method testDriftedFalseIfNoCog.

@Test
public void testDriftedFalseIfNoCog() {
    Fix fix = Mockito.mock(Fix.class);
    Mockito.when(fix.courseOverGroundDegrees()).thenReturn(Optional.<Float>empty());
    Mockito.when(fix.headingDegrees()).thenReturn(Optional.of(110.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));
}
Also used : Fix(au.gov.amsa.risky.format.Fix) Test(org.junit.Test)

Example 18 with Fix

use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.

the class DriftDetectorTest method testRule5TwoDriftersThenTwoNonDrifters.

@Test
public void testRule5TwoDriftersThenTwoNonDrifters() {
    long t = 0;
    // drifter
    Fix f1 = createFix(90, DRIFT_SPEED_KNOTS, t);
    // drifter
    Fix f2 = createFix(91, DRIFT_SPEED_KNOTS, t += 1);
    // non-drifter
    Fix f3 = createFix(1, DRIFT_SPEED_KNOTS, t += 1);
    // non-drifter
    Fix f4 = createFix(2, DRIFT_SPEED_KNOTS, t += 1);
    List<DriftCandidate> list = getCandidates(Observable.just(f1, f2, f3, f4));
    assertEquals(2, list.size());
    assertTrue(f1 == list.get(0).fix());
    assertTrue(f2 == list.get(1).fix());
    assertEquals(f1.time(), list.get(0).driftingSince());
    assertEquals(f1.time(), list.get(1).driftingSince());
}
Also used : Fix(au.gov.amsa.risky.format.Fix) Test(org.junit.Test)

Example 19 with Fix

use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.

the class DriftDetectorTest method testRule6DrifterNonDrifterDrifter.

@Test
public void testRule6DrifterNonDrifterDrifter() {
    long t = 0;
    // drifter
    Fix f1 = createFix(90, DRIFT_SPEED_KNOTS, t);
    // non-drifter
    Fix f2 = createFix(1, DRIFT_SPEED_KNOTS, t += 1);
    // drifter
    Fix f3 = createFix(91, DRIFT_SPEED_KNOTS, t += 1);
    List<DriftCandidate> list = getCandidates(Observable.just(f1, f2, f3));
    assertEquals(2, list.size());
    assertTrue(f1 == list.get(0).fix());
    assertTrue(f3 == list.get(1).fix());
    assertEquals(f1.time(), list.get(0).driftingSince());
    assertEquals(f1.time(), list.get(1).driftingSince());
}
Also used : Fix(au.gov.amsa.risky.format.Fix) Test(org.junit.Test)

Example 20 with Fix

use of au.gov.amsa.risky.format.Fix in project risky by amsa-code.

the class DriftDetectorTest method testRule3ThreeDrifters.

@Test
public void testRule3ThreeDrifters() {
    long t = 0;
    // drifter
    Fix f1 = createFix(90, DRIFT_SPEED_KNOTS, t);
    // drifter
    Fix f2 = createFix(91, DRIFT_SPEED_KNOTS, t += 1);
    // drifter
    Fix f3 = createFix(92, DRIFT_SPEED_KNOTS, t += 1);
    List<DriftCandidate> list = getCandidates(Observable.just(f1, f2, f3));
    assertEquals(3, list.size());
    assertTrue(f1 == list.get(0).fix());
    assertTrue(f2 == list.get(1).fix());
    assertTrue(f3 == list.get(2).fix());
    assertEquals(f1.time(), list.get(0).driftingSince());
    assertEquals(f1.time(), list.get(1).driftingSince());
    assertEquals(f1.time(), list.get(2).driftingSince());
}
Also used : Fix(au.gov.amsa.risky.format.Fix) Test(org.junit.Test)

Aggregations

Fix (au.gov.amsa.risky.format.Fix)48 Test (org.junit.Test)27 File (java.io.File)18 BinaryFixes (au.gov.amsa.risky.format.BinaryFixes)12 Observable (rx.Observable)12 IOException (java.io.IOException)11 List (java.util.List)10 FileOutputStream (java.io.FileOutputStream)9 Pattern (java.util.regex.Pattern)7 Schedulers (rx.schedulers.Schedulers)7 SegmentOptions (au.gov.amsa.geo.model.SegmentOptions)6 Shapefile (au.gov.amsa.gt.Shapefile)6 BinaryFixesFormat (au.gov.amsa.risky.format.BinaryFixesFormat)6 Files (au.gov.amsa.util.Files)6 InputStream (java.io.InputStream)6 TimeUnit (java.util.concurrent.TimeUnit)6 MmsiValidator2 (au.gov.amsa.util.identity.MmsiValidator2)5 BufferedOutputStream (java.io.BufferedOutputStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 OutputStream (java.io.OutputStream)5