Project

aixm

The project is in a healthy, maintained state
Build XML descriptions of aeronautical infrastructure either as AIXM 4.5 (Aeronautical Information Exchange Model) or OFMX 1 (Open FlightMaps eXchange).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
 Project Readme

Version Tests Code Climate Donorbox

AIXM

Partial implementation of the Aeronautical Information Exchange Model (AIXM 4.5) and it's dialect Open FlightMaps eXchange format (OFMX 0) for Ruby.

For now, only the parts needed to automize the AIP import of open flightmaps are part of this gem. Most notably, the gem is only a builder for snapshot files and does not parse them.

Install

Security

This gem is cryptographically signed in order to assure it hasn't been tampered with. Unless already done, please add the author's public key as a trusted certificate now:

gem cert --add <(curl -Ls https://raw.github.com/svoop/aixm/master/certs/svoop.pem)

Bundler

Add the following to the Gemfile or gems.rb of your Bundler powered Ruby project:

gem aixm

And then install the bundle:

bundle install --trust-policy MediumSecurity

Standalone

If you're only going to use the executables, make sure to have the latest version of Ruby and then install this gem:

gem install aixm --trust-policy MediumSecurity

Usage

Here's how to build a document object, populate it with a simple feature and then render it as AIXM:

document = AIXM.document(
  region: 'LF'
)
document.add_feature(
  AIXM.designated_point(
    id: "ABIXI",
    xy: AIXM.xy(lat: %q(46°31'54.3"N), long: %q(002°19'55.2"W)),
    type: :icao
  )
)
AIXM.ofmx!
document.to_xml

You can initialize all elements either traditionally or by use of the corresponding shorthand AIXM class method. The following two statements are identical:

AIXM::Feature::NavigationalAid::DesignatedPoint.new(...)
AIXM.designated_point(...)

See AIXM::CLASSES for the complete list of shorthand names.

Configuration

AIXM.config.schema

The schema is either :aixm (default) or :ofmx:

AIXM.config.schema = :ofmx   # =>:ofmx

There are shortcuts to set and get the schema:

AIXM.schema             # => :aixm
AIXM.aixm?              # => true
AIXM.ofmx!              # => :ofmx
AIXM.ofmx?              # => true
AIXM.schema             # => :ofmx
AIXM.schema(:version)   # => 0

AIXM.config.region

The :ofmx schema requires the region to be set on all core features. You can do so on individual features, however, you might want to configure a default region to simplify your life:

AIXM.ofmx!
AIXM.region = 'LF'

⚠️ This setting has no effect when using the :aixm schema.

AIXM.config.mid

In order to insert OFMX-compliant mid attributes into all *Uid elements, you have set the mid configuration option to true.

AIXM.ofmx!
AIXM.config.mid          # => false - don't insert mid attributes by default
AIXM.config.mid = true   # => true  - insert mid attributes

⚠️ This setting has no effect when using the :aixm schema.

AIXM.config.ignored_errors

In case you want to ignore certain XML schema validation errors, set this configuration option to a regular expression which matches the error messages to ignore. By default, no errors are ignored.

AIXM.config.ignored_errors = /invalid date/i

Models

Fundamentals

Features

Components

Associations

The different models are interwoven with has_many and has_one associations.

Please note that has_many associations are instances AIXM::Association::Array which mostly behave like normal arrays. However, you must not add or remove elements on the array directly but use the corresponding method on the associating model instead:

document.features << airport   # => NoMethodError
document.add_feature airport   # okay

find_by and find

Use find_by on has_many to filter associations by class and optional attribute values:

document.features.find_by(:airport)               # => [#<AIXM::Feature::Airport>, #<AIXM::Feature::Airport>]
document.features.find_by(:airport, id: 'LFNT')   # => [#<AIXM::Feature::Airport>]

To search a has_many association for equal objects, use find:

document.features.find(airport)   # => [#<AIXM::Feature::Airport>]

This may seem redundant at first, but keep in mind that two instances of +AIXM::CLASSES+ which implement #to_uid are considered equal if they are instances of the same class and both their UIDs as calculated by #to_uid are equal. Attributes which are not part of the #to_uid calculation are irrelevant!

duplicates

Equally on has_many associations, use duplicates to find identical or equal associations:

document.features.duplicates   # => [#<AIXM::Feature::Unit>, #<AIXM::Component::Service>, ...]

Payload Hash

OFMX defines a payload hash function used to facilitate association and modification tracking. It is used internally, but you can also use it in your own code:

# Payload hash of XML fragment string
xml = '<xml><a></a></xml>'
AIXM::PayloadHash.new(xml).to_uuid

# Payload hash of Nokogiri XML fragment
document = File.open("file.xml") { Nokogiri::XML(_1) }
AIXM::PayloadHash.new(document).to_uuid

Validation

AIXM::Document#valid? validates the resulting AIXM or OFMX against its XML schema. If any, you find the errors in AIXM::Document#errors.

Refinements

By using AIXM::Refinements you get a few handy extensions to Ruby core classes.

Executables

mkmid

The mkmid executable reads an OFMX file, adds OFMX-compliant mid values into all *Uid elements and validates the result against the schema.

mkmid --help

ckmid

The chmid executable reads an OFMX file, validates it against the schema and checks all mid attributes for OFMX-compliance.

ckmid --help

References

AIXM

OFMX

Tests

Some tests are very time consuming and therefore skipped by default. To run the full test suite, set the environment variable:

export SPEC_SCOPE=all

Development

To install the development dependencies and then run the test suite:

bundle install
bundle exec rake    # run tests once
bundle exec guard   # run tests whenever files are modified

Please submit issues on:

https://github.com/svoop/aixm/issues

To contribute code, fork the project on Github, add your code and submit a pull request:

https://help.github.com/articles/fork-a-repo

License

The gem is available as open source under the terms of the MIT License.