use of au.gov.amsa.risky.format.FixImpl in project risky by amsa-code.
the class ParquetTest method testWriteOneFixToFile.
@Test
public void testWriteOneFixToFile() throws IOException {
FixImpl f = new FixImpl(213456789, -10f, 135f, 1526002907873L, of(12), of((short) 1), of(NavigationalStatus.ENGAGED_IN_FISHING), of(7.5f), of(45f), of(46f), AisClass.B);
File output = new File("target/test.parquet");
output.delete();
Iterable<Record> iterable = () -> Iterators.limit(Iterators.cycle(Parquet.toRecord(f)), 1000);
Parquet.writeTo(iterable, new Path(output.getPath()));
System.out.println(output.length());
}
use of au.gov.amsa.risky.format.FixImpl in project risky by amsa-code.
the class VesselPositionsTest method testFixSpeedComesThroughCorrectly.
@Test
public void testFixSpeedComesThroughCorrectly() {
FixImpl fix = new FixImpl(213456789, -10f, 135f, 12000, of(12), of((short) 1), of(NavigationalStatus.ENGAGED_IN_FISHING), of(7.5f), of(45f), of(46f), AisClass.B);
assertEquals(7.5 * 1852.0 / 3600, VesselPositions.TO_VESSEL_POSITION.call(fix).speedMetresPerSecond().get(), PRECISION);
}
use of au.gov.amsa.risky.format.FixImpl in project risky by amsa-code.
the class DriftCandidates method toDriftCandidate.
private static DriftCandidate toDriftCandidate(String line) {
String[] items = line.split(",");
int i = 0;
int mmsi = Integer.parseInt(items[i++]);
float lat = Float.parseFloat(items[i++]);
float lon = Float.parseFloat(items[i++]);
long time = Long.parseLong(items[i++]);
String cls = items[i++];
float course = Float.parseFloat(items[i++]);
float heading = Float.parseFloat(items[i++]);
float speedKnots = Float.parseFloat(items[i++]);
String status = items[i++];
long driftingSince = Long.parseLong(items[i++]);
final Optional<NavigationalStatus> navigationalStatus;
if (status.trim().length() == 0)
navigationalStatus = Optional.empty();
else
navigationalStatus = Optional.of(NavigationalStatus.valueOf(status));
final AisClass aisClass;
if (cls.trim().length() == 0)
throw new RuntimeException("cls should not be empty");
else if (AisClass.A.name().equals(cls))
aisClass = AisClass.A;
else
aisClass = AisClass.B;
FixImpl fix = new FixImpl(mmsi, lat, lon, time, Optional.<Integer>empty(), Optional.<Short>empty(), navigationalStatus, Optional.of(speedKnots), Optional.of(course), Optional.of(heading), aisClass);
return new DriftCandidate(fix, driftingSince);
}
use of au.gov.amsa.risky.format.FixImpl 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);
}
Aggregations