NOTE : Currently on for Message Type 18 is working

Encoding AIS JSON to NMEA Format

In maritime communication, the Automatic Identification System (AIS) is a widely used system to track and identify vessels. AIS messages are typically transmitted in binary format but can be converted into a more human-readable format known as NMEA (National Marine Electronics Association) messages. In this guide, we'll explore how to encode AIS data from JSON format into NMEA format using TypeScript.

Introduction to AIS Encoding

AIS messages contain various information about vessels, such as their position, speed, course, and identity. These messages are structured according to different message types, such as message types 1 to 3 for position reports, message type 18 for Class B position reports, and message type 24 for static reports.

Functions Overview

Usage Example

Here's how you can use these functions to encode AIS JSON data into NMEA format:

import { aisPositionEncoder, aisClassBPositionEncoder, encodeJsonToNmea } from './aisEncoder';

const jsonData = {
    messageType: 18,
    // Other AIS message fields...
};

// NOTE : CURRENTLY ONLY MESSAGE TYPE 18 WORKS
const nmeaMessage = encodeJsonToNmea(jsonData);
console.log(nmeaMessage);

Encoding Logic