aixm 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -2
- data/CHANGELOG.md +20 -0
- data/README.md +7 -2
- data/aixm.gemspec +2 -3
- data/lib/aixm.rb +6 -2
- data/lib/aixm/a.rb +151 -0
- data/lib/aixm/component/frequency.rb +2 -2
- data/lib/aixm/component/geometry.rb +4 -0
- data/lib/aixm/component/geometry/point.rb +0 -4
- data/lib/aixm/component/helipad.rb +8 -22
- data/lib/aixm/component/runway.rb +36 -36
- data/lib/aixm/component/surface.rb +121 -0
- data/lib/aixm/component/timetable.rb +1 -0
- data/lib/aixm/constants.rb +40 -0
- data/lib/aixm/d.rb +5 -0
- data/lib/aixm/document.rb +2 -2
- data/lib/aixm/f.rb +6 -0
- data/lib/aixm/feature/address.rb +100 -0
- data/lib/aixm/feature/airport.rb +26 -7
- data/lib/aixm/feature/airspace.rb +10 -1
- data/lib/aixm/feature/navigational_aid.rb +1 -1
- data/lib/aixm/feature/navigational_aid/designated_point.rb +20 -5
- data/lib/aixm/feature/navigational_aid/dme.rb +2 -2
- data/lib/aixm/{component → feature}/service.rb +67 -16
- data/lib/aixm/feature/unit.rb +40 -6
- data/lib/aixm/refinements.rb +63 -6
- data/lib/aixm/shortcuts.rb +12 -4
- data/lib/aixm/version.rb +1 -1
- data/lib/aixm/xy.rb +6 -1
- data/lib/aixm/z.rb +6 -0
- data/schemas/ofmx/0/OFMX-DataTypes.xsd +5 -2
- data/schemas/ofmx/0/OFMX-Features.xsd +2 -0
- data/spec/factory.rb +32 -10
- data/spec/lib/aixm/a_spec.rb +203 -0
- data/spec/lib/aixm/component/helipad_spec.rb +11 -17
- data/spec/lib/aixm/component/runway_spec.rb +46 -32
- data/spec/lib/aixm/component/surface_spec.rb +88 -0
- data/spec/lib/aixm/d_spec.rb +10 -0
- data/spec/lib/aixm/document_spec.rb +104 -32
- data/spec/lib/aixm/f_spec.rb +10 -0
- data/spec/lib/aixm/feature/address_spec.rb +55 -0
- data/spec/lib/aixm/feature/airport_spec.rb +73 -3
- data/spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb +43 -6
- data/spec/lib/aixm/feature/navigational_aid/dme_spec.rb +2 -2
- data/spec/lib/aixm/feature/navigational_aid/marker_spec.rb +2 -2
- data/spec/lib/aixm/feature/navigational_aid/ndb_spec.rb +2 -2
- data/spec/lib/aixm/feature/navigational_aid/tacan_spec.rb +2 -2
- data/spec/lib/aixm/feature/navigational_aid/vor_spec.rb +6 -6
- data/spec/lib/aixm/{component → feature}/service_spec.rb +12 -14
- data/spec/lib/aixm/feature/unit_spec.rb +7 -4
- data/spec/lib/aixm/refinements_spec.rb +100 -15
- data/spec/lib/aixm/z_spec.rb +10 -0
- metadata +17 -25
- data/lib/aixm/h.rb +0 -87
- data/spec/lib/aixm/h_spec.rb +0 -113
@@ -83,9 +83,10 @@ describe AIXM::Feature::Unit do
|
|
83
83
|
</AhpUid>
|
84
84
|
<codeType>TWR</codeType>
|
85
85
|
<codeClass>ICAO</codeClass>
|
86
|
-
<txtRmk>
|
86
|
+
<txtRmk>FR only</txtRmk>
|
87
87
|
</Uni>
|
88
|
-
|
88
|
+
<!-- Service: AFIS by PUJAUT TWR -->
|
89
|
+
<Ser source="LF|GEN|0.0 FACTORY|0|0">
|
89
90
|
<SerUid>
|
90
91
|
<UniUid>
|
91
92
|
<txtName>PUJAUT TWR</txtName>
|
@@ -124,7 +125,8 @@ describe AIXM::Feature::Unit do
|
|
124
125
|
<codeLang>FR</codeLang>
|
125
126
|
</Cdl>
|
126
127
|
</Fqy>
|
127
|
-
|
128
|
+
<!-- Service: AFIS by PUJAUT TWR -->
|
129
|
+
<Ser source="LF|GEN|0.0 FACTORY|0|0">
|
128
130
|
<SerUid>
|
129
131
|
<UniUid>
|
130
132
|
<txtName>PUJAUT TWR</txtName>
|
@@ -163,7 +165,8 @@ describe AIXM::Feature::Unit do
|
|
163
165
|
<codeLang>FR</codeLang>
|
164
166
|
</Cdl>
|
165
167
|
</Fqy>
|
166
|
-
|
168
|
+
<!-- Service: APP by PUJAUT TWR -->
|
169
|
+
<Ser source="LF|GEN|0.0 FACTORY|0|0">
|
167
170
|
<SerUid>
|
168
171
|
<UniUid>
|
169
172
|
<txtName>PUJAUT TWR</txtName>
|
@@ -155,6 +155,32 @@ describe AIXM::Refinements do
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
+
context Regexp do
|
159
|
+
describe :decapture do
|
160
|
+
it "should replace capture groups with non-capture groups" do
|
161
|
+
/(foo) baz (bar)/.decapture.must_equal /(?-mix:(?:foo) baz (?:bar))/
|
162
|
+
/(foo) baz (bar)/i.decapture.must_equal /(?i-mx:(?:foo) baz (?:bar))/
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should replace named capture groups with non-capture groups" do
|
166
|
+
/(?<a>foo) baz (?<b>bar)/.decapture.must_equal /(?-mix:(?:foo) baz (?:bar))/
|
167
|
+
/(?<a>foo) baz (?<b>bar)/i.decapture.must_equal /(?i-mx:(?:foo) baz (?:bar))/
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should not replace special groups" do
|
171
|
+
/(?:foo) (?<=baz) bar/.decapture.must_equal /(?-mix:(?:foo) (?<=baz) bar)/
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should not replace literal round brackets" do
|
175
|
+
/\(foo\)/.decapture.must_equal /(?-mix:\(foo\))/
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should replace literal backslash followed by literal round brackets" do
|
179
|
+
/\\(foo\\)/.decapture.must_equal /(?-mix:\\(?:foo\\))/
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
158
184
|
context String do
|
159
185
|
describe :indent do
|
160
186
|
it "must indent single line string" do
|
@@ -167,77 +193,137 @@ describe AIXM::Refinements do
|
|
167
193
|
end
|
168
194
|
end
|
169
195
|
|
196
|
+
describe :payload_hash do
|
197
|
+
subject do
|
198
|
+
<<~END
|
199
|
+
<?xml version="1.0" encoding="utf-8"?>
|
200
|
+
<OFMX-Snapshot region="LF">
|
201
|
+
<Ser type="essential" active="true">
|
202
|
+
<SerUid>
|
203
|
+
<UniUid>
|
204
|
+
<txtName>STRASBOURG APP</txtName>
|
205
|
+
</UniUid>
|
206
|
+
<codeType version="1" subversion="2">APP</codeType>
|
207
|
+
<noSeq>1</noSeq>
|
208
|
+
</SerUid>
|
209
|
+
<Stt priority="1">
|
210
|
+
<codeWorkHr>H24</codeWorkHr>
|
211
|
+
</Stt>
|
212
|
+
<Stt priority="2">
|
213
|
+
<codeWorkHr>HX</codeWorkHr>
|
214
|
+
</Stt>
|
215
|
+
<txtRmk>aka STRASBOURG approche</txtRmk>
|
216
|
+
</Ser>
|
217
|
+
</OFMX-Snapshot>
|
218
|
+
END
|
219
|
+
end
|
220
|
+
|
221
|
+
it "must calculate the hash" do
|
222
|
+
subject.payload_hash(region: 'LF', element: 'Ser').must_equal "269b1f18-cabe-3c9e-1d71-48a7414a4cb9"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
170
226
|
describe :to_dd do
|
171
227
|
it "must convert +6.2 DMS to DD" do
|
228
|
+
%q(12°34'56.78"N).to_dd.must_equal 12.58243888888889
|
172
229
|
%q(12°34'56.78").to_dd.must_equal 12.58243888888889
|
230
|
+
%q(12°34'56.78'').to_dd.must_equal 12.58243888888889
|
173
231
|
%q(12 34 56.78).to_dd.must_equal 12.58243888888889
|
174
|
-
%q(123456.
|
232
|
+
%q(123456.78N).to_dd.must_equal 12.58243888888889
|
175
233
|
end
|
176
234
|
|
177
235
|
it "must convert -6.2 DMS to DD" do
|
236
|
+
%q(12°34'56.78"S).to_dd.must_equal(-12.58243888888889)
|
178
237
|
%q(-12°34'56.78").to_dd.must_equal(-12.58243888888889)
|
179
238
|
%q(-12 34 56.78).to_dd.must_equal(-12.58243888888889)
|
180
|
-
%q(
|
239
|
+
%q(123456.78S).to_dd.must_equal(-12.58243888888889)
|
181
240
|
end
|
182
241
|
|
183
242
|
it "must convert +7.2 DMS to DD" do
|
243
|
+
%q(111°22'33.44"N).to_dd.must_equal 111.37595555555555
|
184
244
|
%q(111°22'33.44").to_dd.must_equal 111.37595555555555
|
185
245
|
%q(111 22 33.44).to_dd.must_equal 111.37595555555555
|
186
|
-
%q(1112233.
|
246
|
+
%q(1112233.44N).to_dd.must_equal 111.37595555555555
|
187
247
|
end
|
188
248
|
|
189
249
|
it "must convert -7.2 DMS to DD" do
|
250
|
+
%q(111°22'33.44"S).to_dd.must_equal(-111.37595555555555)
|
190
251
|
%q(-111°22'33.44").to_dd.must_equal(-111.37595555555555)
|
191
252
|
%q(-111 22 33.44).to_dd.must_equal(-111.37595555555555)
|
192
|
-
%q(
|
253
|
+
%q(1112233.44S).to_dd.must_equal(-111.37595555555555)
|
193
254
|
end
|
194
255
|
|
195
256
|
it "must convert +6.1 DMS to DD" do
|
257
|
+
%q(12°34'56.7"N).to_dd.must_equal 12.582416666666667
|
196
258
|
%q(12°34'56.7").to_dd.must_equal 12.582416666666667
|
197
259
|
%q(12 34 56.7).to_dd.must_equal 12.582416666666667
|
198
|
-
%q(123456.
|
260
|
+
%q(123456.7N).to_dd.must_equal 12.582416666666667
|
199
261
|
end
|
200
262
|
|
201
263
|
it "must convert -6.1 DMS to DD" do
|
264
|
+
%q(12°34'56.7"S).to_dd.must_equal(-12.582416666666667)
|
202
265
|
%q(-12°34'56.7").to_dd.must_equal(-12.582416666666667)
|
203
266
|
%q(-12 34 56.7).to_dd.must_equal(-12.582416666666667)
|
204
|
-
%q(
|
267
|
+
%q(123456.7S).to_dd.must_equal(-12.582416666666667)
|
205
268
|
end
|
206
269
|
|
207
270
|
it "must convert +7.1 DMS to DD" do
|
271
|
+
%q(111°22'33.4"N).to_dd.must_equal 111.37594444444444
|
208
272
|
%q(111°22'33.4").to_dd.must_equal 111.37594444444444
|
209
273
|
%q(111 22 33.4).to_dd.must_equal 111.37594444444444
|
210
|
-
%q(1112233.
|
274
|
+
%q(1112233.4N).to_dd.must_equal 111.37594444444444
|
211
275
|
end
|
212
276
|
|
213
|
-
it "must convert
|
277
|
+
it "must convert -7.1 DMS to DD" do
|
278
|
+
%q(111°22'33.4"S).to_dd.must_equal(-111.37594444444444)
|
214
279
|
%q(-111°22'33.4").to_dd.must_equal(-111.37594444444444)
|
215
280
|
%q(-111 22 33.4).to_dd.must_equal(-111.37594444444444)
|
216
|
-
%q(
|
281
|
+
%q(1112233.4S).to_dd.must_equal(-111.37594444444444)
|
217
282
|
end
|
218
283
|
|
219
284
|
it "must convert +6.0 DMS to DD" do
|
285
|
+
%q(12°34'56"N).to_dd.must_equal 12.582222222222223
|
220
286
|
%q(12°34'56").to_dd.must_equal 12.582222222222223
|
221
287
|
%q(12 34 56).to_dd.must_equal 12.582222222222223
|
222
|
-
%q(
|
288
|
+
%q(123456N).to_dd.must_equal 12.582222222222223
|
223
289
|
end
|
224
290
|
|
225
291
|
it "must convert -6.0 DMS to DD" do
|
292
|
+
%q(12°34'56"S).to_dd.must_equal(-12.582222222222223)
|
226
293
|
%q(-12°34'56").to_dd.must_equal(-12.582222222222223)
|
227
294
|
%q(-12 34 56).to_dd.must_equal(-12.582222222222223)
|
228
|
-
%q(
|
295
|
+
%q(123456S).to_dd.must_equal(-12.582222222222223)
|
229
296
|
end
|
230
297
|
|
231
298
|
it "must convert +7.0 DMS to DD" do
|
299
|
+
%q(111°22'33"N).to_dd.must_equal 111.37583333333333
|
232
300
|
%q(111°22'33").to_dd.must_equal 111.37583333333333
|
233
301
|
%q(111 22 33).to_dd.must_equal 111.37583333333333
|
234
|
-
%q(
|
302
|
+
%q(1112233N).to_dd.must_equal 111.37583333333333
|
235
303
|
end
|
236
304
|
|
237
|
-
it "must convert
|
305
|
+
it "must convert -7.0 DMS to DD" do
|
306
|
+
%q(111°22'33"S).to_dd.must_equal(-111.37583333333333)
|
238
307
|
%q(-111°22'33").to_dd.must_equal(-111.37583333333333)
|
239
308
|
%q(-111 22 33).to_dd.must_equal(-111.37583333333333)
|
240
|
-
%q(
|
309
|
+
%q(1112233S).to_dd.must_equal(-111.37583333333333)
|
310
|
+
end
|
311
|
+
|
312
|
+
it "must convert all cardinal directions to DD" do
|
313
|
+
%q(111°22'33.44"N).to_dd.must_equal 111.37595555555555
|
314
|
+
%q(111°22'33.44"E).to_dd.must_equal 111.37595555555555
|
315
|
+
%q(111°22'33.44"S).to_dd.must_equal -111.37595555555555
|
316
|
+
%q(111°22'33.44"W).to_dd.must_equal -111.37595555555555
|
317
|
+
end
|
318
|
+
|
319
|
+
it "must ignore minor typos when converting to DD" do
|
320
|
+
%q(111°22'33,44"N).to_dd.must_equal 111.37595555555555
|
321
|
+
%q(111°22'33.44"n).to_dd.must_equal 111.37595555555555
|
322
|
+
%q(111°22"33.44"N).to_dd.must_equal 111.37595555555555
|
323
|
+
%q(111°22'33.44'N).to_dd.must_equal 111.37595555555555
|
324
|
+
%q(111°22'33.44" N).to_dd.must_equal 111.37595555555555
|
325
|
+
%q(111° 22' 33.44" N).to_dd.must_equal 111.37595555555555
|
326
|
+
%q(-111°22'33.44"S).to_dd.must_equal 111.37595555555555
|
241
327
|
end
|
242
328
|
|
243
329
|
it "must do all possible roundtrip conversions" do
|
@@ -276,5 +362,4 @@ describe AIXM::Refinements do
|
|
276
362
|
end
|
277
363
|
end
|
278
364
|
end
|
279
|
-
|
280
365
|
end
|
data/spec/lib/aixm/z_spec.rb
CHANGED
@@ -81,4 +81,14 @@ describe AIXM::Z do
|
|
81
81
|
{ subject => true }[dupe].must_equal true
|
82
82
|
end
|
83
83
|
end
|
84
|
+
|
85
|
+
describe :zero? do
|
86
|
+
it "returns true for zero height, elevation or altitude" do
|
87
|
+
subject.tap { |s| s.alt = 0 }.must_be :zero?
|
88
|
+
end
|
89
|
+
|
90
|
+
it "returns false for non-zero height, elevation or altitude" do
|
91
|
+
subject.tap { |s| s.alt = 1 }.wont_be :zero?
|
92
|
+
end
|
93
|
+
end
|
84
94
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aixm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Schwyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,6 +155,7 @@ files:
|
|
169
155
|
- Rakefile
|
170
156
|
- aixm.gemspec
|
171
157
|
- lib/aixm.rb
|
158
|
+
- lib/aixm/a.rb
|
172
159
|
- lib/aixm/component.rb
|
173
160
|
- lib/aixm/component/frequency.rb
|
174
161
|
- lib/aixm/component/geometry.rb
|
@@ -179,15 +166,17 @@ files:
|
|
179
166
|
- lib/aixm/component/helipad.rb
|
180
167
|
- lib/aixm/component/layer.rb
|
181
168
|
- lib/aixm/component/runway.rb
|
182
|
-
- lib/aixm/component/
|
169
|
+
- lib/aixm/component/surface.rb
|
183
170
|
- lib/aixm/component/timetable.rb
|
184
171
|
- lib/aixm/component/vertical_limits.rb
|
185
172
|
- lib/aixm/config.rb
|
173
|
+
- lib/aixm/constants.rb
|
186
174
|
- lib/aixm/d.rb
|
187
175
|
- lib/aixm/document.rb
|
188
176
|
- lib/aixm/errors.rb
|
189
177
|
- lib/aixm/f.rb
|
190
178
|
- lib/aixm/feature.rb
|
179
|
+
- lib/aixm/feature/address.rb
|
191
180
|
- lib/aixm/feature/airport.rb
|
192
181
|
- lib/aixm/feature/airspace.rb
|
193
182
|
- lib/aixm/feature/navigational_aid.rb
|
@@ -200,8 +189,8 @@ files:
|
|
200
189
|
- lib/aixm/feature/obstacle.rb
|
201
190
|
- lib/aixm/feature/obstacle_group.rb
|
202
191
|
- lib/aixm/feature/organisation.rb
|
192
|
+
- lib/aixm/feature/service.rb
|
203
193
|
- lib/aixm/feature/unit.rb
|
204
|
-
- lib/aixm/h.rb
|
205
194
|
- lib/aixm/refinements.rb
|
206
195
|
- lib/aixm/shortcuts.rb
|
207
196
|
- lib/aixm/version.rb
|
@@ -216,6 +205,7 @@ files:
|
|
216
205
|
- schemas/ofmx/0/OFMX-Features.xsd
|
217
206
|
- schemas/ofmx/0/OFMX-Snapshot.xsd
|
218
207
|
- spec/factory.rb
|
208
|
+
- spec/lib/aixm/a_spec.rb
|
219
209
|
- spec/lib/aixm/component/frequency_spec.rb
|
220
210
|
- spec/lib/aixm/component/geometry/arc_spec.rb
|
221
211
|
- spec/lib/aixm/component/geometry/border_spec.rb
|
@@ -225,7 +215,7 @@ files:
|
|
225
215
|
- spec/lib/aixm/component/helipad_spec.rb
|
226
216
|
- spec/lib/aixm/component/layer_spec.rb
|
227
217
|
- spec/lib/aixm/component/runway_spec.rb
|
228
|
-
- spec/lib/aixm/component/
|
218
|
+
- spec/lib/aixm/component/surface_spec.rb
|
229
219
|
- spec/lib/aixm/component/timetable_spec.rb
|
230
220
|
- spec/lib/aixm/component/vertical_limits_spec.rb
|
231
221
|
- spec/lib/aixm/config_spec.rb
|
@@ -233,6 +223,7 @@ files:
|
|
233
223
|
- spec/lib/aixm/document_spec.rb
|
234
224
|
- spec/lib/aixm/errors_spec.rb
|
235
225
|
- spec/lib/aixm/f_spec.rb
|
226
|
+
- spec/lib/aixm/feature/address_spec.rb
|
236
227
|
- spec/lib/aixm/feature/airport_spec.rb
|
237
228
|
- spec/lib/aixm/feature/airspace_spec.rb
|
238
229
|
- spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb
|
@@ -245,9 +236,9 @@ files:
|
|
245
236
|
- spec/lib/aixm/feature/obstacle_group_spec.rb
|
246
237
|
- spec/lib/aixm/feature/obstacle_spec.rb
|
247
238
|
- spec/lib/aixm/feature/organisation_spec.rb
|
239
|
+
- spec/lib/aixm/feature/service_spec.rb
|
248
240
|
- spec/lib/aixm/feature/unit_spec.rb
|
249
241
|
- spec/lib/aixm/feature_spec.rb
|
250
|
-
- spec/lib/aixm/h_spec.rb
|
251
242
|
- spec/lib/aixm/refinements_spec.rb
|
252
243
|
- spec/lib/aixm/version_spec.rb
|
253
244
|
- spec/lib/aixm/xy_spec.rb
|
@@ -272,20 +263,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
272
263
|
requirements:
|
273
264
|
- - ">="
|
274
265
|
- !ruby/object:Gem::Version
|
275
|
-
version: '2.
|
266
|
+
version: '2.6'
|
276
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
277
268
|
requirements:
|
278
269
|
- - ">="
|
279
270
|
- !ruby/object:Gem::Version
|
280
271
|
version: '0'
|
281
272
|
requirements: []
|
282
|
-
|
283
|
-
rubygems_version: 2.7.6
|
273
|
+
rubygems_version: 3.0.3
|
284
274
|
signing_key:
|
285
275
|
specification_version: 4
|
286
276
|
summary: Aeronautical Information Exchange Model (AIXM 4.5).
|
287
277
|
test_files:
|
288
278
|
- spec/factory.rb
|
279
|
+
- spec/lib/aixm/a_spec.rb
|
289
280
|
- spec/lib/aixm/component/frequency_spec.rb
|
290
281
|
- spec/lib/aixm/component/geometry/arc_spec.rb
|
291
282
|
- spec/lib/aixm/component/geometry/border_spec.rb
|
@@ -295,7 +286,7 @@ test_files:
|
|
295
286
|
- spec/lib/aixm/component/helipad_spec.rb
|
296
287
|
- spec/lib/aixm/component/layer_spec.rb
|
297
288
|
- spec/lib/aixm/component/runway_spec.rb
|
298
|
-
- spec/lib/aixm/component/
|
289
|
+
- spec/lib/aixm/component/surface_spec.rb
|
299
290
|
- spec/lib/aixm/component/timetable_spec.rb
|
300
291
|
- spec/lib/aixm/component/vertical_limits_spec.rb
|
301
292
|
- spec/lib/aixm/config_spec.rb
|
@@ -303,6 +294,7 @@ test_files:
|
|
303
294
|
- spec/lib/aixm/document_spec.rb
|
304
295
|
- spec/lib/aixm/errors_spec.rb
|
305
296
|
- spec/lib/aixm/f_spec.rb
|
297
|
+
- spec/lib/aixm/feature/address_spec.rb
|
306
298
|
- spec/lib/aixm/feature/airport_spec.rb
|
307
299
|
- spec/lib/aixm/feature/airspace_spec.rb
|
308
300
|
- spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb
|
@@ -315,9 +307,9 @@ test_files:
|
|
315
307
|
- spec/lib/aixm/feature/obstacle_group_spec.rb
|
316
308
|
- spec/lib/aixm/feature/obstacle_spec.rb
|
317
309
|
- spec/lib/aixm/feature/organisation_spec.rb
|
310
|
+
- spec/lib/aixm/feature/service_spec.rb
|
318
311
|
- spec/lib/aixm/feature/unit_spec.rb
|
319
312
|
- spec/lib/aixm/feature_spec.rb
|
320
|
-
- spec/lib/aixm/h_spec.rb
|
321
313
|
- spec/lib/aixm/refinements_spec.rb
|
322
314
|
- spec/lib/aixm/version_spec.rb
|
323
315
|
- spec/lib/aixm/xy_spec.rb
|
data/lib/aixm/h.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
using AIXM::Refinements
|
2
|
-
|
3
|
-
module AIXM
|
4
|
-
|
5
|
-
# Heading of an aircraft or runway
|
6
|
-
#
|
7
|
-
# @example
|
8
|
-
# AIXM.h(12)
|
9
|
-
# AIXM.h('12')
|
10
|
-
# AIXM.h('34L')
|
11
|
-
# AIXM.h('05X')
|
12
|
-
class H
|
13
|
-
SUFFIX_INVERSIONS = {
|
14
|
-
R: :L,
|
15
|
-
L: :R
|
16
|
-
}.freeze
|
17
|
-
|
18
|
-
# @return [Integer] heading
|
19
|
-
attr_reader :deg
|
20
|
-
|
21
|
-
# @return [Symbol, nil] suffix
|
22
|
-
attr_reader :suffix
|
23
|
-
|
24
|
-
def initialize(deg_and_suffix)
|
25
|
-
fail(ArgumentError, "invalid heading") unless deg_and_suffix.to_s =~ /\A(\d+)([A-Z]+)?\z/
|
26
|
-
self.deg, self.suffix = $1.to_i, $2
|
27
|
-
end
|
28
|
-
|
29
|
-
# @return [String]
|
30
|
-
def inspect
|
31
|
-
%Q(#<#{self.class} #{to_s}>)
|
32
|
-
end
|
33
|
-
|
34
|
-
# @return [String] human readable representation (e.g. "05" or "34L")
|
35
|
-
def to_s
|
36
|
-
[('%02d' % deg), suffix].map(&:to_s).join
|
37
|
-
end
|
38
|
-
|
39
|
-
def deg=(value)
|
40
|
-
fail(ArgumentError, "invalid deg") unless value.between?(1, 36)
|
41
|
-
@deg = value
|
42
|
-
end
|
43
|
-
|
44
|
-
def suffix=(value)
|
45
|
-
fail(ArgumentError, "invalid suffix") unless value.nil? || value.to_s =~ /\A[A-Z]+\z/
|
46
|
-
@suffix = value&.to_s&.to_sym
|
47
|
-
end
|
48
|
-
|
49
|
-
# Invert a heading by 180 degrees
|
50
|
-
#
|
51
|
-
# @example
|
52
|
-
# AIXM.h('12').invert # => AIXM.h(30)
|
53
|
-
# AIXM.h('34L').invert # => AIXM.h(16, 'R')
|
54
|
-
# AIXM.h('33X').invert # => AIXM.h(17, 'bravo')
|
55
|
-
#
|
56
|
-
# @return [AIXM::H] inverted heading
|
57
|
-
def invert
|
58
|
-
AIXM.h([(((deg + 17) % 36) + 1), SUFFIX_INVERSIONS.fetch(suffix, suffix)].join)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Check whether +other+ heading is the inverse
|
62
|
-
#
|
63
|
-
# @example
|
64
|
-
# AIXM.h('12').inverse_of? AIXM.h('30') # => true
|
65
|
-
# AIXM.h('34L').inverse_of? AIXM.h('16R') # => true
|
66
|
-
# AIXM.h('16R').inverse_of? AIXM.h('16L') # => false
|
67
|
-
#
|
68
|
-
# @return [AIXM::H] inverted heading
|
69
|
-
def inverse_of?(other)
|
70
|
-
invert == other
|
71
|
-
end
|
72
|
-
|
73
|
-
# @see Object#==
|
74
|
-
# @return [Boolean]
|
75
|
-
def ==(other)
|
76
|
-
self.class === other && deg == other.deg && suffix == other.suffix
|
77
|
-
end
|
78
|
-
alias_method :eql?, :==
|
79
|
-
|
80
|
-
# @see Object#hash
|
81
|
-
# @return [Integer]
|
82
|
-
def hash
|
83
|
-
to_s.hash
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|