aixm 0.2.3 → 0.3.0

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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.ruby-version +1 -1
  4. data/.yardopts +3 -0
  5. data/CHANGELOG.md +34 -14
  6. data/Guardfile +1 -0
  7. data/README.md +64 -257
  8. data/lib/aixm.rb +16 -7
  9. data/lib/aixm/component.rb +6 -0
  10. data/lib/aixm/component/frequency.rb +135 -0
  11. data/lib/aixm/component/geometry.rb +34 -23
  12. data/lib/aixm/component/geometry/arc.rb +37 -22
  13. data/lib/aixm/component/geometry/border.rb +29 -20
  14. data/lib/aixm/component/geometry/circle.rb +39 -22
  15. data/lib/aixm/component/geometry/point.rb +29 -13
  16. data/lib/aixm/component/helipad.rb +154 -0
  17. data/lib/aixm/component/layer.rb +91 -0
  18. data/lib/aixm/component/runway.rb +294 -0
  19. data/lib/aixm/component/service.rb +170 -0
  20. data/lib/aixm/component/timetable.rb +65 -0
  21. data/lib/aixm/component/vertical_limits.rb +65 -29
  22. data/lib/aixm/config.rb +87 -0
  23. data/lib/aixm/document.rb +66 -42
  24. data/lib/aixm/errors.rb +11 -0
  25. data/lib/aixm/f.rb +34 -20
  26. data/lib/aixm/feature.rb +38 -0
  27. data/lib/aixm/feature/airport.rb +473 -0
  28. data/lib/aixm/feature/airspace.rb +145 -92
  29. data/lib/aixm/feature/navigational_aid.rb +94 -0
  30. data/lib/aixm/feature/navigational_aid/designated_point.rb +50 -54
  31. data/lib/aixm/feature/navigational_aid/dme.rb +48 -40
  32. data/lib/aixm/feature/navigational_aid/marker.rb +55 -45
  33. data/lib/aixm/feature/navigational_aid/ndb.rb +54 -50
  34. data/lib/aixm/feature/navigational_aid/tacan.rb +38 -31
  35. data/lib/aixm/feature/navigational_aid/vor.rb +84 -76
  36. data/lib/aixm/feature/organisation.rb +97 -0
  37. data/lib/aixm/feature/unit.rb +152 -0
  38. data/lib/aixm/refinements.rb +132 -47
  39. data/lib/aixm/shortcuts.rb +11 -6
  40. data/lib/aixm/version.rb +1 -1
  41. data/lib/aixm/xy.rb +64 -20
  42. data/lib/aixm/z.rb +51 -22
  43. data/{lib/aixm/schemas → schemas/aixm}/4.5/AIXM-DataTypes.xsd +0 -0
  44. data/{lib/aixm/schemas → schemas/aixm}/4.5/AIXM-Features.xsd +0 -0
  45. data/{lib/aixm/schemas → schemas/aixm}/4.5/AIXM-Snapshot.xsd +0 -0
  46. data/schemas/ofmx/0/OFMX-DataTypes.xsd +5077 -0
  47. data/schemas/ofmx/0/OFMX-Features.xsd +9955 -0
  48. data/schemas/ofmx/0/OFMX-Snapshot.xsd +217 -0
  49. data/spec/factory.rb +209 -33
  50. data/spec/lib/aixm/component/frequency_spec.rb +75 -0
  51. data/spec/lib/aixm/component/geometry/arc_spec.rb +28 -22
  52. data/spec/lib/aixm/component/geometry/border_spec.rb +23 -20
  53. data/spec/lib/aixm/component/geometry/circle_spec.rb +31 -22
  54. data/spec/lib/aixm/component/geometry/point_spec.rb +11 -14
  55. data/spec/lib/aixm/component/geometry_spec.rb +150 -69
  56. data/spec/lib/aixm/component/helipad_spec.rb +136 -0
  57. data/spec/lib/aixm/component/layer_spec.rb +110 -0
  58. data/spec/lib/aixm/component/runway_spec.rb +402 -0
  59. data/spec/lib/aixm/component/service_spec.rb +61 -0
  60. data/spec/lib/aixm/component/timetable_spec.rb +49 -0
  61. data/spec/lib/aixm/component/vertical_limits_spec.rb +39 -20
  62. data/spec/lib/aixm/config_spec.rb +41 -0
  63. data/spec/lib/aixm/document_spec.rb +637 -147
  64. data/spec/lib/aixm/errors_spec.rb +14 -0
  65. data/spec/lib/aixm/f_spec.rb +17 -10
  66. data/spec/lib/aixm/feature/airport_spec.rb +546 -0
  67. data/spec/lib/aixm/feature/airspace_spec.rb +349 -226
  68. data/spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb +47 -36
  69. data/spec/lib/aixm/feature/navigational_aid/dme_spec.rb +61 -36
  70. data/spec/lib/aixm/feature/navigational_aid/marker_spec.rb +61 -113
  71. data/spec/lib/aixm/feature/navigational_aid/ndb_spec.rb +65 -79
  72. data/spec/lib/aixm/feature/navigational_aid/tacan_spec.rb +57 -36
  73. data/spec/lib/aixm/feature/navigational_aid/vor_spec.rb +86 -112
  74. data/spec/lib/aixm/feature/navigational_aid_spec.rb +52 -0
  75. data/spec/lib/aixm/feature/organisation_spec.rb +77 -0
  76. data/spec/lib/aixm/feature/unit_spec.rb +227 -0
  77. data/spec/lib/aixm/feature_spec.rb +58 -0
  78. data/spec/lib/aixm/refinements_spec.rb +187 -178
  79. data/spec/lib/aixm/xy_spec.rb +45 -34
  80. data/spec/lib/aixm/z_spec.rb +19 -21
  81. data/spec/macros/organisation.rb +11 -0
  82. data/spec/macros/remarks.rb +12 -0
  83. data/spec/macros/timetable.rb +11 -0
  84. data/spec/macros/xy.rb +11 -0
  85. data/spec/macros/z_qnh.rb +11 -0
  86. data/spec/spec_helper.rb +26 -0
  87. metadata +60 -19
  88. data/lib/aixm/base.rb +0 -10
  89. data/lib/aixm/component/base.rb +0 -6
  90. data/lib/aixm/component/class_layer.rb +0 -46
  91. data/lib/aixm/component/geometry/base.rb +0 -8
  92. data/lib/aixm/component/schedule.rb +0 -43
  93. data/lib/aixm/feature/base.rb +0 -6
  94. data/lib/aixm/feature/navigational_aid/base.rb +0 -79
  95. data/spec/lib/aixm/component/class_layer_spec.rb +0 -74
  96. data/spec/lib/aixm/component/schedule_spec.rb +0 -33
  97. data/spec/lib/aixm/feature/navigational_aid/base_spec.rb +0 -41
@@ -0,0 +1,14 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe AIXM::GeometryError do
4
+ it "must be defined" do
5
+ AIXM::GeometryError.wont_be_nil
6
+ end
7
+ end
8
+
9
+
10
+ describe AIXM::LayerError do
11
+ it "must be defined" do
12
+ AIXM::LayerError.wont_be_nil
13
+ end
14
+ end
@@ -1,21 +1,27 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
3
  describe AIXM::F do
4
- describe :initialize do
5
- it "must parse valid unit" do
6
- subject = AIXM.f(123.35, :mhz)
7
- subject.freq.must_equal 123.35
8
- subject.unit.must_equal :mhz
4
+ subject do
5
+ AIXM::Factory.f
6
+ end
7
+
8
+ describe :freq= do
9
+ it "fails on invalid values" do
10
+ [:foobar].wont_be_written_to subject, :freq
9
11
  end
10
12
 
11
- it "won't parse invalid unit" do
12
- -> { AIXM.f(123.35, :foo) }.must_raise ArgumentError
13
+ it "converts Numeric to Float" do
14
+ subject.tap { |s| s.freq = 5 }.freq.must_equal 5.0
13
15
  end
14
16
  end
15
17
 
16
- describe :to_digest do
17
- it "must return digest of payload" do
18
- AIXM.f(111, :mhz).to_digest.must_equal 779608518
18
+ describe :unit= do
19
+ it "fails on invalid values" do
20
+ [:foobar, 123].wont_be_written_to subject, :unit
21
+ end
22
+
23
+ it "symbolizes and downcases values" do
24
+ subject.tap { |s| s.unit = "MHz" }.unit.must_equal :mhz
19
25
  end
20
26
  end
21
27
 
@@ -55,4 +61,5 @@ describe AIXM::F do
55
61
  subject.between?(90, 95, :mhz).must_equal false
56
62
  end
57
63
  end
64
+
58
65
  end
@@ -0,0 +1,546 @@
1
+ require_relative '../../../spec_helper'
2
+
3
+ describe AIXM::Feature::Airport do
4
+ subject do
5
+ AIXM::Factory.airport
6
+ end
7
+
8
+ describe :initialize do
9
+ it "sets defaults" do
10
+ subject = AIXM::Feature::Airport.new(
11
+ organisation: AIXM::Factory.organisation,
12
+ code: 'LFNT',
13
+ name: 'Avignon-Pujaut',
14
+ xy: AIXM.xy(lat: %q(43°59'46"N), long: %q(004°45'16"E))
15
+ )
16
+ subject.runways.must_equal []
17
+ subject.helipads.must_equal []
18
+ subject.usage_limitations.must_equal []
19
+ end
20
+ end
21
+
22
+ describe :organisation= do
23
+ it "fails on invalid values" do
24
+ [nil, :foobar].wont_be_written_to subject, :organisation
25
+ end
26
+ end
27
+
28
+ describe :code= do
29
+ it "fails on invalid values" do
30
+ [nil, 'A', 'AB', 'ABCDE', 'AB12345'].wont_be_written_to subject, :code
31
+ end
32
+
33
+ it "upcases valid values" do
34
+ subject.tap { |s| s.code = 'lfnt' }.code.must_equal 'LFNT'
35
+ end
36
+ end
37
+
38
+ describe :name= do
39
+ it "fails on invalid values" do
40
+ [nil, 123].wont_be_written_to subject, :name
41
+ end
42
+
43
+ it "upcases and transcodes valid values" do
44
+ subject.tap { |s| s.name = 'Nîmes-Alès' }.name.must_equal 'NIMES-ALES'
45
+ end
46
+ end
47
+
48
+ describe :gps= do
49
+ it "fails on invalid values" do
50
+ [:foobar, 123].wont_be_written_to subject, :gps
51
+ end
52
+
53
+ it "accepts nil value" do
54
+ [nil].must_be_written_to subject, :gps
55
+ end
56
+
57
+ it "upcases valid values" do
58
+ subject.tap { |s| s.gps = 'Ebdeurne' }.gps.must_equal 'EBDEURNE'
59
+ end
60
+ end
61
+
62
+ describe :type= do
63
+ it "fails on invalid values" do
64
+ [nil, :foobar].wont_be_written_to subject, :type
65
+ end
66
+
67
+ it "fails on values derived from runways and helipads" do
68
+ [:aerodrome, :heliport, :aerodrome_and_heliport].wont_be_written_to subject, :type
69
+ end
70
+
71
+ it "looks up valid values" do
72
+ subject.tap { |s| s.type = :landing_site }.type.must_equal :landing_site
73
+ subject.tap { |s| s.type = :LS }.type.must_equal :landing_site
74
+ end
75
+
76
+ it "derives values from runways and helipads" do
77
+ subject.type.must_equal :aerodrome_and_heliport
78
+ end
79
+ end
80
+
81
+ describe :xy= do
82
+ macro :xy
83
+
84
+ it "fails on nil values" do
85
+ [nil].wont_be_written_to subject, :xy
86
+ end
87
+ end
88
+
89
+ describe :z= do
90
+ macro :z_qnh
91
+
92
+ it "accepts nil value" do
93
+ [nil].must_be_written_to subject, :z
94
+ end
95
+ end
96
+
97
+ describe :declination= do
98
+ it "fails on invalid values" do
99
+ [:foobar, false].wont_be_written_to subject, :declination
100
+ end
101
+
102
+ it "accepts nil value" do
103
+ [nil].must_be_written_to subject, :declination
104
+ end
105
+
106
+ it "converts valid values to Float" do
107
+ subject.tap { |s| s.declination = 10 }.declination.must_equal 10.0
108
+ subject.tap { |s| s.declination = 20.0 }.declination.must_equal 20.0
109
+ end
110
+ end
111
+
112
+ describe :transition_z= do
113
+ it "fails on invalid values" do
114
+ [123, AIXM.z(123, :qfe)].wont_be_written_to subject, :transition_z
115
+ end
116
+
117
+ it "accepts valid values" do
118
+ [nil, AIXM.z(123, :qnh)].must_be_written_to subject, :transition_z
119
+ end
120
+ end
121
+
122
+ describe :timetable= do
123
+ macro :timetable
124
+ end
125
+
126
+ describe :remarks= do
127
+ macro :remarks
128
+ end
129
+
130
+ describe :add_runway do
131
+ it "fails on invalid arguments" do
132
+ -> { subject.add_runway nil }.must_raise ArgumentError
133
+ end
134
+
135
+ it "adds runway to the array" do
136
+ count = subject.runways.count
137
+ subject.add_runway(AIXM.runway(name: '10'))
138
+ subject.runways.count.must_equal count + 1
139
+ end
140
+ end
141
+
142
+ describe :add_helipad do
143
+ it "fails on invalid arguments" do
144
+ -> { subject.add_helipad nil }.must_raise ArgumentError
145
+ end
146
+
147
+ it "adds helipad to the array" do
148
+ count = subject.helipads.count
149
+ subject.add_helipad(AIXM.helipad(name: 'H2'))
150
+ subject.helipads.count.must_equal count + 1
151
+ end
152
+ end
153
+
154
+ describe :add_usage_limitation do
155
+ it "fails on invalid arguments" do
156
+ -> { subject.add_usage_limitation(:foobar) }.must_raise ArgumentError
157
+ end
158
+
159
+ context "without block" do
160
+ it "accepts simple limitation" do
161
+ count = subject.usage_limitations.count
162
+ subject.add_usage_limitation(:permitted)
163
+ subject.usage_limitations.count.must_equal count + 1
164
+ subject.usage_limitations.last.type.must_equal :permitted
165
+ end
166
+ end
167
+
168
+ context "with block" do
169
+ it "accepts complex limitation" do
170
+ count = subject.usage_limitations.count
171
+ subject.add_usage_limitation(:permitted) do |permitted|
172
+ permitted.add_condition { |c| c.aircraft = :glider }
173
+ permitted.add_condition { |c| c.rule = :ifr }
174
+ end
175
+ subject.usage_limitations.count.must_equal count + 1
176
+ subject.usage_limitations.last.conditions.count.must_equal 2
177
+ end
178
+ end
179
+ end
180
+
181
+ describe :to_xml do
182
+ it "builds correct complete OFMX" do
183
+ AIXM.ofmx!
184
+ subject.to_xml.must_equal <<~END
185
+ <!-- Airport: LFNT AVIGNON-PUJAUT -->
186
+ <Ahp source="LF|GEN|0.0 FACTORY|0|0">
187
+ <AhpUid region="LF">
188
+ <codeId>LFNT</codeId>
189
+ </AhpUid>
190
+ <OrgUid region="LF">
191
+ <txtName>FRANCE</txtName>
192
+ </OrgUid>
193
+ <txtName>AVIGNON-PUJAUT</txtName>
194
+ <codeIcao>LFNT</codeIcao>
195
+ <codeGps>LFPUJAUT</codeGps>
196
+ <codeType>AH</codeType>
197
+ <geoLat>43.99611111N</geoLat>
198
+ <geoLong>004.75444444E</geoLong>
199
+ <codeDatum>WGE</codeDatum>
200
+ <valElev>146</valElev>
201
+ <uomDistVer>FT</uomDistVer>
202
+ <valMagVar>1.08</valMagVar>
203
+ <valTransitionAlt>10000</valTransitionAlt>
204
+ <uomTransitionAlt>FT</uomTransitionAlt>
205
+ <txtRmk>Restricted access</txtRmk>
206
+ </Ahp>
207
+ <Rwy>
208
+ <RwyUid>
209
+ <AhpUid region="LF">
210
+ <codeId>LFNT</codeId>
211
+ </AhpUid>
212
+ <txtDesig>16L/34R</txtDesig>
213
+ </RwyUid>
214
+ <valLen>650</valLen>
215
+ <valWid>80</valWid>
216
+ <uomDimRwy>M</uomDimRwy>
217
+ <codeComposition>GRADE</codeComposition>
218
+ <codeSts>CLSD</codeSts>
219
+ <txtRmk>Markings eroded</txtRmk>
220
+ </Rwy>
221
+ <Rdn>
222
+ <RdnUid>
223
+ <RwyUid>
224
+ <AhpUid region="LF">
225
+ <codeId>LFNT</codeId>
226
+ </AhpUid>
227
+ <txtDesig>16L/34R</txtDesig>
228
+ </RwyUid>
229
+ <txtDesig>16L</txtDesig>
230
+ </RdnUid>
231
+ <geoLat>44.00211944N</geoLat>
232
+ <geoLong>004.75216944E</geoLong>
233
+ <valTrueBrg>165</valTrueBrg>
234
+ <valMagBrg>166</valMagBrg>
235
+ <valElevTdz>147</valElevTdz>
236
+ <uomElevTdz>FT</uomElevTdz>
237
+ <txtRmk>forth remarks</txtRmk>
238
+ </Rdn>
239
+ <Rdd>
240
+ <RddUid>
241
+ <RdnUid>
242
+ <RwyUid>
243
+ <AhpUid region="LF">
244
+ <codeId>LFNT</codeId>
245
+ </AhpUid>
246
+ <txtDesig>16L/34R</txtDesig>
247
+ </RwyUid>
248
+ <txtDesig>16L</txtDesig>
249
+ </RdnUid>
250
+ <codeType>DPLM</codeType>
251
+ <codeDayPeriod>A</codeDayPeriod>
252
+ </RddUid>
253
+ <valDist>131</valDist>
254
+ <uomDist>M</uomDist>
255
+ <txtRmk>forth remarks</txtRmk>
256
+ </Rdd>
257
+ <Rdn>
258
+ <RdnUid>
259
+ <RwyUid>
260
+ <AhpUid region="LF">
261
+ <codeId>LFNT</codeId>
262
+ </AhpUid>
263
+ <txtDesig>16L/34R</txtDesig>
264
+ </RwyUid>
265
+ <txtDesig>34R</txtDesig>
266
+ </RdnUid>
267
+ <geoLat>43.99036389N</geoLat>
268
+ <geoLong>004.75645556E</geoLong>
269
+ <valTrueBrg>345</valTrueBrg>
270
+ <valMagBrg>346</valMagBrg>
271
+ <txtRmk>back remarks</txtRmk>
272
+ </Rdn>
273
+ <Rdd>
274
+ <RddUid>
275
+ <RdnUid>
276
+ <RwyUid>
277
+ <AhpUid region="LF">
278
+ <codeId>LFNT</codeId>
279
+ </AhpUid>
280
+ <txtDesig>16L/34R</txtDesig>
281
+ </RwyUid>
282
+ <txtDesig>34R</txtDesig>
283
+ </RdnUid>
284
+ <codeType>DPLM</codeType>
285
+ <codeDayPeriod>A</codeDayPeriod>
286
+ </RddUid>
287
+ <valDist>209</valDist>
288
+ <uomDist>M</uomDist>
289
+ <txtRmk>back remarks</txtRmk>
290
+ </Rdd>
291
+ <Tla>
292
+ <TlaUid>
293
+ <AhpUid region=\"LF\">
294
+ <codeId>LFNT</codeId>
295
+ </AhpUid>
296
+ <txtDesig>H1</txtDesig>
297
+ </TlaUid>
298
+ <geoLat>43.99915000N</geoLat>
299
+ <geoLong>004.75154444E</geoLong>
300
+ <codeDatum>WGE</codeDatum>
301
+ <valElev>141</valElev>
302
+ <uomDistVer>FT</uomDistVer>
303
+ <valLen>20</valLen>
304
+ <valWid>20</valWid>
305
+ <uomDim>M</uomDim>
306
+ <codeComposition>GRASS</codeComposition>
307
+ <codeSts>OTHER</codeSts>
308
+ <txtRmk>Authorizaton by AD operator required</txtRmk>
309
+ </Tla>
310
+ <Ahu>
311
+ <AhuUid>
312
+ <AhpUid region="LF">
313
+ <codeId>LFNT</codeId>
314
+ </AhpUid>
315
+ </AhuUid>
316
+ <UsageLimitation>
317
+ <codeUsageLimitation>PERMIT</codeUsageLimitation>
318
+ </UsageLimitation>
319
+ <UsageLimitation>
320
+ <codeUsageLimitation>RESERV</codeUsageLimitation>
321
+ <UsageCondition>
322
+ <AircraftClass>
323
+ <codeType>E</codeType>
324
+ </AircraftClass>
325
+ </UsageCondition>
326
+ <UsageCondition>
327
+ <FlightClass>
328
+ <codeOrigin>INTL</codeOrigin>
329
+ </FlightClass>
330
+ </UsageCondition>
331
+ <Timetable>
332
+ <codeWorkHr>H24</codeWorkHr>
333
+ </Timetable>
334
+ <txtRmk>reservation remarks</txtRmk>
335
+ </UsageLimitation>
336
+ </Ahu>
337
+ END
338
+ end
339
+
340
+ it "builds correct minimal OFMX" do
341
+ AIXM.ofmx!
342
+ subject.z = subject.declination = subject.transition_z = subject.remarks = nil
343
+ subject.instance_variable_set(:'@runways', [])
344
+ subject.instance_variable_set(:'@helipads', [])
345
+ subject.instance_variable_set(:'@usage_limitations', [])
346
+ subject.to_xml.must_equal <<~END
347
+ <!-- Airport: LFNT AVIGNON-PUJAUT -->
348
+ <Ahp source="LF|GEN|0.0 FACTORY|0|0">
349
+ <AhpUid region="LF">
350
+ <codeId>LFNT</codeId>
351
+ </AhpUid>
352
+ <OrgUid region="LF">
353
+ <txtName>FRANCE</txtName>
354
+ </OrgUid>
355
+ <txtName>AVIGNON-PUJAUT</txtName>
356
+ <codeIcao>LFNT</codeIcao>
357
+ <codeGps>LFPUJAUT</codeGps>
358
+ <geoLat>43.99611111N</geoLat>
359
+ <geoLong>004.75444444E</geoLong>
360
+ <codeDatum>WGE</codeDatum>
361
+ </Ahp>
362
+ END
363
+ end
364
+ end
365
+ end
366
+
367
+ describe AIXM::Feature::Airport::UsageLimitation do
368
+ subject do
369
+ AIXM::Factory.airport.usage_limitations.first
370
+ end
371
+
372
+ describe :initialize do
373
+ it "sets defaults" do
374
+ subject.conditions.must_equal []
375
+ end
376
+ end
377
+
378
+ describe :type= do
379
+ it "fails on invalid values" do
380
+ [nil, :foobar].wont_be_written_to subject, :type
381
+ end
382
+
383
+ it "looks up valid values" do
384
+ subject.tap { |s| s.type = :permitted }.type.must_equal :permitted
385
+ subject.tap { |s| s.type = :RESERV }.type.must_equal :reservation_required
386
+ end
387
+ end
388
+
389
+ describe :timetable= do
390
+ macro :timetable
391
+ end
392
+
393
+ describe :remarks= do
394
+ macro :remarks
395
+ end
396
+
397
+ describe :xml= do
398
+ it "builds correct complete OFMX" do
399
+ AIXM.ofmx!
400
+ subject = AIXM::Factory.airport.usage_limitations.last
401
+ subject.to_xml.must_equal <<~END
402
+ <UsageLimitation>
403
+ <codeUsageLimitation>RESERV</codeUsageLimitation>
404
+ <UsageCondition>
405
+ <AircraftClass>
406
+ <codeType>E</codeType>
407
+ </AircraftClass>
408
+ </UsageCondition>
409
+ <UsageCondition>
410
+ <FlightClass>
411
+ <codeOrigin>INTL</codeOrigin>
412
+ </FlightClass>
413
+ </UsageCondition>
414
+ <Timetable>
415
+ <codeWorkHr>H24</codeWorkHr>
416
+ </Timetable>
417
+ <txtRmk>reservation remarks</txtRmk>
418
+ </UsageLimitation>
419
+ END
420
+ end
421
+
422
+ it "builds correct minimal OFMX" do
423
+ AIXM.ofmx!
424
+ subject.to_xml.must_equal <<~END
425
+ <UsageLimitation>
426
+ <codeUsageLimitation>PERMIT</codeUsageLimitation>
427
+ </UsageLimitation>
428
+ END
429
+ end
430
+ end
431
+ end
432
+
433
+ describe AIXM::Feature::Airport::UsageLimitation::Condition do
434
+ subject do
435
+ AIXM::Factory.airport.usage_limitations.last.conditions.first
436
+ end
437
+
438
+ describe :aircraft= do
439
+ it "fails on invalid values" do
440
+ [:foobar, 123].wont_be_written_to subject, :aircraft
441
+ end
442
+
443
+ it "accepts nil value" do
444
+ [nil].must_be_written_to subject, :aircraft
445
+ end
446
+
447
+ it "looks up valid values" do
448
+ subject.tap { |s| s.aircraft = :glider }.aircraft.must_equal :glider
449
+ subject.tap { |s| s.aircraft = :H }.aircraft.must_equal :helicopter
450
+ end
451
+ end
452
+
453
+ describe :rule= do
454
+ it "fails on invalid values" do
455
+ [:foobar, 123].wont_be_written_to subject, :rule
456
+ end
457
+
458
+ it "accepts nil value" do
459
+ [nil].must_be_written_to subject, :rule
460
+ end
461
+
462
+ it "looks up valid values" do
463
+ subject.tap { |s| s.rule = :ifr }.rule.must_equal :ifr
464
+ subject.tap { |s| s.rule = :IV }.rule.must_equal :ifr_and_vfr
465
+ end
466
+ end
467
+
468
+ describe :realm= do
469
+ it "fails on invalid values" do
470
+ [:foobar, 123].wont_be_written_to subject, :realm
471
+ end
472
+
473
+ it "accepts nil value" do
474
+ [nil].must_be_written_to subject, :realm
475
+ end
476
+
477
+ it "looks up valid values" do
478
+ subject.tap { |s| s.realm = :civilian }.realm.must_equal :civilian
479
+ subject.tap { |s| s.realm = :MIL }.realm.must_equal :military
480
+ end
481
+ end
482
+
483
+ describe :origin= do
484
+ it "fails on invalid values" do
485
+ [:foobar, 123].wont_be_written_to subject, :origin
486
+ end
487
+
488
+ it "accepts nil value" do
489
+ [nil].must_be_written_to subject, :origin
490
+ end
491
+
492
+ it "looks up valid values" do
493
+ subject.tap { |s| s.origin = :international }.origin.must_equal :international
494
+ subject.tap { |s| s.origin = :NTL }.origin.must_equal :national
495
+ end
496
+ end
497
+
498
+ describe :purpose= do
499
+ it "fails on invalid values" do
500
+ [:foobar, 123].wont_be_written_to subject, :purpose
501
+ end
502
+
503
+ it "accepts nil value" do
504
+ [nil].must_be_written_to subject, :purpose
505
+ end
506
+
507
+ it "looks up valid values" do
508
+ subject.tap { |s| s.purpose = :private }.purpose.must_equal :private
509
+ subject.tap { |s| s.purpose = :TRG }.purpose.must_equal :school_or_training
510
+ end
511
+ end
512
+
513
+ describe :xml= do
514
+ it "builds correct complete OFMX" do
515
+ subject.rule = :vfr
516
+ subject.realm = :military
517
+ subject.origin = :international
518
+ subject.purpose = :school_or_training
519
+ AIXM.ofmx!
520
+ subject.to_xml.must_equal <<~END
521
+ <UsageCondition>
522
+ <AircraftClass>
523
+ <codeType>E</codeType>
524
+ </AircraftClass>
525
+ <FlightClass>
526
+ <codeRule>V</codeRule>
527
+ <codeMil>MIL</codeMil>
528
+ <codeOrigin>INTL</codeOrigin>
529
+ <codePurpose>TRG</codePurpose>
530
+ </FlightClass>
531
+ </UsageCondition>
532
+ END
533
+ end
534
+
535
+ it "builds correct minimal OFMX" do
536
+ AIXM.ofmx!
537
+ subject.to_xml.must_equal <<~END
538
+ <UsageCondition>
539
+ <AircraftClass>
540
+ <codeType>E</codeType>
541
+ </AircraftClass>
542
+ </UsageCondition>
543
+ END
544
+ end
545
+ end
546
+ end