Airdata
Rails engine for adding aviation related models and data to a web application.
Compatible with Rails 4.0
It will add 3 Active Record models to your rails application: Airports
, Runways
and Waypoints
(including Navaids). It will add the corresponding database
structure (migrations) and finally it will populate the corresponding tables of
your database with data (based on AIRAC cycle 1306.)
Disclaimer
This database is designed for training, education and flight simulation purposes! Its contents might be outdated and shall not be used for real world navigation and flight as it is unlawful and unsafe to do so!
Installation within parent app
Add this gem AND the activerecord-import
gem to your application's Gemfile:
gem 'airdata'
gem "activerecord-import", "~> 0.4.1" # Required for the data import
And then execute:
$ bundle
Run the following commands in your app directory:
rake airdata:install:migrations
rake db:migrate
rake airdata:setup
Updating the data
You can get information about your currently installed AIRAC cycle and the latest available one by running:
rake airdata:cycle # =>
Currently instaled AIRAC cycle: 1306
Latest available AIRAC cycle: 1306
No update is necessary!
# Or if there's a newer verion available:
rake airdata:cycle # =>
There's a newer cycle available.
You can update by running: rake airdata:update
If you want to do a data update to a newer AIRAC cycle, run the following rake task for clearing up the old data and re-injecting the current one:
rake airdata:update
Data stats
-
Airports: 10840
-
Runways: 29089
-
Waypoints and navaids: 239293
-
Total DB records: 279222
All data is derrived and compiled from public sources such as: OurAirports and OpenFlights
Lib classes
2 classes handle the heavy lifting of downloading, parsing and injecting the data
within you local database: Airdata::DataDownloader
and Airdata::DataInjector
.
Generally you won't need to deal with them directly. All the functionality you
need to install is triggered via rake tasks and almost nothing there is
considered public API, apart from the following public class methods:
# Returns the currently installed AIRAC cycle:
Airdata::DataDownloader.cycle # => 1208
# Returns the latest available for download AIRAC cycle:
Airdata::DataDownloader.latest_cycle # => 1301
Models and their attributes
These AR models and attribute sets will be available in your parent app,
namespaced within the Airdata
module and accessible like this:
Airdata::Airports
Airdata::Runways
Airdata::Waypoints
Currently there are no special public methods/APIs available for these models, the engine is tailored primarily for data storage and access.
Ordering
Default ordering is implemented for all 3 classes. Airports and waypoints are
sorted alphabetically i.e. ordered by id
, and the runways are ordered by their
airport_id
. Remember you can always override the default ordering by using Active
Record's .reorder
method
Airports
Includes one-to-many association with the Runways
class.
attr_accessible :elevation, :icao, :lat, :lon, :msa, :name, :ta
has_many :runways, :dependent => :destroy
- ICAO
- Name (city)
- Latitude
- Longitude
- Elevation
- Transition altitude
- Minimum safe altitude
Runways
Includes one-to-many association with the Airports
models.
attr_accessible :airport_id, :course, :elevation, :glidepath, :ils, :ils_fac
attr_accessible :ils_freq, :lat, :length, :lon, :number
belongs_to :airport
- airport_id (association)
- number
- course
- elevation
- glidepath angle
- ILS (boolean)
- ILS final approach course
- ILS frequency
- latitude on the threshold
- longitude on the threshold
- length
Waypoints (includes Navaids)
Regular waypoints only include :ident, :lat, :lon, :country_code
. The rest is
for navaids.
attr_accessible :country_code, :elevation, :freq, :ident, :lat, :lon, :name, :range
- ident
- name
- frequency
- country code
- elevation
- latitude
- longitude
- range (in MSFS)
Rake tasks
Here's a lisk of all rake tasks that this gem adds:
rake airdata:install:migrations # Copy migrations from airdata to application.
# This is part of the initial install process.
rake airdata:setup # Downloads and installs the latest navdata
rake airdata:cycle # Compares your currently installed AIRAC cycle
# agianst the latest available
rake airdata:truncate # Truncate navadata tables, populated by Airdata.
# Generally you don't need to run this separately,
# it's automatically called during data updates
rake airdata:update # Removes old Airdata and installs latest available
# Essentially it runs the truncate task followed by the setup
Updating from older versions
- make sure to run the
rake airdata:update
task after updating the gem. This will ensure all latest migrations and modifications to the data structure are executed and will inject the latest available dataset
Changelog
v. 0.4.1, 26 Oct 2013
- dependencies update
v. 0.4.0, 30 Aug 2013
- rails 4 compatibility
v. 0.3.2, 15 June 2013
- updated dependencies and data
v. 0.3.1, 1 February 2013
- moved away from the deprecated github downloads
- updated dependencies
- inproved setup/update processing speed
- fixed support for multiple parallel runways (left, right, center)
- other bugfixes
v. 0.2, 29 August 2012
- added default ordering for all 3 models. Airports and waypoints/navaids are
sorted by
id
, runways are sorted byairport_id
Credits
Copyright © 2013 Svilen Vassilev
If you find my work useful or time-saving, you can endorse it or buy me a beer:
Released under the MIT LICENSE