airdata 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.md +181 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/airdata/application.js +15 -0
- data/app/assets/stylesheets/airdata/application.css +13 -0
- data/app/controllers/airdata/application_controller.rb +4 -0
- data/app/helpers/airdata/application_helper.rb +4 -0
- data/app/models/airdata/airoption.rb +5 -0
- data/app/models/airdata/airport.rb +7 -0
- data/app/models/airdata/runway.rb +8 -0
- data/app/models/airdata/waypoint.rb +5 -0
- data/app/views/layouts/airdata/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20120729093219_create_airdata_airports.rb +15 -0
- data/db/migrate/20120729093820_create_airdata_runways.rb +19 -0
- data/db/migrate/20120729134341_create_airdata_waypoints.rb +16 -0
- data/db/migrate/20120730092740_create_airdata_airoptions.rb +10 -0
- data/lib/airdata.rb +97 -0
- data/lib/airdata/engine.rb +5 -0
- data/lib/airdata/version.rb +3 -0
- data/lib/tasks/airdata_tasks.rake +69 -0
- data/test/airdata_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +64 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +43576 -0
- data/test/dummy/log/test.log +3 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/airdata/airoptions.yml +9 -0
- data/test/fixtures/airdata/airports.yml +19 -0
- data/test/fixtures/airdata/runways.yml +27 -0
- data/test/fixtures/airdata/waypoints.yml +21 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/airdata/airoption_test.rb +9 -0
- data/test/unit/airdata/airport_test.rb +9 -0
- data/test/unit/airdata/runway_test.rb +9 -0
- data/test/unit/airdata/waypoint_test.rb +9 -0
- metadata +225 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Svilen Vassilev
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
# Airdata
|
2
|
+
|
3
|
+
Rails engine for adding aviation related models and data to a web application.
|
4
|
+
|
5
|
+
It will add 3 Active Record models to your rails application: `Airports`, `Runways`
|
6
|
+
and `Waypoints` (including Navaids). It will add the corresponding database
|
7
|
+
structure (migrations) and finally it will populate the corresponding tables of
|
8
|
+
your database with [data](#data-stats) (based on *AIRAC cycle 1208*.)
|
9
|
+
|
10
|
+
[](http://travis-ci.org/tarakanbg/airdata)
|
11
|
+
[](https://codeclimate.com/github/tarakanbg/airdata)
|
12
|
+
[](https://gemnasium.com/tarakanbg/airdata)
|
13
|
+
|
14
|
+
## Installation within parent app
|
15
|
+
|
16
|
+
Add this gem AND the `activerecord-import` your application's Gemfile:
|
17
|
+
|
18
|
+
gem 'airdata'
|
19
|
+
gem "activerecord-import", "~> 0.2.9" # Required for the data import
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Run the following commands in your app directory:
|
26
|
+
|
27
|
+
```sh
|
28
|
+
rake airdata:install:migrations
|
29
|
+
rake db:migrate
|
30
|
+
rake airdata:setup
|
31
|
+
```
|
32
|
+
|
33
|
+
### Updating the data
|
34
|
+
|
35
|
+
You can get information about your currently installed AIRAC cycle and the
|
36
|
+
latest available one by running:
|
37
|
+
|
38
|
+
```sh
|
39
|
+
rake airdata:cycle # =>
|
40
|
+
|
41
|
+
Currently instaled AIRAC cycle: 1208
|
42
|
+
Latest available AIRAC cycle: 1208
|
43
|
+
|
44
|
+
No update is necessary!
|
45
|
+
|
46
|
+
# Or if there's a newer verion available:
|
47
|
+
rake airdata:cycle # =>
|
48
|
+
|
49
|
+
There's a newer cycle available.
|
50
|
+
You can update by running: rake airdata:update
|
51
|
+
```
|
52
|
+
|
53
|
+
If you want to do a data update to a newer AIRAC cycle, run the following
|
54
|
+
rake task for clearing up the old data and re-injecting the current one:
|
55
|
+
|
56
|
+
```sh
|
57
|
+
rake airdata:update
|
58
|
+
```
|
59
|
+
|
60
|
+
## Data stats
|
61
|
+
|
62
|
+
* Airports: 10775
|
63
|
+
* Runways: 28977
|
64
|
+
* Navaids: 16300
|
65
|
+
* Waypoints: 214400
|
66
|
+
|
67
|
+
* Total DB records: 270472
|
68
|
+
|
69
|
+
All data is derrived and compiled from public sources such as:
|
70
|
+
[OurAirports](http://www.ourairports.com/data/) and
|
71
|
+
[OpenFlights](http://openflights.org/data.html)
|
72
|
+
|
73
|
+
## Lib classes
|
74
|
+
|
75
|
+
2 classes handle the heavy lifting of downloading, parsing and injecting the data
|
76
|
+
within you local database: `Airdata::DataDownloader` and `Airdata::DataInjector`.
|
77
|
+
Generally you won't need to deal with them directly. All the functionality you
|
78
|
+
need to install is triggered via rake tasks and almost nothing there is
|
79
|
+
considered public API, apart from the following public class methods:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
# Returns the currently installed AIRAC cycle:
|
83
|
+
Airdata::DataDownloader.cycle # => 1206
|
84
|
+
|
85
|
+
# Returns the latest available for download AIRAC cycle:
|
86
|
+
Airdata::DataDownloader.latest_cycle # => 1208
|
87
|
+
```
|
88
|
+
|
89
|
+
## Models and their attributes
|
90
|
+
|
91
|
+
These AR models and attribute sets will be available in your parent app,
|
92
|
+
namespaced within the `Airdata` module and accessible like this:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
Airdata::Airports
|
96
|
+
Airdata::Runways
|
97
|
+
Airdata::Waypoints
|
98
|
+
```
|
99
|
+
Currently there are no special public methods/APIs available for these models,
|
100
|
+
the engine is tailored primarily for data storage and access.
|
101
|
+
|
102
|
+
### Airports
|
103
|
+
|
104
|
+
Includes one-to-many association with the `Runways` class.
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
attr_accessible :elevation, :icao, :lat, :lon, :msa, :name, :ta
|
108
|
+
|
109
|
+
has_many :runways, :dependent => :destroy
|
110
|
+
```
|
111
|
+
* ICAO
|
112
|
+
* Name (city)
|
113
|
+
* Latitude
|
114
|
+
* Longitude
|
115
|
+
* Elevation
|
116
|
+
* Transition altitude
|
117
|
+
* Minimum safe altitude
|
118
|
+
|
119
|
+
### Runways
|
120
|
+
|
121
|
+
Includes one-to-many association with the `Airports` models.
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
attr_accessible :airport_id, :course, :elevation, :glidepath, :ils, :ils_fac
|
125
|
+
attr_accessible :ils_freq, :lat, :length, :lon, :number
|
126
|
+
|
127
|
+
belongs_to :airport
|
128
|
+
```
|
129
|
+
|
130
|
+
* airport_id (association)
|
131
|
+
* number
|
132
|
+
* course
|
133
|
+
* elevation
|
134
|
+
* glidepath angle
|
135
|
+
* ILS (boolean)
|
136
|
+
* ILS final approach course
|
137
|
+
* ILS frequency
|
138
|
+
* latitude on the threshold
|
139
|
+
* longitude on the threshold
|
140
|
+
* length
|
141
|
+
|
142
|
+
### Waypoints (includes Navaids)
|
143
|
+
|
144
|
+
Regular waypoints only include `:ident, :lat, :lon, :country_code`. The rest is
|
145
|
+
for navaids.
|
146
|
+
|
147
|
+
```ruby
|
148
|
+
attr_accessible :country_code, :elevation, :freq, :ident, :lat, :lon, :name, :range
|
149
|
+
```
|
150
|
+
* ident
|
151
|
+
* name
|
152
|
+
* frequency
|
153
|
+
* country code
|
154
|
+
* elevation
|
155
|
+
* latitude
|
156
|
+
* longitude
|
157
|
+
* range (in MSFS)
|
158
|
+
|
159
|
+
## Rake tasks
|
160
|
+
|
161
|
+
Here's a lisk of all rake tasks that this gem adds:
|
162
|
+
|
163
|
+
```sh
|
164
|
+
rake airdata:install:migrations # Copy migrations from airdata to application.
|
165
|
+
# This is part of the initial install process.
|
166
|
+
rake airdata:setup # Downloads and installs the latest navdata
|
167
|
+
rake airdata:cycle # Compares your currently installed AIRAC cycle
|
168
|
+
# agianst the latest available
|
169
|
+
rake airdata:truncate # Truncate navadata tables, populated by Airdata.
|
170
|
+
# Generally you don't need to run this separately,
|
171
|
+
# it's automatically called during data updates
|
172
|
+
rake airdata:update # Removes old Airdata and installs latest available
|
173
|
+
# Essentially it runs the truncate task followed by the setup
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
## Credits
|
178
|
+
|
179
|
+
Copyright © 2012 [Svilen Vassilev](http://about.me/svilen)
|
180
|
+
|
181
|
+
Released under the [MIT LICENSE](https://github.com/tarakanbg/airdata/blob/master/LICENSE)
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Airdata'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.libs << 'test'
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
36
|
+
t.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Airdata</title>
|
5
|
+
<%= stylesheet_link_tag "airdata/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "airdata/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateAirdataAirports < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :airdata_airports do |t|
|
4
|
+
t.string :icao
|
5
|
+
t.string :name
|
6
|
+
t.float :lat
|
7
|
+
t.float :lon
|
8
|
+
t.integer :elevation
|
9
|
+
t.integer :ta
|
10
|
+
t.integer :msa
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateAirdataRunways < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :airdata_runways do |t|
|
4
|
+
t.integer :airport_id
|
5
|
+
t.integer :number
|
6
|
+
t.integer :course
|
7
|
+
t.integer :length
|
8
|
+
t.boolean :ils
|
9
|
+
t.float :ils_freq
|
10
|
+
t.integer :ils_fac
|
11
|
+
t.float :lat
|
12
|
+
t.float :lon
|
13
|
+
t.integer :elevation
|
14
|
+
t.float :glidepath
|
15
|
+
|
16
|
+
t.timestamps
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateAirdataWaypoints < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :airdata_waypoints do |t|
|
4
|
+
t.string :ident
|
5
|
+
t.string :name
|
6
|
+
t.float :freq
|
7
|
+
t.float :lat
|
8
|
+
t.float :lon
|
9
|
+
t.integer :range
|
10
|
+
t.integer :elevation
|
11
|
+
t.string :country_code
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/airdata.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require "airdata/engine"
|
2
|
+
|
3
|
+
module Airdata
|
4
|
+
class DataDownloader
|
5
|
+
%w{curb tempfile tmpdir}.each { |lib| require lib }
|
6
|
+
|
7
|
+
attr_accessor :name, :local, :remote
|
8
|
+
|
9
|
+
def initialize(name)
|
10
|
+
@name = name
|
11
|
+
@local = "#{Dir.tmpdir}/#{@name}.airdata"
|
12
|
+
@remote = "http://cloud.github.com/downloads/tarakanbg/airdata/#{@name}.airdata"
|
13
|
+
create_local_file
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.cycle
|
17
|
+
Airdata::Airoption.last.value
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.latest_cycle
|
21
|
+
txt = "http://cloud.github.com/downloads/tarakanbg/airdata/cycle.airdata"
|
22
|
+
Curl::Easy.perform(txt).body_str[0..3]
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def create_local_file
|
28
|
+
data = Tempfile.new(@name, :encoding => 'utf-8')
|
29
|
+
File.rename data.path, @local
|
30
|
+
data = Curl::Easy.perform(@remote).body_str
|
31
|
+
File.open(@local, "w+") {|f| f.write(data)}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
class DataInjector
|
37
|
+
%w{csv tempfile tmpdir}.each { |lib| require lib }
|
38
|
+
|
39
|
+
attr_accessor :name, :last_ap, :local, :records
|
40
|
+
|
41
|
+
def initialize(name)
|
42
|
+
@name = name
|
43
|
+
Airdata::DataDownloader.new(@name)
|
44
|
+
@local = "#{Dir.tmpdir}/#{@name}.airdata"
|
45
|
+
@last_ap = ""
|
46
|
+
@records = []
|
47
|
+
process
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def process
|
53
|
+
inject_airports if @name == "airports"
|
54
|
+
inject_navaids if @name == "navaids"
|
55
|
+
inject_waypoints if @name == "waypoints"
|
56
|
+
Airdata::Airoption.create!(:key => "cycle", :value => Airdata::DataDownloader.latest_cycle)
|
57
|
+
cleanup
|
58
|
+
end
|
59
|
+
|
60
|
+
def inject_airports
|
61
|
+
CSV.foreach(@local, :col_sep =>',') do |row|
|
62
|
+
type = row[0]
|
63
|
+
if type == "A"
|
64
|
+
ap = Airdata::Airport.create!(:icao => row[1], :name => row[2], :lat => row[3],
|
65
|
+
:lon => row[4], :elevation => row[5], :ta => row[6], :msa => row[8] )
|
66
|
+
@last_ap = ap.id
|
67
|
+
elsif type == "R"
|
68
|
+
@records << Airdata::Runway.new(:airport_id => @last_ap, :course => row[2], :elevation => row[10],
|
69
|
+
:glidepath => row[11], :ils => row[5], :ils_fac => row[7], :ils_freq => row[6],
|
70
|
+
:lat => row[8], :lon => row[9], :length => row[3], :number => row[1])
|
71
|
+
end # end if
|
72
|
+
end # end CSV loop
|
73
|
+
Airdata::Runway.import @records
|
74
|
+
end # end method
|
75
|
+
|
76
|
+
def inject_navaids
|
77
|
+
CSV.foreach(@local, :col_sep =>',') do |row|
|
78
|
+
@records << Airdata::Waypoint.new(:ident => row[0], :name => row[1], :freq => row[2],
|
79
|
+
:range => row[5], :lat => row[6], :lon => row[7], :elevation => row[8], :country_code => row[9])
|
80
|
+
end
|
81
|
+
Airdata::Waypoint.import @records
|
82
|
+
end
|
83
|
+
|
84
|
+
def inject_waypoints
|
85
|
+
CSV.foreach(@local, :col_sep =>',') do |row|
|
86
|
+
@records << Airdata::Waypoint.new(:ident => row[0], :lat => row[1], :lon => row[2], :country_code => row[3])
|
87
|
+
end
|
88
|
+
Airdata::Waypoint.import @records
|
89
|
+
end
|
90
|
+
|
91
|
+
def cleanup
|
92
|
+
File.delete(@local)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|