Search in sources :

Example 1 with SegmentOptions

use of au.gov.amsa.geo.model.SegmentOptions in project risky by amsa-code.

the class EffectiveSpeedCheckFailures2Main method main.

public static void main(String[] args) throws ParseException {
    SegmentOptions options = SegmentOptions.builder().acceptAnyFixHours(12L).maxSpeedKnots(50).build();
    tasmania().groupBy(fix -> fix.mmsi()).flatMap(g -> g.lift(new OperatorEffectiveSpeedChecker(options)).buffer(2, 1).filter(list -> list.size() == 2 && list.get(0).isOk() && !list.get(1).isOk()).doOnNext(list -> {
        System.out.println(" ok," + list.get(0));
        System.out.println("bad," + list.get(1));
    })).count().toBlocking().single();
}
Also used : Arrays(java.util.Arrays) BinaryFixes(au.gov.amsa.risky.format.BinaryFixes) Func2(rx.functions.Func2) SegmentOptions(au.gov.amsa.geo.model.SegmentOptions) OperatorEffectiveSpeedChecker(au.gov.amsa.geo.distance.OperatorEffectiveSpeedChecker) Fix(au.gov.amsa.risky.format.Fix) ParseException(java.text.ParseException) File(java.io.File) Observable(rx.Observable) SegmentOptions(au.gov.amsa.geo.model.SegmentOptions) OperatorEffectiveSpeedChecker(au.gov.amsa.geo.distance.OperatorEffectiveSpeedChecker)

Example 2 with SegmentOptions

use of au.gov.amsa.geo.model.SegmentOptions in project risky by amsa-code.

the class OperatorEffectiveSpeedCheckerTest method testSpiritOfTasmania.

@Test
public void testSpiritOfTasmania() throws ParseException {
    SegmentOptions options = SegmentOptions.builder().acceptAnyFixHours(12L).maxSpeedKnots(50).build();
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    df.setTimeZone(TimeZone.getTimeZone("UTC"));
    Fix a = new FixImpl(1, -39.572643f, 145.38763f, df.parse("2015-01-01T03:36:36").getTime(), AisClass.A);
    Fix b = new FixImpl(1, -40.095074f, 145.71864f, df.parse("2015-01-01T04:52:25").getTime(), AisClass.A);
    System.out.println(Position.create(a.lat(), a.lon()).getDistanceToKm(Position.create(b.lat(), b.lon())) / 1.852 / (75.81666666 / 60) + "knots");
    assertEquals(27.605441702145423, EffectiveSpeedChecker.effectiveSpeedKnots(a, b, options).get(), 0.00001);
}
Also used : Fix(au.gov.amsa.risky.format.Fix) SegmentOptions(au.gov.amsa.geo.model.SegmentOptions) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) FixImpl(au.gov.amsa.risky.format.FixImpl) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Aggregations

SegmentOptions (au.gov.amsa.geo.model.SegmentOptions)2 Fix (au.gov.amsa.risky.format.Fix)2 OperatorEffectiveSpeedChecker (au.gov.amsa.geo.distance.OperatorEffectiveSpeedChecker)1 BinaryFixes (au.gov.amsa.risky.format.BinaryFixes)1 FixImpl (au.gov.amsa.risky.format.FixImpl)1 File (java.io.File)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Arrays (java.util.Arrays)1 Test (org.junit.Test)1 Observable (rx.Observable)1 Func2 (rx.functions.Func2)1