use of au.gov.amsa.risky.format.NavigationalStatus 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);
}
Aggregations