simulator/lib/GG-NmeaAisEncoder.js
function NmeaAisEncoder (data) {
    var msg;

    // Use NMEA GRPMC or AIVDM depending on Vessel MMSI
    if (data.mmsi === 0) {
        // this ship has no MMSI let's use GPRMC format
        switch (data.cmd) {
            case 1:
                msg = { // built a Fake NMEA authentication message
                    valid: true,
                    nmea: "FAKID" + data.mmsi +',' + data.shipname
                };
                break;
            case 2:
                msg = new GGencode.NmeaEncode(data);
                break;
            default:
                msg = null;
        }
    } else {
        // we are facing multiple boats use AIS ADVDM
        switch (data.cmd) {
            case 1:
                if (data.class === 'A') data.aistype = 5; else data.aistype = 24;
                msg = new GGencode.AisEncode(data);
                break;
            case 2:
                if (data.class === 'A') data.aistype = 3; else data.aistype = 18;
                msg = new GGencode.AisEncode(data);
                break;
            default:
                msg = null;
        }
    }
    if (msg.valid) return (msg.nmea);
    else return (null);
}
function NmeaAisEncoder (data) {
    var msg;

    // Use NMEA GRPMC or AIVDM depending on Vessel MMSI
    if (data.mmsi === 0) {
        // this ship has no MMSI let's use GPRMC format
        switch (data.cmd) {
            case 1:
                msg = { // built a Fake NMEA authentication message
                    valid: true,
                    nmea: "FAKID" + data.mmsi +',' + data.shipname
                };
                break;
            case 2:
                msg = new GGencode.NmeaEncode(data);
                break;
            default:
                msg = null;
        }
    } else {
        // we are facing multiple boats use AIS ADVDM
        switch (data.cmd) {
            case 1:
                if (data.class === 'A') data.aistype = 5; else data.aistype = 24;
                msg = new GGencode.AisEncode(data);
                break;
            case 2:
                if (data.class === 'A') data.aistype = 3; else data.aistype = 18;
                msg = new GGencode.AisEncode(data);
                break;
            default:
                msg = null;
        }
    }
    if (msg.valid) return (msg.nmea);
    else return (null);
}
function NmeaAisEncoder ( data ) { var msg ; // Use NMEA GRPMC or AIVDM depending on Vessel MMSI if ( data . mmsi === 0 ) { // this ship has no MMSI let's use GPRMC format switch ( data . cmd ) { case 1 : msg = { // built a Fake NMEA authentication message valid : true , nmea : "FAKID" + data . mmsi + ',' + data . shipname } ; break ; case 2 : msg = new GGencode . NmeaEncode ( data ) ; break ; default : msg = null ; } } else { // we are facing multiple boats use AIS ADVDM switch ( data . cmd ) { case 1 : if ( data . class === 'A' ) data . aistype = 5 ; else data . aistype = 24 ; msg = new GGencode . AisEncode ( data ) ; break ; case 2 : if ( data . class === 'A' ) data . aistype = 3 ; else data . aistype = 18 ; msg = new GGencode . AisEncode ( data ) ; break ; default : msg = null ; } } if ( msg . valid ) return ( msg . nmea ) ; else return ( null ) ; }
Encode AIS AIVDM or GPRMC depending on position MMSI
Encode AIS AIVDM or GPRMC depending on position MMSI