aipp 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +6 -1
- data/aipp.gemspec +1 -1
- data/exe/aip2aixm +3 -3
- data/lib/aipp/parsers/LF/AD-1.5.rb +128 -0
- data/lib/aipp/parsers/LF/ENR-4.1.rb +5 -2
- data/lib/aipp/parsers/LF/ENR-4.3.rb +2 -1
- data/lib/aipp/parsers/LF/ENR-5.1.rb +3 -1
- data/lib/aipp/parsers/LF/helpers/html.rb +11 -0
- data/lib/aipp/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ce24174fda71fe6649f2d1f02eab03a2d9de0a59da6dbb581d581fe2dc2df4c
|
4
|
+
data.tar.gz: 7643f1ec9c399e244ddbc13ef9a3a5df31eaf63e78c197a55c55838a0536d8ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4029172c77e70998f89c10eb19c6bb827d042fd7a9c9190538bb422e319c0387c85534de28e8d0357b0c676f99e7a222479419bbc34d00cc34ca3c918636987
|
7
|
+
data.tar.gz: 3a294be41d8eb5067dc286b60ed304db554607694e094b7fa92a114ce9bac663261ba4246d45d4da133b753689535f2a708d09dd47dc06204dd5f86c5dd982f6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -31,7 +31,7 @@ aip2aixm --help
|
|
31
31
|
|
32
32
|
## Parsers
|
33
33
|
|
34
|
-
Parsers are defined as modules and named
|
34
|
+
Parsers are defined as modules and named <tt>lib/aipp/parser/{FIR}/{AIP}.rb</tt>. For
|
35
35
|
them to plug in, you have to define the following public methods:
|
36
36
|
|
37
37
|
* `url`<br>Must return the download URL of the AIP HTML as a string.
|
@@ -53,6 +53,11 @@ You should `fail` on fatal and `warn` on non-fatal problems. If `$DEBUG` is
|
|
53
53
|
warn("my message", binding)
|
54
54
|
```
|
55
55
|
|
56
|
+
## Helpers
|
57
|
+
|
58
|
+
Any modules in <tt>lib/aipp/parser/{FIR}/helpers</tt> are required automatically and
|
59
|
+
can be included and used in the parsers.
|
60
|
+
|
56
61
|
## AIRAC date calculations
|
57
62
|
|
58
63
|
```ruby
|
data/aipp.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'guard'
|
31
31
|
spec.add_development_dependency 'guard-minitest'
|
32
32
|
|
33
|
-
spec.add_runtime_dependency 'aixm', '~> 0', '>= 0.2.
|
33
|
+
spec.add_runtime_dependency 'aixm', '~> 0', '>= 0.2.3'
|
34
34
|
spec.add_runtime_dependency 'nokogiri', '~> 1'
|
35
35
|
spec.add_runtime_dependency 'nokogumbo', '~> 1'
|
36
36
|
spec.add_runtime_dependency 'pry', '~> 0'
|
data/exe/aip2aixm
CHANGED
@@ -20,7 +20,7 @@ class Executable
|
|
20
20
|
@verbose = false
|
21
21
|
OptionParser.new do |o|
|
22
22
|
o.banner = <<~END
|
23
|
-
Download online AIP and convert it to AIXM.
|
23
|
+
Download online AIP and convert it to AIXM for VFR.
|
24
24
|
Usage: #{File.basename($0)} [options]
|
25
25
|
END
|
26
26
|
o.on('-A', '--about', 'author and license information') { puts 'Written by Sven Schwyn (bitcetera.com) and distributed under MIT license.'; exit }
|
@@ -42,8 +42,8 @@ class Executable
|
|
42
42
|
extensions = [(:ofm if ofm)].compact
|
43
43
|
filename = [fir, aip, airac].join('_') + '.aixm'
|
44
44
|
loader = AIPP::Loader.new(fir: fir, aip: aip, airac: airac, limit: limit)
|
45
|
-
|
46
|
-
|
45
|
+
File.write(Pathname.new(Dir.pwd).join(filename), loader.aixm.to_aixm(*extensions))
|
46
|
+
puts "#{loader.aixm.features.count} feature(s) written to #{filename}"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module AIPP
|
2
|
+
module Parsers
|
3
|
+
include Helpers::URL
|
4
|
+
include Helpers::HTML
|
5
|
+
using AIPP::Refinements
|
6
|
+
|
7
|
+
MASTER_MAP = {
|
8
|
+
'l' => 'ndb'
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def convert!
|
12
|
+
cleanup!
|
13
|
+
html.css('tbody').each do |tbody|
|
14
|
+
name = last_id = nil
|
15
|
+
tbody.css('tr').to_enum.with_index(1).each do |tr, index|
|
16
|
+
break if index >= @limit
|
17
|
+
case tr.attr(:id)
|
18
|
+
when /TXT_NAME/
|
19
|
+
index -= 1
|
20
|
+
name = tr.css('td').text.strip.split("\n").first
|
21
|
+
when /GEO_LAT/
|
22
|
+
tds = tr.css('td')
|
23
|
+
type, runway = tds[0].text.strip.gsub(/\s+/, ' ').split(' ', 2)
|
24
|
+
master, slave = type.downcase.split('-')
|
25
|
+
if respond_to?("#{master}_from", true)
|
26
|
+
id = tds[1].text.strip.blank_to_nil || last_id
|
27
|
+
navaid = AIXM.send(
|
28
|
+
(MASTER_MAP[master] || master),
|
29
|
+
{ id: id, name: [name, runway].compact.join(' ') }.
|
30
|
+
merge(base_from(tds)).
|
31
|
+
merge(send("#{master}_from", tds))
|
32
|
+
)
|
33
|
+
navaid.schedule = schedule_from(tds[3])
|
34
|
+
navaid.remarks = remarks_from(tds[6], tds[7], tds[8])
|
35
|
+
navaid.send("associate_#{slave}", channel: channel_from(tds[2])) if slave
|
36
|
+
aixm.features << navaid
|
37
|
+
last_id = id
|
38
|
+
else
|
39
|
+
warn("WARNING: navigational aid `#{master}' at ##{index} skipped: not relevant to VFR")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
rescue => exception
|
43
|
+
warn("WARNING: error parsing navigational aid at ##{index}: #{exception.message}", binding)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def base_from(tds)
|
52
|
+
{
|
53
|
+
xy: xy_from(tds[4]),
|
54
|
+
z: z_from(tds[5])
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def vor_from(tds)
|
59
|
+
{
|
60
|
+
type: :conventional,
|
61
|
+
f: frequency_from(tds[2]),
|
62
|
+
north: :geographic,
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
def dme_from(tds)
|
67
|
+
{
|
68
|
+
channel: channel_from(tds[2])
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def ndb_from(tds)
|
73
|
+
{
|
74
|
+
type: :en_route,
|
75
|
+
f: frequency_from(tds[2])
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def l_from(tds)
|
80
|
+
{
|
81
|
+
type: :locator,
|
82
|
+
f: frequency_from(tds[2])
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
def tacan_from(tds)
|
87
|
+
{
|
88
|
+
channel: channel_from(tds[2])
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def xy_from(td)
|
93
|
+
parts = td.text.strip.split(/\s+/)
|
94
|
+
AIXM.xy(lat: parts[0], long: parts[1])
|
95
|
+
end
|
96
|
+
|
97
|
+
def z_from(td)
|
98
|
+
parts = td.text.strip.split(/\s+/)
|
99
|
+
AIXM.z(parts[0].to_i, :qnh) if parts[1] == 'ft'
|
100
|
+
end
|
101
|
+
|
102
|
+
def frequency_from(td)
|
103
|
+
parts = td.text.strip.split(/\s+/)
|
104
|
+
AIXM.f(parts[0], parts[1]) if parts[1] =~ /hz$/i
|
105
|
+
end
|
106
|
+
|
107
|
+
def channel_from(td)
|
108
|
+
parts = td.text.strip.split(/\s+/)
|
109
|
+
parts.last if parts[-2].downcase == 'ch'
|
110
|
+
end
|
111
|
+
|
112
|
+
def schedule_from(td)
|
113
|
+
code = td.text.strip
|
114
|
+
AIXM.schedule(code: code) unless code.empty?
|
115
|
+
end
|
116
|
+
|
117
|
+
def remarks_from(*parts)
|
118
|
+
part_titles = ['COVERAGE', 'RDH (SLOPE)', 'LOCATION']
|
119
|
+
[].tap do |remarks|
|
120
|
+
parts.each.with_index do |part, index|
|
121
|
+
if part = part.text.gsub(/ +/, ' ').strip.blank_to_nil
|
122
|
+
remarks << "#{part_titles[index]}:\n#{part}"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end.join("\n\n").blank_to_nil
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module AIPP
|
2
2
|
module Parsers
|
3
3
|
include Helpers::URL
|
4
|
+
include Helpers::HTML
|
4
5
|
using AIPP::Refinements
|
5
6
|
|
6
7
|
def convert!
|
8
|
+
cleanup!
|
7
9
|
html.css('tbody').each do |tbody|
|
8
10
|
tbody.css('tr').to_enum.with_index(1).each do |tr, index|
|
9
11
|
break if index >= @limit
|
10
12
|
tds = tr.css('td')
|
11
|
-
master, slave = tds[1].text.strip.
|
13
|
+
master, slave = tds[1].text.strip.gsub(/[^\w-]/, '').downcase.split('-')
|
12
14
|
navaid = AIXM.send(master, base_from(tds).merge(send("#{master}_from", tds)))
|
13
15
|
navaid.schedule = schedule_from(tds[4])
|
14
16
|
navaid.remarks = remarks_from(tds[5], tds[7], tds[9])
|
@@ -34,7 +36,7 @@ module AIPP
|
|
34
36
|
|
35
37
|
def vor_from(tds)
|
36
38
|
{
|
37
|
-
type: :
|
39
|
+
type: :conventional,
|
38
40
|
f: frequency_from(tds[3]),
|
39
41
|
north: :geographic,
|
40
42
|
}
|
@@ -48,6 +50,7 @@ module AIPP
|
|
48
50
|
|
49
51
|
def ndb_from(tds)
|
50
52
|
{
|
53
|
+
type: :en_route,
|
51
54
|
f: frequency_from(tds[3])
|
52
55
|
}
|
53
56
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module AIPP
|
2
2
|
module Parsers
|
3
3
|
include Helpers::URL
|
4
|
+
include Helpers::HTML
|
4
5
|
using AIPP::Refinements
|
5
6
|
using AIXM::Refinements
|
6
7
|
|
@@ -21,6 +22,7 @@ module AIPP
|
|
21
22
|
}.freeze
|
22
23
|
|
23
24
|
def convert!
|
25
|
+
cleanup!
|
24
26
|
html.css('tbody:has(tr[id^=mid])').each do |tbody|
|
25
27
|
airspace = nil
|
26
28
|
tbody.css('tr').to_enum.with_index(1).each do |tr, index|
|
@@ -126,7 +128,7 @@ module AIPP
|
|
126
128
|
end
|
127
129
|
end
|
128
130
|
end
|
129
|
-
end.join("\n\n")
|
131
|
+
end.join("\n\n").blank_to_nil
|
130
132
|
end
|
131
133
|
end
|
132
134
|
end
|
data/lib/aipp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aipp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Schwyn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,7 +131,7 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version: 0.2.
|
134
|
+
version: 0.2.3
|
135
135
|
type: :runtime
|
136
136
|
prerelease: false
|
137
137
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -141,7 +141,7 @@ dependencies:
|
|
141
141
|
version: '0'
|
142
142
|
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.2.
|
144
|
+
version: 0.2.3
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: nokogiri
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,9 +206,11 @@ files:
|
|
206
206
|
- lib/aipp.rb
|
207
207
|
- lib/aipp/airac.rb
|
208
208
|
- lib/aipp/loader.rb
|
209
|
+
- lib/aipp/parsers/LF/AD-1.5.rb
|
209
210
|
- lib/aipp/parsers/LF/ENR-4.1.rb
|
210
211
|
- lib/aipp/parsers/LF/ENR-4.3.rb
|
211
212
|
- lib/aipp/parsers/LF/ENR-5.1.rb
|
213
|
+
- lib/aipp/parsers/LF/helpers/html.rb
|
212
214
|
- lib/aipp/parsers/LF/helpers/url.rb
|
213
215
|
- lib/aipp/refinements.rb
|
214
216
|
- lib/aipp/version.rb
|