Giter Club home page Giter Club logo

csharp-taf-decoder's Introduction

C# TAF decoder

Build status Coverage Status Latest Stable Version NuGet

A .NET library to decode TAF (Terminal Aerodrome Forecast) strings, fully unit tested (100% code coverage)

This is largely based on SafranCassiopee/php-taf-decoder

They use csharp-taf-decoder in production:

  • Safran AGS (private)
  • Your service here ? Submit a pull request or open an issue !

Introduction

This piece of software is a library package that provides a parser to decode raw TAF messages.

TAF is a format made for weather information forecast. It is predominantly used by in aviation, during flight preparation. Raw TAF format is highly standardized through the International Civil Aviation Organization (ICAO).

Requirements

This library package only requires .NET >= 4.5

It is currently tested automatically for .NET >= 4.5 using nUnit 3.9.0.

Although this is provided as a library project, a command line version (StartTafDecoder) is also included that can be used as both an example and a starting point. StartTafDecoder requires CommandLineParser.

Usage:

StartTafDecoder.exe --TAF "TAF LEMD 080500Z 0806/0912 23010KT 9999 SCT025 TX12/0816Z TN04/0807Z"

If you want to integrate the library easily in your project, you should consider using the official nuget package available from https://www.nuget.org/.

nuget install csharp-taf-decoder

It is not mandatory though.

Setup

  • With nuget.exe (recommended)

From the Package Manager Console in Visual Studio

nuget install csharp-taf-decoder

Add a reference to the library, then add the following using directives:

using csharp_taf_decoder;
using csharp_taf_decoder.entity;
  • By hand

Download the latest release from github

Extract it wherever you want in your project. The library itself is in the csharp-taf-decoder/ directory, the other directories are not mandatory for the library to work.

Add the csharp-taf-decoder project to your solution, then add a reference to it in your own project. Finally, add the same using directives than above.

Usage

Instantiate the decoder and launch it on a TAF string. The returned object is a DecodedTAF object from which you can retrieve all the weather properties that have been decoded.

All values who have a unit are based on the Value object which provides the ActualValue and ActualUnit properties

Please check the DecodedTAF class for the structure of the resulting object

  var d = TAFDecoder.ParseWithMode("TAF LEMD 080500Z 0806/0912 23010KT 9999 SCT025 TX12/0816Z TN04/0807Z");

 (TODO)
 

About Value objects

In the example above, it is assumed that all requested parameters are available. In the real world, some fields are not mandatory thus it is important to check that the Value object (containing both the value and its unit) is not null before using it. What you do in case it's null is totally up to you.

Here is an example:

(TODO)

Value objects also contain their unit, that you can access with the ActualUnit property. When you access the ActualValue property, you'll get the value in this unit.

If you want to get the value directly in another unit you can call GetConvertedValue(unit). Supported values are speed, distance and pressure.

Here are all available units for conversion:

// speed units:
// Value.Unit.MeterPerSecond
// Value.Unit.KilometerPerHour
// Value.Unit.Knot

// distance units:
// Value.Unit.Meter
// Value.Unit.Feet
// Value.Unit.StatuteMile

// pressure units:
// Value.Unit.HectoPascal
// Value.Unit.MercuryInch

// use on-the-fly conversion
var distance_in_sm = visibility.GetConvertedValue(Value.Unit.StatuteMile);
var speed_kph = speed.GetConvertedValue(Value.Unit.KilometerPerHour);

About parsing errors

When an unexpected format is encountered for a part of the TAF, the parsing error is logged into the DecodedTaf object itself.

All parsing errors for one TAF can be accessed through the DecodingExceptions property.

By default parsing will continue when a bad format is encountered. But the parser also provides a "strict" mode where parsing stops as soon as an error occurs. The mode can be set globally for a TafDecoder object, or just once as you can see in this example:

var decoder = new TAFDecoder();

(TODO)

About parsing errors, again

(TODO)

Contribute

If you find a valid TAF that is badly parsed by this library, please open a github issue with all possible details:

  • the full TAF causing problem
  • the parsing exception returned by the library
  • how you expected the decoder to behave
  • anything to support your proposal (links to official websites appreciated)

If you want to improve or enrich the test suite, fork the repository and submit your changes with a pull request.

If you have any other idea to improve the library, please use github issues or directly pull requests depending on what you're more comfortable with.

In order to contribute to the codebase, you must fork the repository on github, than clone it locally with:

git clone https://github.com/<username>/csharp-taf-decoder

Install all the dependencies using nuget :

nuget restore csharp-taf-decoder\

You're ready to launch the test suite with:

nunit-console.exe /xml:results.xml csharp-taf-decoder-tests\bin\debug\csharp-taf-decoder-tests.dll

This library is fully unit tested, and uses nUnit to launch the tests.

Travis CI is used for continuous integration, which triggers tests for .NET 4.5 for each push to the repo.

csharp-taf-decoder's People

Contributors

jpjoux avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

csharp-taf-decoder's Issues

Decoding issue

Hi,

The following code does not seem to be decoded correctly. It seems to have a problem with the combination of Tempo and Prob.

TAF ESSA 110530Z 1106/1206 04005KT CAVOK TEMPO 1113/1120 SHRA BKN045CB PROB40 1106/1109 SHRA SCT040CB

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.