NAisParser 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NAisParser --version 0.1.1                
NuGet\Install-Package NAisParser -Version 0.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NAisParser" Version="0.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NAisParser --version 0.1.1                
#r "nuget: NAisParser, 0.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NAisParser as a Cake Addin
#addin nuget:?package=NAisParser&version=0.1.1

// Install NAisParser as a Cake Tool
#tool nuget:?package=NAisParser&version=0.1.1                

NAisParser is an AIVDM/AIVDO Parser for .NET

coverage

NaisParser is an NMEA marine Automatic Identification System (AIS) AIVDM/AIVDO decoder for .NET Standard. Written in F# using FParsec. The main advantage of using a parser combinator library such as FParsec, and using an applicative (functor) style is that the implementation looks very similar to the specification, thus the code is clean, and easy to extend and validate against the specification.

Currently parses:

  • Types 1, 2 and 3: Position Report Class A
  • Type 5: Static and Voyage Related Data

The parser works in two stages. In the first stage you parse the outer layer of the AIS data packet:

var line = "!BSVDM,1,1,,A,13mAwp001m0MMrjSoomG6mWT0<1h,0*16";
var result = parser.TryParse(line, out AisResult aisResult); // Returns true

If result is true then you have a valid AisResult. If false then the packet if fragmented and you need to supply more data by calling TryParse again with another line of data, e.g.

var line1 = "!BSVDM,2,1,2,A,53mDDD02>EjthmLJ220HtppE>2222222222222164@G:34rdR?QSkSQDp888,0*15";
var line2 = "!BSVDM,2,2,2,A,88888888880,2*3F";

var result1 = parser.TryParse(line1, out AisResult aisResult); // Returns false
var result2 = parser.TryParse(line2, out AisResult aisResult); // Returns true

If an error occurs while parsing TryParse will raise an ArgumentException.

In the second stage you parse the AIS payload data depending on the type of message. The type of message is available in a valid AisResult from stage 1. To parse a message of type 1 you call TryParse with an out parameter of type MessageType123. To parse a message of type 5 you call TryParse with an out parameter of type MessageType5.

var result = parser.TryParse(aisResult, out MessageType123 type123Result);

Se below for a full example. Enjoy!

Install

dotnet add package NAisParser

C# Example

var parser = new Parser();

using (StreamReader reader = new StreamReader(stream))
{
    string line;
    while ((line = reader.ReadLine()) != null) {
        var result = parser.TryParse(line, out AisResult aisResult);
        if (!result) continue;

        switch (aisResult.Type)
        {
            case 1:
            case 2:
            case 3:
                result = parser.TryParse(aisResult, out MessageType123 type123Result);
                Console.WriteLine(type123Result.ToString());
                break;
            case 5:
                result = parser.TryParse(aisResult, out MessageType5 type5Result);
                Console.WriteLine(type5Result.ToString());
                break;
            default:
                break;
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.6 is compatible.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.0 2,587 10/10/2018
0.2.0 1,000 5/13/2018
0.1.2 914 5/8/2018
0.1.1 939 5/6/2018