use of au.gov.amsa.ais.message.AisAidToNavigation in project risky by amsa-code.
the class AisMessageParser method parse.
/**
* Returns an {@link AisMessage} from the string representation of the
* message as per 1371-4 IMO specification (as per the appropriate column in
* the NMEA message).
*
* @param message
* @param source
* @return
*/
public AisMessage parse(String message, String source, int padBits) {
AisExtractor extractor = factory.create(message, 0, padBits);
int id = extractor.getMessageId();
if (Util.isClassAPositionReport(id)) {
return new AisPositionA(message, source, padBits);
} else if (id == 4)
return new AisBaseStation(message, source, padBits);
else if (id == 5)
return new AisShipStaticA(message, source, padBits);
else if (id == 18)
return new AisPositionB(message, source, padBits);
else if (id == 19)
return new AisPositionBExtended(message, source, padBits);
else if (id == 21)
return new AisAidToNavigation(message, source, padBits);
else if (id == AisMessageType.STATIC_DATA_REPORT.getId()) {
int partNumber = AbstractAisBStaticDataReport.extractPartNumber(factory, message, padBits);
return parseStaticDataReport(partNumber, id, message, source, padBits);
} else if (id == 27)
return new AisPositionGPS(message, source, padBits);
else
return new AisMessageOther(id, source, padBits);
}
use of au.gov.amsa.ais.message.AisAidToNavigation in project risky by amsa-code.
the class AisMessageParserTest method testParseAtonMessage.
@Test
public void testParseAtonMessage() {
AisMessageParser p = new AisMessageParser();
AisMessage m = p.parse("E>lsp0;`bRb:0h97QUP00000000E6LE2ttVw020@@@P020", 0);
assertTrue(m instanceof AisAidToNavigation);
AisAidToNavigation a = (AisAidToNavigation) m;
// System.out.println(a);
assertEquals(21, a.getMessageId());
assertEquals(0, a.getRepeatIndicator());
assertEquals(995031040, a.getMmsi());
assertEquals(23, a.getAtoNType());
assertEquals("QUETTA ROCK", a.getName());
assertEquals("", a.getAtonStatus());
assertTrue(a.isHighAccuracyPosition());
}
use of au.gov.amsa.ais.message.AisAidToNavigation in project risky by amsa-code.
the class AisNmeaMessageTest method testParseCorruptAisAidToNavigationThrows.
@Test(expected = AisParseException.class)
public void testParseCorruptAisAidToNavigationThrows() {
String line = "\\s:Kordia Terrestrial,c:1517229997,seq:11725574*18\\!AIVDM,2,1,8,B,E>m1cBFch80W4PP000000000000FDvc;lecp@00003j,0*11";
AisNmeaMessage m = AisNmeaMessage.from(line);
AisAidToNavigation aid = (AisAidToNavigation) m.getMessage();
aid.getTimeSecondsOnly();
}
Aggregations