npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ais-decoder-ts

v3.1.0

Published

Ais Decoder (TypeScript, Node 12.17.0)

Downloads

67

Readme

AIS Decoder

The automatic identification system (AIS) is an automatic Tracking system used on ships and by vessel traffic services (VTS). When satellites are used to detect AIS signatures, the term Satellite-AIS (S-AIS) is used. AIS information supplements marine radar, which continues to be the primary method of collision avoidance for water transport.

Build Status

Ideal Node Version : 8.16.2

Tests : run npm test

AIS MESSAGES

  1. Position[0] format: !AIVDM, identifies this as an AIVDM packet (AIS format).
  2. Position[1] message_count: Messages counter (number of messages), sometimes the ais messages will be split over several messages.
  3. Position[2] message_id:
  4. Position[3] sequence_id: Sequential message, the current message number
  5. Position[4] channel: vhf channel A/B
  6. Position[5] payload: the ais data itself
  7. Position[6] size: number of bits required to fill the data

<format>,<message count>,<message id>,<sequence id>,<channel A/B>,<data>,<fill bits>

Important notes:

  • Ais payload is represented in a 6bits encoded string

API

  • constructor(AIS_Messages, safeMode)
    • AIS_Messages: Array of ais messages.
    • safeMode: set to false by default. when true the module will never throw an error (silent mode).
  • getResults() - return a collection of the parse messages
  • private decode(input: Array<any>, session: any): void - decode the raw ais messages
  • private validateRawMessage(input: string): boolean - validate if the raw messages

Command Line:

  • node dist/bin/parse <ais message> for example: node ./dist/bin/parse "!AIVDM,1,1,,A,13u?etPv2;0n:dDPwUM1U1Cb069D,0*24"

Running example:

  • npm run example

Example:

// new Decoder(Array<AIS_Messages>, safeMode<Boolean>)
import { Decoder } from '../lib/index';
const aisMessages:Array<string> = [
  '!AIVDM,1,1,,A,400TcdiuiT7VDR>3nIfr6>i00000,0*78',
  '!AIVDM,2,1,0,A,58wt8Ui`g??r21`7S=:22058<v05Htp000000015>8OA;0sk,0*7B',
  '!AIVDM,2,2,0,A,eQ8823mDm3kP00000000000,2*5D',
  '!AIVDM,2,1,0,A,58wt8Ui`g??r21`7S=:22058<v05Htp000000015>8OA;0sk,0*7B ',
  '!AIVDM,2,2,0,A,eQ8823mDm3kP00000000000,2*5D',
];
const safeMode = false;
const aisDecoder_ex2 = new Decoder(aisMessages, safeMode);

// results will hold a collection of the parsed ais messages
const results = aisDecoder_ex2.getResults();

References:

  • Gov:
    • https://www.navcen.uscg.gov/?pageName=AISMessagesA
  • Gpsd:
    • https://gpsd.gitlab.io/gpsd/AIVDM.html [recommended]
  • OpenCPN:
    • https://github.com/OpenCPN/OpenCPN [file: AIS_Bitstring.cpp]
      • http://fossies.org/linux/misc/gpsd-3.11.tar.gz/gpsd-3.11/test/sample.aivdm
  • online AIS decoder:
    • http://www.maritec.co.za/tools/aisvdmvdodecoding/
    • http://www.maritec.co.za/aisvdmvdodecoding1.php
  • Wikipedia:
    • https://en.wikipedia.org/wiki/Automatic_identification_system
  • OpenCPN
    • Github: https://github.com/OpenCPN/OpenCPN/blob/45504f35c005ed1ffcd117c67797279da42d53ae/src/AIS_Decoder.cpp

Bugs & PR's

  • If you find any bug please feel free to open an issue. PR are always welcome.