Skip to content

Commit

Permalink
Merge pull request #206 from mivek/major/Airport-Spi
Browse files Browse the repository at this point in the history
Major/airport spi
  • Loading branch information
mivek authored May 27, 2020
2 parents 705e23a + f091c49 commit bc43315
Show file tree
Hide file tree
Showing 207 changed files with 8,199 additions and 7,839 deletions.
17 changes: 17 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ before_deploy:

deploy:
provider: releases
file: target/metarParser-${VERSION}.jar
file_glob: true
file: /**/target/*.jar
api_key: $GITHUB_OATH
skip_cleanup: true
draft: true
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

**Have you found a bug**

Open an issue describing the bug and the steps to reproduce it.
Open an issue describing the bug, and the steps to reproduce it.
If you are willing to fix the bug:

* Open a Github Pull request
Expand All @@ -21,14 +21,14 @@ The keywords feature, bugfix and clean are mandatory for branch name.

* Do bot update the pom.xml, it will be updated accordingly to the branch name

* Add new code and the tests
* Add new code and tests

* Push code and create the pull request towards the master branch

**Internationalization**

This project currently supports English and French languages.
If you are willing to add a new language, please use https://poeditor.com/join/project/kWbkKRuHlr to register and contribute.
Once a language is completed at 100%, the file will be added to the project.
Once a language is complete at 100%, the file will be added to the project.

Thank you
196 changes: 122 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![Build Status](https://travis-ci.org/mivek/MetarParser.svg?branch=master)](https://travis-ci.org/mivek/MetarParser)
[![Build Status](https://travis-ci.com/mivek/MetarParser.svg?branch=master)](https://travis-ci.org/mivek/MetarParser)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=io.github.mivek%3AmetarParser&metric=alert_status)](https://sonarcloud.io/dashboard?id=io.github.mivek%3AmetarParser)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=io.github.mivek%3AmetarParser&metric=coverage)](https://sonarcloud.io/dashboard?id=io.github.mivek%3AmetarParser)
[![GitHub license](https://img.shields.io/github/license/mivek/MetarParser.svg)](https://github.com/mivek/MetarParser/blob/master/LICENSE)
![Maven Central](https://img.shields.io/maven-central/v/io.github.mivek/metarParser.svg)
[![Maven Central](https://img.shields.io/maven-central/v/io.github.mivek/metarParser.svg)](https://search.maven.org/artifact/io.github.mivek/metarParser/)

![](jetbrains_small.png)
# MetarParser

# MetarParser

This java lib provides a Metar and TAF decoder.

Expand All @@ -15,135 +15,177 @@ Use the MetarFacade class and its method retrieveFromAirport to get the metar of
The trends of the metar are not parsed.

## Table of content
1. [Adding dependency](https://github.com/mivek/MetarParser#adding-the-dependency)
2. [Model](https://github.com/mivek/MetarParser#model)
1. [Enumerations](https://github.com/mivek/MetarParser#enumerations)
2. [Classes](https://github.com/mivek/MetarParser#classes)
3. [Examples](https://github.com/mivek/MetarParser#examples)
1. [Parse a metar](https://github.com/mivek/MetarParser#parse-a-metar)
2. [Retrieve a metar](https://github.com/mivek/MetarParser#retrieve-the-metar-of-an-airport)
3. [Parse a taf](https://github.com/mivek/MetarParser#parse-a-taf)
4. [Retrieve a taf](https://github.com/mivek/MetarParser#retrieve-a-taf)
4. [Internationalization](https://github.com/mivek/MetarParser#internationalization)

1. [Adding dependency](#adding-the-dependency)
2. [Model](#model)
1. [Enumerations](#enumerations)
2. [Classes](#classes)
3. [Examples](#examples)
1. [Parse a metar](#parse-a-metar)
2. [Retrieve a metar](#retrieve-the-metar-of-an-airport)
3. [Parse a taf](#parse-a-taf)
4. [Retrieve a taf](#retrieve-a-taf)
4. [Internationalization](#internationalization)

## Architecture of the project

This project is divided into multiple maven module

- metarParser-entities: Contains the model and the enumerations
- metarParser-parsers: Contains the parsers and the commands
- metarParser-services: Contains a service allowing you to parse or retrieve METAR and TAF
- metarParser-spi: Contains the SPI
- metarParser-commons: Contains utility and internationalization classes

## Adding the dependency

To add the service module :

```xml
<dependency>
<groupId>io.github.mivek</groupId>
<artifactId>metarParser</artifactId>
<artifactId>metarParser-services</artifactId>
<version>latest</version>
</dependency>
```

Or check [here](https://search.maven.org/artifact/io.github.mivek/metarParser/) if you are not using maven.

## Model
The model is generated by using the Eclipse visualization tool [ObjectAid](http://www.objectaid.com/home).
When updating classes in packages io.github.mivek.enums or io.github.mivek.model, the class diagram is also updated.
When added a new class/enumeration in one of those package, drag and drop the new class to model.ucls and generate a new jpeg of the class diagram.

The class diagrams are generated by IntelliJ
When updating classes, regenerate the diagrams and save the images in the project.
![class diagram](model.jpg)

### Enumerations

The application contains numerous enumerations to represent data.
- CloudType: to represent the type of cloud.
- CloudQuantity: to represent the amount of clouds.
- Intensity: to represent the intensity of a meteorological phenomenon.
- Descriptive: to represent the descriptive of a meteorological phenomenon.
- Phenomenon: to represent a phenomenon.
- WeatherChangeTime: to represent a trend.
- TimeIndicator: to represent the time of the trend.


- CloudType: to represent the type of cloud.
- CloudQuantity: to represent the amount of clouds.
- Intensity: to represent the intensity of a meteorological phenomenon.
- Descriptive: to represent the descriptive of a meteorological phenomenon.
- Phenomenon: to represent a phenomenon.
- WeatherChangeTime: to represent a trend.
- TimeIndicator: to represent the time of the trend.

### Classes

#### Airport

The airport class is composed of
- Name
- City
- Country
- IATA code
- ICAO code
- latitude
- longitude
- altitude
- timezone

#### Cloud

- Name
- City
- Country
- IATA code
- ICAO code
- latitude
- longitude
- altitude
- timezone
Note: Depending on the source for the airports, fields can be null

#### Cloud

In this application a cloud is composed of
- CloudQuantity
- CloudType (optional)
- height (optional)


- CloudQuantity
- CloudType (optional)
- height (optional)

#### Country

A country is represented by its name.

#### Runway information

The runway information is composed of
- The name of the runway
- The minimal visibility on the runway
- The maximal visibility on the runway (optional)
- The trend of the visibility (optional)

- The name of the runway
- The minimal visibility on the runway
- The maximal visibility on the runway (optional)
- The trend of the visibility (optional)

#### Visibility

The visibility class is composed of
- The main visibility
- The minimal visibility (optional)
- The direction of the minimal visibility (optional)

- The main visibility
- The minimal visibility (optional)
- The direction of the minimal visibility (optional)

#### WeatherCondition

The weather condition is class to represent a meteorological phenomenon.
A weather condition is composed of
- an intensity (optional)
- a descriptive (optional)
- a list of phenomenon


- an intensity (optional)
- a descriptive (optional)
- a list of phenomenon

#### Wind

The wind class is composed of
- the speed
- the direction
- the speed of the gust
- the minimal wind variation in degrees
- the maximal wind variation in degrees
- the unit of the wind's speed


- the speed
- the direction
- the speed of the gust
- the minimal wind variation in degrees
- the maximal wind variation in degrees
- the unit of the wind's speed

#### WindShear

This class is a subclass of Wind.
It is composed of
- the height of the wind shear.

- the height of the wind shear.

### Trends

![trends diagram](trend.jpg)
Numerous classes represents the trends. Trends are stored inside a list of the metar object `Metar.getTrends()`.
Trends are composed of
- a Type (BECMG or TEMPO)
- a wind
- a visibility and vertical visibility
- a list of clouds
- a list of weather conditions
- a list of `AbstractMetarTrendTime` to represent the time with its type (AT, FM, TL)

- a Type (BECMG or TEMPO)
- a wind
- a visibility and vertical visibility
- a list of clouds
- a list of weather conditions
- a list of `AbstractMetarTrendTime` to represent the time with its type (AT, FM, TL)

## Airports loading

By default, airports are loaded from the temporary file [airport.dat](metarParser-spi/src/main/resources/data/airports.dat)
It is possible to provide your own source of airports via spi.
See [spi](metarParser-spi/README.md) module for details.

## Examples

### Parse a metar

Instantiate the metarFacade and use its method parse.

```java
String code = "LFPG 131830Z 19005KT 170V250 9999 -SHRA FEW040TCU SCT086 16/08 Q1011";
MetarFacade facade = MetarFacade.getInstance();
Metar metar = facade.decode(code);
MetarService service = MetarService.getInstance();
Metar metar = service.decode(code);
```

### Retrieve the metar of an airport

Instantiate the metarFacade.
Use the its method retrieveFromAirport with the ICAO code of the airport.

```java
String icao = "LFPG";
MetarFacade facade = MetarFacade.getInstance();
Metar metar = facade.retrieveFromAirport(icao);
MetarService service = MetarService.getInstance();
Metar metar = service.retrieveFromAirport(icao);
```

### Parse a taf

Use the TAFFacade to decode the taf.

```java
Expand All @@ -154,29 +196,35 @@ String message = "TAF LFPG 150500Z 1506/1612 17005KT 6000 SCT012 \n"
+"BECMG 1520/1522 CAVOK \n"
+"TEMPO 1603/1608 3000 BR BKN006 PROB40 \n"
+"TEMPO 1604/1607 0400 BCFG BKN002 TX17/1512Z TN07/1605Z";
TAFFacade facade = TAFFacade.getInstance();
TAF taf = facade.decode(message);
TAFService service = TAFService.getInstance();
TAF taf = service.decode(message);
```
Lines of the message have to be separated by a "\n" character.

Lines of the message have to be separated by a "\\n" character.

### Retrieve a taf

Use the TAFFacade and the method retrieveFromAirport with the ICAO code of the airport.

```java
String icao = "LFPG";
TAFFacade facade = TAFFacade.getInstance();
TAF taf = facade.retrieveFromAirport(icao);
TAFService service = TAFService.getInstance();
TAF taf = service.retrieveFromAirport(icao);
```

### Internationalization

English and french locales are supported by the library. The library uses the user's locale.
The default locale is english.

#### Change the locale and contributing

To change the locale use the method `setLocale(Locale)` of the class `Messages.java`

```(java)
Messages.getInstance().setLocale(Locale.FRENCH); // Changes the locale to french.
```

If you are willing to add a new locale or contribute to the project please see [Contributing.md file](CONTRIBUTING.md).

[Jetbrains](https://www.jetbrains.com/?from=metarParser) open source project.
Loading

0 comments on commit bc43315

Please sign in to comment.