Search in sources :

Example 1 with AisAidToNavigation

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);
}
Also used : AisPositionA(au.gov.amsa.ais.message.AisPositionA) AisAidToNavigation(au.gov.amsa.ais.message.AisAidToNavigation) AisPositionGPS(au.gov.amsa.ais.message.AisPositionGPS) AisBaseStation(au.gov.amsa.ais.message.AisBaseStation) AisPositionB(au.gov.amsa.ais.message.AisPositionB) AisShipStaticA(au.gov.amsa.ais.message.AisShipStaticA) AisPositionBExtended(au.gov.amsa.ais.message.AisPositionBExtended) AisMessageOther(au.gov.amsa.ais.message.AisMessageOther)

Example 2 with AisAidToNavigation

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());
}
Also used : AisAidToNavigation(au.gov.amsa.ais.message.AisAidToNavigation) Test(org.junit.Test)

Example 3 with AisAidToNavigation

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();
}
Also used : AisAidToNavigation(au.gov.amsa.ais.message.AisAidToNavigation) Test(org.junit.Test)

Aggregations

AisAidToNavigation (au.gov.amsa.ais.message.AisAidToNavigation)3 Test (org.junit.Test)2 AisBaseStation (au.gov.amsa.ais.message.AisBaseStation)1 AisMessageOther (au.gov.amsa.ais.message.AisMessageOther)1 AisPositionA (au.gov.amsa.ais.message.AisPositionA)1 AisPositionB (au.gov.amsa.ais.message.AisPositionB)1 AisPositionBExtended (au.gov.amsa.ais.message.AisPositionBExtended)1 AisPositionGPS (au.gov.amsa.ais.message.AisPositionGPS)1 AisShipStaticA (au.gov.amsa.ais.message.AisShipStaticA)1