Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
moryakovdv committed Apr 9, 2018
0 parents commit a6ac5f5
Show file tree
Hide file tree
Showing 6,071 changed files with 1,311,225 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
8 changes: 8 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
11 changes: 11 additions & 0 deletions .settings/org.eclipse.wst.common.component
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="iwxxmConverter">
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/schemabindings"/>
<property name="context-root" value="iwxxmConverter"/>
<property name="java-output-path" value="/iwxxmConverter/target/classes"/>
</wb-module>
</project-modules>
4 changes: 4 additions & 0 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.8"/>
</faceted-project>
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.container
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.jsdt.ui.superType.name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Window
54 changes: 54 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Apache License

Version 2.0, January 2004

http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.

"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:

You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.

You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
12 changes: 12 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
IwxxmConverter
Copyright(C) 2018 Dmitry Moryakov. Main aeronautical meteorological center, Moscow, Russia

The CRUX software is provided under
CRUX License
Copyright © 2016 University Corporation for Atmospheric Research (UCAR). All rights reserved.

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

1. PH-Schematron (Philip Helger (www.helger.com))

151 changes: 151 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Introduction
IwxxmConverter is JAXB-project intended to provide starting API(numerous of helper classes and methods) to allow other contributors to develop
their own applications in the area of **IWXXM** conversion, validation and distribution.

## Credits
Thanks to the many of IWXXM, ICAO, WMO people who provided clear XSD schemas of the new aviation weather format.
One may find them here:
[IWXXM2.0](http://schemas.wmo.int/iwxxm/2.0/zip/iwxxm-schema-bundle-2.0.zip)
[IWXXM2.1RC](http://schemas.wmo.int/iwxxm/2.1.1RC1/zip/iwxxm-schema-bundle-2.1.1RC1.zip)

## What has been done
This project contains already prepared java-classes, generated by xjc compiler and some binding classes
(for example see /test/resources/iwxxm/2.1/binders1)
Execution of `xjc iwxxm.xsd -extension -b binders1 -d output` leads to recompile all xsds into 'output' dir.

BUT keep in mind that there are some edits and additions to generated classes.
1. Namespaces prefixes are set either by annotation @XmlNs in each package-info file,
e.g. *xmlns={@XmlNs(namespaceURI = "http://icao.int/iwxxm/2.1", prefix = "iwxxm" )}*
or by special mapper 'common.NameSpaceMapper' when (somehow) for xlink @XmlNs namespace annotation binding doesn't work.
2. Also there are direct changes in generated classes that remove some unnecessary(?) tags from output XML:
- GML AbstractFeatureType - BoundedBy - made non-mandatory (removes \<boundedBy="nil"\> tag)
- In these classes field 'final static TypeType TYPE' can be changed to a non-static property to remove \<xlink:type="simple"\>:
- GML ReferenceType
- GML TimeInstantPropertyType
- GML FeaturePropertyType
3. The CRUX validation, provided by NCAR (thanks to [Aaron Braeckel](https://github.com/braeckel)), is included in POM and avaliable from unit tests.
But the performance of crux library taken from Maven is not very good.
Probably it caused by loading of xml schemas via http.

As an alternative way of validation the [PH-SHEMATRON](https://github.com/phax/ph-schematron) is provided.
The comparing results look similar but ph-schematron's performance out-of-the-box is much better.
Bonus: ph-shematron can generate SVRL report files with validation results.

## Using
There are some steps from TAC to IWXXM messages:
- Parsing TAC
- Creating internal representation of described elements
- Applying transformation to JAXB-object
- Marshalling of the prepared object to XML-document
- Validation of XML-file with schematron engine

If you're not interested in internal representation just use appropriate converter:

1. Conversion sample
```java
String metar = "METAR UUEE 270830Z 02006MPS 2100 -SN OVC009 M04/M06 Q1008 R06L/590230\n" +
" R06R/590230 TEMPO 1000 SHSN BKN012CB=";
@Test
public void testMetar() {
METARConverter mc = new METARConverter();
String result = mc.convertTacToXML(metar);
System.out.println(result);
}
```
Similar use TAFConverter and SPECIConverter

2. Validation sample. See IwxxmValidator class for details
```java
@Test
public void testValidation() {
//create and init validator
IwxxmValidator validator = new IwxxmValidator();
validator.init();
//convert taf
String validTaf = "TAF LZIB 101058Z 1012/1112 24015KT 9999 -SHRA FEW018 BKN028 TX10/1112Z TN05/1100Z BECMG 1014/1017 18012KT BECMG 1104/1107 14022KT 7000 RADZ SCT010 BKN015CB OVC025";
TAFConverter tafconverter = new TAFConverter();
String iwxxm = tafconverter.convertTacToXML(validTaf);
//send it to validator and check failures
List<FailedAssert> failedResults = validator.validateString(iwxxm);
assertTrue(failedResults.size()==0);
}
```
3. Using internal representation
If you need internal classes, see METARTacMessage, SPECITacMessage, TAFTacMessage classes and their interfaces.
When parsing from TAC use `parseMessage()` for whole message and `parseSection()` for Trends functions.
```java
String tafUUWW = "TAF UUWW 090750Z 0909/1008 30007MPS 9999 SCT015 TXM03/1009Z\r\n" +
"TNM06/0918Z TEMPO 0909/0913 30012MPS\r\nBECMG 0913/0915 OVC009 TEMPO\n" +
"0915/1009 3100 -SN OVC005=";
@Test
public void testTafCommonWeatherSection() throws TAFParsingException {
//Init message and parse TAC
TAFTacMessage tafMessage = new TAFTacMessage(tafUUWW);
tafMessage.parseMessage();
//check field values after parsing
assertEquals(23, tafMessage.getValidityInterval().toPeriod().toStandardHours().getHours());
assertEquals(1,tafMessage.getBecomingSections().size());
assertEquals(2,tafMessage.getTempoSections().size());
assertEquals(BigDecimal.valueOf(-3),tafMessage.getCommonWeatherSection().getAirTemperatureMax());
assertEquals(BigDecimal.valueOf(-6),tafMessage.getCommonWeatherSection().getAirTemperatureMin());
}
```

4. Also you may init empty message object, fill them via setters and convert into IWXXM representation
```java
@Test
public void testIWXXMCreation() {
//create empty object
TAFTacMessage tafMessage = new TAFTacMessage("");

//fill with data
tafMessage.getCommonWeatherSection().setAirTemperatureMax(BigDecimal.TEN);
tafMessage.getCommonWeatherSection().setAirTemperatureMaxTime(DateTime.now());

// further field setters...

TAFConverter tc = new TAFConverter(); //create converter
TAFType tt = tc.convertMessage(tafMessage); //create iwxxm type
String result = tc.marshallMessageToXML(tt); //marshal to XML
System.out.println(result);
}
```
5. Simple REST-services (Grizzly+Jersey) included in project as a samples of remote conversion and validation.
Build project and start embedded web-server by following command with arguments of your ip/hostname and port (localhost:8082 are default):
```java -cp iwxxmConverter.jar WebAppStarter xxx.xxx.xxx.xxx yyyy```

In the case of empty parameters base URI will be (http://localhost:8082/iwxxmConverter/api)

API methods:
- test if REST is running
**method**: test
- get converted TAC in IWXXM format
**method**: convertandvalidate
**parameter**: message
- get converted result in IWXXM format and list of validation errors
**method**: convertandvalidate
**parameter**: message
- get validation results for input IWXXM message
**method**: validate
**parameter**:message

So ask (http://localhost:8082/iwxxmConverter/api/convertandvalidate?message=METAR UUWW 090830Z 23005MPS CAVOK 14/03 Q1021 R24/000070 NOSIG)
to get converted and validated results.


## Contribution
Any help from the community will be highly appreciated. There is a lot of work to be done =):
- This project needs much more test cases with tricky not well-formed TAC messages.
- It currently supports only IWXXM2.1 METAR, SPECI and TAF, so it should be extended for all documented IWXXM format
- After final release of the IWXXM 3 this project should be refactored to support new format
- RMK sections are waiting for implementation

## Licensing
The IwxxmConverter is distributed under The APACHE 2.0 License
CRUX software as dependency is distrubuted under The CRUX License
PH-Schematron as dependency is distributed under The APACHE 2.0 License

## Contacts
Dmitry Moryakov
Main aeronautical meteorological center, Moscow, Russia
E-mail: [email protected]
Loading

0 comments on commit a6ac5f5

Please sign in to comment.