aixm 0.3.7 → 0.3.8

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +26 -0
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +17 -4
  5. data/README.md +23 -5
  6. data/lib/aixm/component/fato.rb +3 -3
  7. data/lib/aixm/component/frequency.rb +1 -1
  8. data/lib/aixm/component/geometry/border.rb +9 -3
  9. data/lib/aixm/component/helipad.rb +1 -1
  10. data/lib/aixm/component/lighting.rb +1 -1
  11. data/lib/aixm/component/runway.rb +4 -7
  12. data/lib/aixm/config.rb +2 -1
  13. data/lib/aixm/document.rb +1 -0
  14. data/lib/aixm/feature/address.rb +1 -1
  15. data/lib/aixm/feature/airport.rb +13 -4
  16. data/lib/aixm/feature/airspace.rb +11 -8
  17. data/lib/aixm/feature/navigational_aid/designated_point.rb +1 -1
  18. data/lib/aixm/feature/navigational_aid/dme.rb +1 -1
  19. data/lib/aixm/feature/navigational_aid/marker.rb +1 -1
  20. data/lib/aixm/feature/navigational_aid/ndb.rb +1 -1
  21. data/lib/aixm/feature/navigational_aid/tacan.rb +1 -1
  22. data/lib/aixm/feature/navigational_aid/vor.rb +1 -1
  23. data/lib/aixm/feature/obstacle.rb +1 -1
  24. data/lib/aixm/feature/obstacle_group.rb +1 -1
  25. data/lib/aixm/feature/organisation.rb +1 -1
  26. data/lib/aixm/feature/service.rb +1 -1
  27. data/lib/aixm/feature/unit.rb +1 -1
  28. data/lib/aixm/refinements.rb +39 -8
  29. data/lib/aixm/version.rb +1 -1
  30. data/rakefile.rb +22 -8
  31. data/spec/lib/aixm/a_spec.rb +55 -55
  32. data/spec/lib/aixm/component/fato_spec.rb +30 -23
  33. data/spec/lib/aixm/component/frequency_spec.rb +12 -13
  34. data/spec/lib/aixm/component/geometry/arc_spec.rb +7 -9
  35. data/spec/lib/aixm/component/geometry/border_spec.rb +8 -3
  36. data/spec/lib/aixm/component/geometry/circle_spec.rb +6 -8
  37. data/spec/lib/aixm/component/geometry/point_spec.rb +2 -4
  38. data/spec/lib/aixm/component/geometry_spec.rb +57 -62
  39. data/spec/lib/aixm/component/helipad_spec.rb +25 -19
  40. data/spec/lib/aixm/component/layer_spec.rb +17 -19
  41. data/spec/lib/aixm/component/lighting_spec.rb +21 -15
  42. data/spec/lib/aixm/component/runway_spec.rb +44 -37
  43. data/spec/lib/aixm/component/surface_spec.rb +24 -24
  44. data/spec/lib/aixm/component/timetable_spec.rb +7 -9
  45. data/spec/lib/aixm/component/vertical_limits_spec.rb +9 -12
  46. data/spec/lib/aixm/config_spec.rb +8 -8
  47. data/spec/lib/aixm/d_spec.rb +28 -28
  48. data/spec/lib/aixm/document_spec.rb +46 -37
  49. data/spec/lib/aixm/errors_spec.rb +2 -2
  50. data/spec/lib/aixm/f_spec.rb +16 -16
  51. data/spec/lib/aixm/feature/address_spec.rb +12 -7
  52. data/spec/lib/aixm/feature/airport_spec.rb +80 -74
  53. data/spec/lib/aixm/feature/airspace_spec.rb +32 -28
  54. data/spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb +16 -11
  55. data/spec/lib/aixm/feature/navigational_aid/dme_spec.rb +22 -16
  56. data/spec/lib/aixm/feature/navigational_aid/marker_spec.rb +13 -7
  57. data/spec/lib/aixm/feature/navigational_aid/ndb_spec.rb +15 -9
  58. data/spec/lib/aixm/feature/navigational_aid/tacan_spec.rb +22 -16
  59. data/spec/lib/aixm/feature/navigational_aid/vor_spec.rb +21 -15
  60. data/spec/lib/aixm/feature/navigational_aid_spec.rb +6 -6
  61. data/spec/lib/aixm/feature/obstacle_group_spec.rb +25 -21
  62. data/spec/lib/aixm/feature/obstacle_spec.rb +47 -42
  63. data/spec/lib/aixm/feature/organisation_spec.rb +16 -10
  64. data/spec/lib/aixm/feature/service_spec.rb +9 -9
  65. data/spec/lib/aixm/feature/unit_spec.rb +21 -13
  66. data/spec/lib/aixm/feature_spec.rb +5 -5
  67. data/spec/lib/aixm/p_spec.rb +37 -37
  68. data/spec/lib/aixm/refinements_spec.rb +164 -115
  69. data/spec/lib/aixm/version_spec.rb +1 -1
  70. data/spec/lib/aixm/w_spec.rb +28 -28
  71. data/spec/lib/aixm/xy_spec.rb +34 -34
  72. data/spec/lib/aixm/z_spec.rb +19 -19
  73. data/spec/macros/marking.rb +3 -3
  74. data/spec/macros/organisation.rb +2 -2
  75. data/spec/macros/remarks.rb +3 -3
  76. data/spec/macros/timetable.rb +2 -2
  77. data/spec/macros/xy.rb +2 -2
  78. data/spec/macros/z_qnh.rb +2 -2
  79. data/spec/spec_helper.rb +7 -0
  80. metadata +3 -3
  81. data/.travis.yml +0 -8
@@ -7,75 +7,75 @@ describe AIXM::Document do
7
7
 
8
8
  describe :initialize do
9
9
  it "sets defaults" do
10
- subject.features.must_equal []
10
+ _(subject.features).must_equal []
11
11
  end
12
12
  end
13
13
 
14
14
  describe :namespace= do
15
15
  it "fails on invalid values" do
16
- ['foobar', :foobar].wont_be_written_to subject, :namespace
16
+ _(['foobar', :foobar]).wont_be_written_to subject, :namespace
17
17
  end
18
18
 
19
19
  it "sets random UUID for nil value" do
20
- subject.tap { |s| s.namespace = nil }.namespace.must_match AIXM::Document::NAMESPACE_RE
20
+ _(subject.tap { |s| s.namespace = nil }.namespace).must_match AIXM::Document::NAMESPACE_RE
21
21
  end
22
22
 
23
23
  it "accepts UUID value" do
24
- [SecureRandom.uuid].must_be_written_to subject, :namespace
24
+ _([SecureRandom.uuid]).must_be_written_to subject, :namespace
25
25
  end
26
26
  end
27
27
 
28
28
  describe :region= do
29
29
  it "fails on invalid values" do
30
- ['x', 'foobar', :foobar].wont_be_written_to subject, :region
30
+ _(['x', 'foobar', :foobar]).wont_be_written_to subject, :region
31
31
  end
32
32
 
33
33
  it "upcases valid values" do
34
- subject.tap { |s| s.region = 'lf' }.region.must_equal 'LF'
34
+ _(subject.tap { |s| s.region = 'lf' }.region).must_equal 'LF'
35
35
  end
36
36
  end
37
37
 
38
38
  describe :created_at= do
39
39
  it "fails on invalid values" do
40
- ['foobar', '2018-01-77'].wont_be_written_to subject, :created_at
40
+ _(['foobar', '2018-01-77']).wont_be_written_to subject, :created_at
41
41
  end
42
42
 
43
43
  it "parses dates and times" do
44
44
  string = '2018-01-01 12:00:00 +0100'
45
- subject.tap { |s| s.created_at = string }.created_at.must_equal Time.parse(string)
45
+ _(subject.tap { |s| s.created_at = string }.created_at).must_equal Time.parse(string)
46
46
  end
47
47
 
48
48
  it "falls back to effective_at first" do
49
49
  subject.effective_at = Time.now
50
50
  subject.created_at = nil
51
- subject.created_at.must_equal subject.effective_at
51
+ _(subject.created_at).must_equal subject.effective_at
52
52
  end
53
53
 
54
54
  it "falls back to now second" do
55
55
  subject.created_at = nil
56
- subject.created_at.must_be_close_to Time.now
56
+ _(subject.created_at).must_be_close_to Time.now
57
57
  end
58
58
  end
59
59
 
60
60
  describe :effective_at= do
61
61
  it "fails on invalid values" do
62
- ['foobar', '2018-01-77'].wont_be_written_to subject, :effective_at
62
+ _(['foobar', '2018-01-77']).wont_be_written_to subject, :effective_at
63
63
  end
64
64
 
65
65
  it "parses dates and times" do
66
66
  string = '2018-01-01 12:00:00 +0100'
67
- subject.tap { |s| s.effective_at = string }.effective_at.must_equal Time.parse(string)
67
+ _(subject.tap { |s| s.effective_at = string }.effective_at).must_equal Time.parse(string)
68
68
  end
69
69
 
70
70
  it "falls back to created_at first" do
71
71
  subject.effective_at = Time.now
72
72
  subject.effective_at = nil
73
- subject.effective_at.must_equal subject.created_at
73
+ _(subject.effective_at).must_equal subject.created_at
74
74
  end
75
75
 
76
76
  it "falls back to now second" do
77
77
  subject.effective_at = nil
78
- subject.effective_at.must_be_close_to Time.now
78
+ _(subject.effective_at).must_be_close_to Time.now
79
79
  end
80
80
  end
81
81
 
@@ -85,21 +85,21 @@ describe AIXM::Document do
85
85
  end
86
86
 
87
87
  it "returns array of features by class" do
88
- subject.select_features(:airport).map(&:id).must_equal %w(LFNT)
89
- subject.select_features(AIXM::Feature::Airport).map(&:id).must_equal %w(LFNT)
88
+ _(subject.select_features(:airport).map(&:id)).must_equal %w(LFNT)
89
+ _(subject.select_features(AIXM::Feature::Airport).map(&:id)).must_equal %w(LFNT)
90
90
  end
91
91
 
92
92
  it "returns array of features by class and attributes" do
93
- subject.select_features(:airport, id: "LFNT").map(&:id).must_equal %w(LFNT)
94
- subject.select_features(AIXM::Feature::Airport, id: "LFNT").map(&:id).must_equal %w(LFNT)
93
+ _(subject.select_features(:airport, id: "LFNT").map(&:id)).must_equal %w(LFNT)
94
+ _(subject.select_features(AIXM::Feature::Airport, id: "LFNT").map(&:id)).must_equal %w(LFNT)
95
95
  end
96
96
 
97
97
  it "returns empty array if nothing matches" do
98
- subject.select_features(:airport, id: "FAKE").must_equal []
98
+ _(subject.select_features(:airport, id: "FAKE")).must_equal []
99
99
  end
100
100
 
101
101
  it "fails on invalid shortcut" do
102
- -> { subject.select_features(:fake) }.must_raise ArgumentError
102
+ _{ subject.select_features(:fake) }.must_raise ArgumentError
103
103
  end
104
104
  end
105
105
 
@@ -130,44 +130,43 @@ describe AIXM::Document do
130
130
  end
131
131
 
132
132
  it "adds 1 group of obstacles with default max distance" do
133
- subject.group_obstacles!.must_equal 1
133
+ _(subject.group_obstacles!).must_equal 1
134
134
  obstacle_group = subject.select_features(:obstacle_group).first
135
- obstacle_group.obstacles.count.must_equal 8
135
+ _(obstacle_group.obstacles.count).must_equal 8
136
136
  end
137
137
 
138
138
  it "adds 2 groups of obstacles with max distance 400m" do
139
- subject.group_obstacles!(max_distance: AIXM.d(400, :m)).must_equal 2
139
+ _(subject.group_obstacles!(max_distance: AIXM.d(400, :m))).must_equal 2
140
140
  obstacle_groups = subject.features.select { |f| f.is_a? AIXM::Feature::ObstacleGroup }
141
141
  obstacle_groups.each do |obstacle_group|
142
142
  names = obstacle_group.obstacles.map(&:name).sort
143
- names.must_equal names.include?('1') ? %w(1 2 3 4) : %w(5 6 7 8)
143
+ _(names).must_equal names.include?('1') ? %w(1 2 3 4) : %w(5 6 7 8)
144
144
  end
145
145
  end
146
146
 
147
147
  it "leaves ungrouped obstacles untouched" do
148
148
  subject.group_obstacles!
149
- subject.select_features(:obstacle).count.must_equal 1
149
+ _(subject.select_features(:obstacle).count).must_equal 1
150
150
  end
151
151
 
152
152
  it "copies source of first obstacle to obstacle group" do
153
153
  subject.group_obstacles!
154
154
  obstacle_group = subject.select_features(:obstacle_group).first
155
- obstacle_group.source.must_equal obstacle_group.obstacles.first.source
155
+ _(obstacle_group.source).must_equal obstacle_group.obstacles.first.source
156
156
  end
157
157
  end
158
158
 
159
159
  context "AIXM" do
160
160
  subject do
161
- AIXM.aixm!
162
161
  AIXM::Factory.document
163
162
  end
164
163
 
165
164
  it "won't have errors" do
166
- subject.errors.must_equal []
165
+ _(subject.errors).must_equal []
167
166
  end
168
167
 
169
168
  it "builds correct AIXM" do
170
- subject.to_xml.must_equal <<~"END"
169
+ _(subject.to_xml).must_equal <<~"END"
171
170
  <?xml version="1.0" encoding="UTF-8"?>
172
171
  <AIXM-Snapshot xmlns:xsi="http://www.aixm.aero/schema/4.5/AIXM-Snapshot.xsd" version="4.5" origin="rubygem aixm-#{AIXM::VERSION}" created="2018-01-01T12:00:00+01:00" effective="2018-01-01T12:00:00+01:00">
173
172
  <!-- Organisation: FRANCE -->
@@ -297,7 +296,7 @@ describe AIXM::Document do
297
296
  <geoLat>440007.63N</geoLat>
298
297
  <geoLong>0044507.81E</geoLong>
299
298
  <valTrueBrg>165</valTrueBrg>
300
- <valMagBrg>166</valMagBrg>
299
+ <valMagBrg>164</valMagBrg>
301
300
  <valElevTdz>145</valElevTdz>
302
301
  <uomElevTdz>FT</uomElevTdz>
303
302
  <codeVfrPattern>E</codeVfrPattern>
@@ -352,7 +351,7 @@ describe AIXM::Document do
352
351
  <geoLat>435925.31N</geoLat>
353
352
  <geoLong>0044523.24E</geoLong>
354
353
  <valTrueBrg>345</valTrueBrg>
355
- <valMagBrg>346</valMagBrg>
354
+ <valMagBrg>344</valMagBrg>
356
355
  <valElevTdz>147</valElevTdz>
357
356
  <uomElevTdz>FT</uomElevTdz>
358
357
  <codeVfrPattern>L</codeVfrPattern>
@@ -435,7 +434,7 @@ describe AIXM::Document do
435
434
  <txtDesig>35</txtDesig>
436
435
  </FdnUid>
437
436
  <valTrueBrg>355</valTrueBrg>
438
- <valMagBrg>356</valMagBrg>
437
+ <valMagBrg>354</valMagBrg>
439
438
  <txtRmk>Avoid flight over residental area</txtRmk>
440
439
  </Fdn>
441
440
  <Fls>
@@ -978,11 +977,11 @@ describe AIXM::Document do
978
977
  end
979
978
 
980
979
  it "won't have errors" do
981
- subject.errors.must_equal []
980
+ _(subject.errors).must_equal []
982
981
  end
983
982
 
984
983
  it "builds correct OFMX" do
985
- subject.to_xml.must_equal <<~"END"
984
+ _(subject.to_xml).must_equal <<~"END"
986
985
  <?xml version="1.0" encoding="UTF-8"?>
987
986
  <OFMX-Snapshot xmlns:xsi="http://schema.openflightmaps.org/0/OFMX-Snapshot.xsd" version="0" origin="rubygem aixm-#{AIXM::VERSION}" region="LF" namespace="00000000-0000-0000-0000-000000000000" created="2018-01-01T12:00:00+01:00" effective="2018-01-01T12:00:00+01:00">
988
987
  <!-- Organisation: FRANCE -->
@@ -1113,7 +1112,7 @@ describe AIXM::Document do
1113
1112
  <geoLat>44.00211944N</geoLat>
1114
1113
  <geoLong>004.75216944E</geoLong>
1115
1114
  <valTrueBrg>165</valTrueBrg>
1116
- <valMagBrg>166</valMagBrg>
1115
+ <valMagBrg>164</valMagBrg>
1117
1116
  <valElevTdz>145</valElevTdz>
1118
1117
  <uomElevTdz>FT</uomElevTdz>
1119
1118
  <codeVfrPattern>E</codeVfrPattern>
@@ -1168,7 +1167,7 @@ describe AIXM::Document do
1168
1167
  <geoLat>43.99036389N</geoLat>
1169
1168
  <geoLong>004.75645556E</geoLong>
1170
1169
  <valTrueBrg>345</valTrueBrg>
1171
- <valMagBrg>346</valMagBrg>
1170
+ <valMagBrg>344</valMagBrg>
1172
1171
  <valElevTdz>147</valElevTdz>
1173
1172
  <uomElevTdz>FT</uomElevTdz>
1174
1173
  <codeVfrPattern>L</codeVfrPattern>
@@ -1251,7 +1250,7 @@ describe AIXM::Document do
1251
1250
  <txtDesig>35</txtDesig>
1252
1251
  </FdnUid>
1253
1252
  <valTrueBrg>355</valTrueBrg>
1254
- <valMagBrg>356</valMagBrg>
1253
+ <valMagBrg>354</valMagBrg>
1255
1254
  <txtRmk>Avoid flight over residental area</txtRmk>
1256
1255
  </Fdn>
1257
1256
  <Fls>
@@ -1871,5 +1870,15 @@ describe AIXM::Document do
1871
1870
  </OFMX-Snapshot>
1872
1871
  END
1873
1872
  end
1873
+
1874
+ it "builds OFMX with one mid for every *Uid" do
1875
+ AIXM.ofmx!
1876
+ AIXM.config.mid_region = 'LF'
1877
+ xml = subject.to_xml
1878
+ #require 'pry'; binding.pry
1879
+ count_mid = xml.scan(/mid=/).count
1880
+ count_uid = xml.scan(/<\w+Uid[\s>]/).count
1881
+ _(count_mid).must_equal count_uid
1882
+ end
1874
1883
  end
1875
1884
  end
@@ -2,13 +2,13 @@ require_relative '../../spec_helper'
2
2
 
3
3
  describe AIXM::GeometryError do
4
4
  it "must be defined" do
5
- AIXM::GeometryError.wont_be_nil
5
+ _(AIXM::GeometryError).wont_be_nil
6
6
  end
7
7
  end
8
8
 
9
9
 
10
10
  describe AIXM::LayerError do
11
11
  it "must be defined" do
12
- AIXM::LayerError.wont_be_nil
12
+ _(AIXM::LayerError).wont_be_nil
13
13
  end
14
14
  end
@@ -7,21 +7,21 @@ describe AIXM::F do
7
7
 
8
8
  describe :freq= do
9
9
  it "fails on invalid values" do
10
- [:foobar].wont_be_written_to subject, :freq
10
+ _([:foobar]).wont_be_written_to subject, :freq
11
11
  end
12
12
 
13
13
  it "converts Numeric to Float" do
14
- subject.tap { |s| s.freq = 5 }.freq.must_equal 5.0
14
+ _(subject.tap { |s| s.freq = 5 }.freq).must_equal 5.0
15
15
  end
16
16
  end
17
17
 
18
18
  describe :unit= do
19
19
  it "fails on invalid values" do
20
- [:foobar, 123].wont_be_written_to subject, :unit
20
+ _([:foobar, 123]).wont_be_written_to subject, :unit
21
21
  end
22
22
 
23
23
  it "symbolizes and downcases values" do
24
- subject.tap { |s| s.unit = "MHz" }.unit.must_equal :mhz
24
+ _(subject.tap { |s| s.unit = "MHz" }.unit).must_equal :mhz
25
25
  end
26
26
  end
27
27
 
@@ -31,14 +31,14 @@ describe AIXM::F do
31
31
  end
32
32
 
33
33
  it "detect frequencies within a frequency band" do
34
- subject.between?(90, 110, :mhz).must_equal true
35
- subject.between?(90, 100, :mhz).must_equal true
36
- subject.between?(100.0, 100.1, :mhz).must_equal true
34
+ _(subject.between?(90, 110, :mhz)).must_equal true
35
+ _(subject.between?(90, 100, :mhz)).must_equal true
36
+ _(subject.between?(100.0, 100.1, :mhz)).must_equal true
37
37
  end
38
38
 
39
39
  it "detect frequencies outside of a frequency band" do
40
- subject.between?(90, 110, :khz).must_equal false
41
- subject.between?(90, 95, :mhz).must_equal false
40
+ _(subject.between?(90, 110, :khz)).must_equal false
41
+ _(subject.between?(90, 95, :mhz)).must_equal false
42
42
  end
43
43
  end
44
44
 
@@ -46,40 +46,40 @@ describe AIXM::F do
46
46
  it "recognizes objects with identical frequency and unit as equal" do
47
47
  a = AIXM.f(123.0, :mhz)
48
48
  b = AIXM.f(123, 'MHZ')
49
- a.must_equal b
49
+ _(a).must_equal b
50
50
  end
51
51
 
52
52
  it "recognizes objects with different frequency or unit as unequal" do
53
53
  a = AIXM.f(123.35, :mhz)
54
54
  b = AIXM.f(123.35, :khz)
55
- a.wont_equal b
55
+ _(a).wont_equal b
56
56
  end
57
57
 
58
58
  it "recognizes objects of different class as unequal" do
59
59
  a = AIXM.f(123.35, :mhz)
60
60
  b = :oggy
61
- a.wont_equal b
61
+ _(a).wont_equal b
62
62
  end
63
63
  end
64
64
 
65
65
  describe :hash do
66
66
  it "returns an integer" do
67
- subject.hash.must_be_instance_of Integer
67
+ _(subject.hash).must_be_instance_of Integer
68
68
  end
69
69
 
70
70
  it "allows for the use of instances as hash keys" do
71
71
  dupe = subject.dup
72
- { subject => true }[dupe].must_equal true
72
+ _({ subject => true }[dupe]).must_equal true
73
73
  end
74
74
  end
75
75
 
76
76
  describe :zero? do
77
77
  it "returns true for zero frequency" do
78
- subject.tap { |s| s.freq = 0 }.must_be :zero?
78
+ _(subject.tap { |s| s.freq = 0 }).must_be :zero?
79
79
  end
80
80
 
81
81
  it "returns false for non-zero frequency" do
82
- subject.tap { |s| s.freq = 1 }.wont_be :zero?
82
+ _(subject.tap { |s| s.freq = 1 }).wont_be :zero?
83
83
  end
84
84
  end
85
85
  end
@@ -7,13 +7,13 @@ describe AIXM::Feature::Address do
7
7
 
8
8
  describe :type= do
9
9
  it "fails on invalid values" do
10
- -> { subject.type = :foobar }.must_raise ArgumentError
11
- -> { subject.type = nil }.must_raise ArgumentError
10
+ _{ subject.type = :foobar }.must_raise ArgumentError
11
+ _{ subject.type = nil }.must_raise ArgumentError
12
12
  end
13
13
 
14
14
  it "looks up valid values" do
15
- subject.tap { |s| s.type = :phone }.type.must_equal :phone
16
- subject.tap { |s| s.type = :RADIO }.type.must_equal :radio_frequency
15
+ _(subject.tap { |s| s.type = :phone }.type).must_equal :phone
16
+ _(subject.tap { |s| s.type = :RADIO }.type).must_equal :radio_frequency
17
17
  end
18
18
  end
19
19
 
@@ -24,7 +24,7 @@ describe AIXM::Feature::Address do
24
24
  describe :xml= do
25
25
  it "builds correct OFMX" do
26
26
  AIXM.ofmx!
27
- subject.to_xml(as: :Xxx, sequence: 1).must_equal <<~END
27
+ _(subject.to_xml(as: :Xxx, sequence: 1)).must_equal <<~END
28
28
  <!-- Address: RADIO -->
29
29
  <Xxx source="LF|GEN|0.0 FACTORY|0|0">
30
30
  <XxxUid>
@@ -37,10 +37,15 @@ describe AIXM::Feature::Address do
37
37
  END
38
38
  end
39
39
 
40
+ it "builds OFMX with mid" do
41
+ AIXM.ofmx!
42
+ AIXM.config.mid_region = 'LF'
43
+ _(subject.to_xml(as: :Xxx, sequence: 1)).must_match /<XxxUid mid="126bee70-4d4e-0032-ada9-81d3318fe6b7">/
44
+ end
45
+
40
46
  it "builds correct AIXM" do
41
- AIXM.aixm!
42
47
  subject = AIXM.address(type: :weather_url, address: 'https://www.foo.bar')
43
- subject.to_xml(as: :Xxx, sequence: 1).must_equal <<~END
48
+ _(subject.to_xml(as: :Xxx, sequence: 1)).must_equal <<~END
44
49
  <!-- Address: URL-MET -->
45
50
  <Xxx>
46
51
  <XxxUid>
@@ -13,74 +13,74 @@ describe AIXM::Feature::Airport do
13
13
  name: 'Avignon-Pujaut',
14
14
  xy: AIXM.xy(lat: %q(43°59'46"N), long: %q(004°45'16"E))
15
15
  )
16
- subject.addresses.must_equal []
17
- subject.runways.must_equal []
18
- subject.helipads.must_equal []
19
- subject.usage_limitations.must_equal []
16
+ _(subject.addresses).must_equal []
17
+ _(subject.runways).must_equal []
18
+ _(subject.helipads).must_equal []
19
+ _(subject.usage_limitations).must_equal []
20
20
  end
21
21
  end
22
22
 
23
23
  describe :organisation= do
24
24
  it "fails on invalid values" do
25
- [nil, :foobar].wont_be_written_to subject, :organisation
25
+ _([nil, :foobar]).wont_be_written_to subject, :organisation
26
26
  end
27
27
  end
28
28
 
29
29
  describe :id= do
30
30
  it "fails on invalid values" do
31
- [nil, 'A', 'ABCDE', 'AB 1234'].wont_be_written_to subject, :id
31
+ _([nil, 'A', 'ABCDE', 'AB 1234']).wont_be_written_to subject, :id
32
32
  end
33
33
 
34
34
  it "combines 2 character region with an 8 characters digest from name" do
35
- subject.tap { |s| s.id = 'lf' }.id.must_equal 'LFD18754F5'
36
- subject.tap { |s| s.name = 'OTHER'; s.id = 'lf' }.id.must_equal 'LFD646E0F9'
35
+ _(subject.tap { |s| s.id = 'lf' }.id).must_equal 'LFD18754F5'
36
+ _(subject.tap { |s| s.name = 'OTHER'; s.id = 'lf' }.id).must_equal 'LFD646E0F9'
37
37
  end
38
38
 
39
39
  it "upcases valid values" do
40
- subject.tap { |s| s.id = 'lfnt' }.id.must_equal 'LFNT'
40
+ _(subject.tap { |s| s.id = 'lfnt' }.id).must_equal 'LFNT'
41
41
  end
42
42
  end
43
43
 
44
44
  describe :name= do
45
45
  it "fails on invalid values" do
46
- [nil, 123].wont_be_written_to subject, :name
46
+ _([nil, 123]).wont_be_written_to subject, :name
47
47
  end
48
48
 
49
49
  it "upcases and transcodes valid values" do
50
- subject.tap { |s| s.name = 'Nîmes-Alès' }.name.must_equal 'NIMES-ALES'
50
+ _(subject.tap { |s| s.name = 'Nîmes-Alès' }.name).must_equal 'NIMES-ALES'
51
51
  end
52
52
  end
53
53
 
54
54
  describe :gps= do
55
55
  it "fails on invalid values" do
56
- [:foobar, 123].wont_be_written_to subject, :gps
56
+ _([:foobar, 123]).wont_be_written_to subject, :gps
57
57
  end
58
58
 
59
59
  it "accepts nil value" do
60
- [nil].must_be_written_to subject, :gps
60
+ _([nil]).must_be_written_to subject, :gps
61
61
  end
62
62
 
63
63
  it "upcases valid values" do
64
- subject.tap { |s| s.gps = 'Ebdeurne' }.gps.must_equal 'EBDEURNE'
64
+ _(subject.tap { |s| s.gps = 'Ebdeurne' }.gps).must_equal 'EBDEURNE'
65
65
  end
66
66
  end
67
67
 
68
68
  describe :type= do
69
69
  it "fails on invalid values" do
70
- [nil, :foobar].wont_be_written_to subject, :type
70
+ _([nil, :foobar]).wont_be_written_to subject, :type
71
71
  end
72
72
 
73
73
  it "fails on values derived from runways and helipads" do
74
- [:aerodrome, :heliport, :aerodrome_and_heliport].wont_be_written_to subject, :type
74
+ _([:aerodrome, :heliport, :aerodrome_and_heliport]).wont_be_written_to subject, :type
75
75
  end
76
76
 
77
77
  it "looks up valid values" do
78
- subject.tap { |s| s.type = :landing_site }.type.must_equal :landing_site
79
- subject.tap { |s| s.type = :LS }.type.must_equal :landing_site
78
+ _(subject.tap { |s| s.type = :landing_site }.type).must_equal :landing_site
79
+ _(subject.tap { |s| s.type = :LS }.type).must_equal :landing_site
80
80
  end
81
81
 
82
82
  it "derives values from runways and helipads" do
83
- subject.type.must_equal :aerodrome_and_heliport
83
+ _(subject.type).must_equal :aerodrome_and_heliport
84
84
  end
85
85
  end
86
86
 
@@ -88,7 +88,7 @@ describe AIXM::Feature::Airport do
88
88
  macro :xy
89
89
 
90
90
  it "fails on nil values" do
91
- [nil].wont_be_written_to subject, :xy
91
+ _([nil]).wont_be_written_to subject, :xy
92
92
  end
93
93
  end
94
94
 
@@ -96,32 +96,32 @@ describe AIXM::Feature::Airport do
96
96
  macro :z_qnh
97
97
 
98
98
  it "accepts nil value" do
99
- [nil].must_be_written_to subject, :z
99
+ _([nil]).must_be_written_to subject, :z
100
100
  end
101
101
  end
102
102
 
103
103
  describe :declination= do
104
104
  it "fails on invalid values" do
105
- [:foobar, false].wont_be_written_to subject, :declination
105
+ _([:foobar, false]).wont_be_written_to subject, :declination
106
106
  end
107
107
 
108
108
  it "accepts nil value" do
109
- [nil].must_be_written_to subject, :declination
109
+ _([nil]).must_be_written_to subject, :declination
110
110
  end
111
111
 
112
112
  it "converts valid values to Float" do
113
- subject.tap { |s| s.declination = 10 }.declination.must_equal 10.0
114
- subject.tap { |s| s.declination = 20.0 }.declination.must_equal 20.0
113
+ _(subject.tap { |s| s.declination = 10 }.declination).must_equal 10.0
114
+ _(subject.tap { |s| s.declination = 20.0 }.declination).must_equal 20.0
115
115
  end
116
116
  end
117
117
 
118
118
  describe :transition_z= do
119
119
  it "fails on invalid values" do
120
- [123, AIXM.z(123, :qfe)].wont_be_written_to subject, :transition_z
120
+ _([123, AIXM.z(123, :qfe)]).wont_be_written_to subject, :transition_z
121
121
  end
122
122
 
123
123
  it "accepts valid values" do
124
- [nil, AIXM.z(123, :qnh)].must_be_written_to subject, :transition_z
124
+ _([nil, AIXM.z(123, :qnh)]).must_be_written_to subject, :transition_z
125
125
  end
126
126
  end
127
127
 
@@ -131,15 +131,15 @@ describe AIXM::Feature::Airport do
131
131
 
132
132
  describe :operator= do
133
133
  it "fails on invalid values" do
134
- [123].wont_be_written_to subject, :operator
134
+ _([123]).wont_be_written_to subject, :operator
135
135
  end
136
136
 
137
137
  it "accepts nil value" do
138
- [nil].must_be_written_to subject, :operator
138
+ _([nil]).must_be_written_to subject, :operator
139
139
  end
140
140
 
141
141
  it "upcases and transcodes valid values" do
142
- subject.tap { |s| s.operator = 'Municipality of Nîmes-Alès' }.operator.must_equal 'MUNICIPALITY OF NIMES-ALES'
142
+ _(subject.tap { |s| s.operator = 'Municipality of Nîmes-Alès' }.operator).must_equal 'MUNICIPALITY OF NIMES-ALES'
143
143
  end
144
144
  end
145
145
 
@@ -149,51 +149,51 @@ describe AIXM::Feature::Airport do
149
149
 
150
150
  describe :add_address do
151
151
  it "fails on invalid arguments" do
152
- -> { subject.add_address nil }.must_raise ArgumentError
152
+ _{ subject.add_address nil }.must_raise ArgumentError
153
153
  end
154
154
 
155
155
  it "adds address to the array" do
156
156
  count = subject.addresses.count
157
157
  subject.add_address(AIXM::Factory.address)
158
- subject.addresses.count.must_equal count + 1
158
+ _(subject.addresses.count).must_equal count + 1
159
159
  end
160
160
  end
161
161
 
162
162
  describe :add_runway do
163
163
  it "fails on invalid arguments" do
164
- -> { subject.add_runway nil }.must_raise ArgumentError
164
+ _{ subject.add_runway nil }.must_raise ArgumentError
165
165
  end
166
166
 
167
167
  it "adds runway to the array" do
168
168
  count = subject.runways.count
169
169
  subject.add_runway(AIXM.runway(name: '10'))
170
- subject.runways.count.must_equal count + 1
170
+ _(subject.runways.count).must_equal count + 1
171
171
  end
172
172
  end
173
173
 
174
174
  describe :add_helipad do
175
175
  it "fails on invalid arguments" do
176
- -> { subject.add_helipad nil }.must_raise ArgumentError
176
+ _{ subject.add_helipad nil }.must_raise ArgumentError
177
177
  end
178
178
 
179
179
  it "adds helipad to the array" do
180
180
  count = subject.helipads.count
181
181
  subject.add_helipad(AIXM.helipad(name: 'H2', xy: AIXM::Factory.xy))
182
- subject.helipads.count.must_equal count + 1
182
+ _(subject.helipads.count).must_equal count + 1
183
183
  end
184
184
  end
185
185
 
186
186
  describe :add_usage_limitation do
187
187
  it "fails on invalid arguments" do
188
- -> { subject.add_usage_limitation(:foobar) }.must_raise ArgumentError
188
+ _{ subject.add_usage_limitation(:foobar) }.must_raise ArgumentError
189
189
  end
190
190
 
191
191
  context "without block" do
192
192
  it "accepts simple limitation" do
193
193
  count = subject.usage_limitations.count
194
194
  subject.add_usage_limitation(:permitted)
195
- subject.usage_limitations.count.must_equal count + 1
196
- subject.usage_limitations.last.type.must_equal :permitted
195
+ _(subject.usage_limitations.count).must_equal count + 1
196
+ _(subject.usage_limitations.last.type).must_equal :permitted
197
197
  end
198
198
  end
199
199
 
@@ -204,8 +204,8 @@ describe AIXM::Feature::Airport do
204
204
  permitted.add_condition { |c| c.aircraft = :glider }
205
205
  permitted.add_condition { |c| c.rule = :ifr }
206
206
  end
207
- subject.usage_limitations.count.must_equal count + 1
208
- subject.usage_limitations.last.conditions.count.must_equal 2
207
+ _(subject.usage_limitations.count).must_equal count + 1
208
+ _(subject.usage_limitations.last.conditions.count).must_equal 2
209
209
  end
210
210
  end
211
211
  end
@@ -215,7 +215,7 @@ describe AIXM::Feature::Airport do
215
215
  AIXM.ofmx!
216
216
  subject.add_address(AIXM.address(source: "LF|GEN|0.0 FACTORY|0|0", type: :url, address: 'https://lfnt.tower.zone'))
217
217
  subject.add_address(AIXM.address(source: "LF|GEN|0.0 FACTORY|0|0", type: :url, address: 'https://planeur-avignon-pujaut.fr'))
218
- subject.to_xml.must_equal <<~END
218
+ _(subject.to_xml).must_equal <<~END
219
219
  <!-- Airport: LFNT AVIGNON-PUJAUT -->
220
220
  <Ahp source="LF|GEN|0.0 FACTORY|0|0">
221
221
  <AhpUid>
@@ -280,7 +280,7 @@ describe AIXM::Feature::Airport do
280
280
  <geoLat>44.00211944N</geoLat>
281
281
  <geoLong>004.75216944E</geoLong>
282
282
  <valTrueBrg>165</valTrueBrg>
283
- <valMagBrg>166</valMagBrg>
283
+ <valMagBrg>164</valMagBrg>
284
284
  <valElevTdz>145</valElevTdz>
285
285
  <uomElevTdz>FT</uomElevTdz>
286
286
  <codeVfrPattern>E</codeVfrPattern>
@@ -335,7 +335,7 @@ describe AIXM::Feature::Airport do
335
335
  <geoLat>43.99036389N</geoLat>
336
336
  <geoLong>004.75645556E</geoLong>
337
337
  <valTrueBrg>345</valTrueBrg>
338
- <valMagBrg>346</valMagBrg>
338
+ <valMagBrg>344</valMagBrg>
339
339
  <valElevTdz>147</valElevTdz>
340
340
  <uomElevTdz>FT</uomElevTdz>
341
341
  <codeVfrPattern>L</codeVfrPattern>
@@ -418,7 +418,7 @@ describe AIXM::Feature::Airport do
418
418
  <txtDesig>35</txtDesig>
419
419
  </FdnUid>
420
420
  <valTrueBrg>355</valTrueBrg>
421
- <valMagBrg>356</valMagBrg>
421
+ <valMagBrg>354</valMagBrg>
422
422
  <txtRmk>Avoid flight over residental area</txtRmk>
423
423
  </Fdn>
424
424
  <Fls>
@@ -567,7 +567,7 @@ describe AIXM::Feature::Airport do
567
567
  subject.instance_eval { @fatos.clear }
568
568
  subject.instance_eval { @helipads.clear }
569
569
  subject.instance_eval { @usage_limitations.clear }
570
- subject.to_xml.must_equal <<~END
570
+ _(subject.to_xml).must_equal <<~END
571
571
  <!-- Airport: LFNT AVIGNON-PUJAUT -->
572
572
  <Ahp source="LF|GEN|0.0 FACTORY|0|0">
573
573
  <AhpUid>
@@ -586,6 +586,12 @@ describe AIXM::Feature::Airport do
586
586
  END
587
587
  end
588
588
  end
589
+
590
+ it "builds OFMX with mid" do
591
+ AIXM.ofmx!
592
+ AIXM.config.mid_region = 'LF'
593
+ _(subject.to_xml).must_match /<AhpUid mid="c63504f4-c1d9-1b88-f2ca-2c35a25d8bf3">/
594
+ end
589
595
  end
590
596
 
591
597
  describe AIXM::Feature::Airport::UsageLimitation do
@@ -595,18 +601,18 @@ describe AIXM::Feature::Airport::UsageLimitation do
595
601
 
596
602
  describe :initialize do
597
603
  it "sets defaults" do
598
- subject.conditions.must_equal []
604
+ _(subject.conditions).must_equal []
599
605
  end
600
606
  end
601
607
 
602
608
  describe :type= do
603
609
  it "fails on invalid values" do
604
- [nil, :foobar].wont_be_written_to subject, :type
610
+ _([nil, :foobar]).wont_be_written_to subject, :type
605
611
  end
606
612
 
607
613
  it "looks up valid values" do
608
- subject.tap { |s| s.type = :permitted }.type.must_equal :permitted
609
- subject.tap { |s| s.type = :RESERV }.type.must_equal :reservation_required
614
+ _(subject.tap { |s| s.type = :permitted }.type).must_equal :permitted
615
+ _(subject.tap { |s| s.type = :RESERV }.type).must_equal :reservation_required
610
616
  end
611
617
  end
612
618
 
@@ -622,7 +628,7 @@ describe AIXM::Feature::Airport::UsageLimitation do
622
628
  it "builds correct complete OFMX" do
623
629
  AIXM.ofmx!
624
630
  subject = AIXM::Factory.airport.usage_limitations.last
625
- subject.to_xml.must_equal <<~END
631
+ _(subject.to_xml).must_equal <<~END
626
632
  <UsageLimitation>
627
633
  <codeUsageLimitation>RESERV</codeUsageLimitation>
628
634
  <UsageCondition>
@@ -645,7 +651,7 @@ describe AIXM::Feature::Airport::UsageLimitation do
645
651
 
646
652
  it "builds correct minimal OFMX" do
647
653
  AIXM.ofmx!
648
- subject.to_xml.must_equal <<~END
654
+ _(subject.to_xml).must_equal <<~END
649
655
  <UsageLimitation>
650
656
  <codeUsageLimitation>PERMIT</codeUsageLimitation>
651
657
  </UsageLimitation>
@@ -661,76 +667,76 @@ describe AIXM::Feature::Airport::UsageLimitation::Condition do
661
667
 
662
668
  describe :aircraft= do
663
669
  it "fails on invalid values" do
664
- [:foobar, 123].wont_be_written_to subject, :aircraft
670
+ _([:foobar, 123]).wont_be_written_to subject, :aircraft
665
671
  end
666
672
 
667
673
  it "accepts nil value" do
668
- [nil].must_be_written_to subject, :aircraft
674
+ _([nil]).must_be_written_to subject, :aircraft
669
675
  end
670
676
 
671
677
  it "looks up valid values" do
672
- subject.tap { |s| s.aircraft = :glider }.aircraft.must_equal :glider
673
- subject.tap { |s| s.aircraft = :H }.aircraft.must_equal :helicopter
678
+ _(subject.tap { |s| s.aircraft = :glider }.aircraft).must_equal :glider
679
+ _(subject.tap { |s| s.aircraft = :H }.aircraft).must_equal :helicopter
674
680
  end
675
681
  end
676
682
 
677
683
  describe :rule= do
678
684
  it "fails on invalid values" do
679
- [:foobar, 123].wont_be_written_to subject, :rule
685
+ _([:foobar, 123]).wont_be_written_to subject, :rule
680
686
  end
681
687
 
682
688
  it "accepts nil value" do
683
- [nil].must_be_written_to subject, :rule
689
+ _([nil]).must_be_written_to subject, :rule
684
690
  end
685
691
 
686
692
  it "looks up valid values" do
687
- subject.tap { |s| s.rule = :ifr }.rule.must_equal :ifr
688
- subject.tap { |s| s.rule = :IV }.rule.must_equal :ifr_and_vfr
693
+ _(subject.tap { |s| s.rule = :ifr }.rule).must_equal :ifr
694
+ _(subject.tap { |s| s.rule = :IV }.rule).must_equal :ifr_and_vfr
689
695
  end
690
696
  end
691
697
 
692
698
  describe :realm= do
693
699
  it "fails on invalid values" do
694
- [:foobar, 123].wont_be_written_to subject, :realm
700
+ _([:foobar, 123]).wont_be_written_to subject, :realm
695
701
  end
696
702
 
697
703
  it "accepts nil value" do
698
- [nil].must_be_written_to subject, :realm
704
+ _([nil]).must_be_written_to subject, :realm
699
705
  end
700
706
 
701
707
  it "looks up valid values" do
702
- subject.tap { |s| s.realm = :civilian }.realm.must_equal :civilian
703
- subject.tap { |s| s.realm = :MIL }.realm.must_equal :military
708
+ _(subject.tap { |s| s.realm = :civilian }.realm).must_equal :civilian
709
+ _(subject.tap { |s| s.realm = :MIL }.realm).must_equal :military
704
710
  end
705
711
  end
706
712
 
707
713
  describe :origin= do
708
714
  it "fails on invalid values" do
709
- [:foobar, 123].wont_be_written_to subject, :origin
715
+ _([:foobar, 123]).wont_be_written_to subject, :origin
710
716
  end
711
717
 
712
718
  it "accepts nil value" do
713
- [nil].must_be_written_to subject, :origin
719
+ _([nil]).must_be_written_to subject, :origin
714
720
  end
715
721
 
716
722
  it "looks up valid values" do
717
- subject.tap { |s| s.origin = :international }.origin.must_equal :international
718
- subject.tap { |s| s.origin = :NTL }.origin.must_equal :national
723
+ _(subject.tap { |s| s.origin = :international }.origin).must_equal :international
724
+ _(subject.tap { |s| s.origin = :NTL }.origin).must_equal :national
719
725
  end
720
726
  end
721
727
 
722
728
  describe :purpose= do
723
729
  it "fails on invalid values" do
724
- [:foobar, 123].wont_be_written_to subject, :purpose
730
+ _([:foobar, 123]).wont_be_written_to subject, :purpose
725
731
  end
726
732
 
727
733
  it "accepts nil value" do
728
- [nil].must_be_written_to subject, :purpose
734
+ _([nil]).must_be_written_to subject, :purpose
729
735
  end
730
736
 
731
737
  it "looks up valid values" do
732
- subject.tap { |s| s.purpose = :private }.purpose.must_equal :private
733
- subject.tap { |s| s.purpose = :TRG }.purpose.must_equal :school_or_training
738
+ _(subject.tap { |s| s.purpose = :private }.purpose).must_equal :private
739
+ _(subject.tap { |s| s.purpose = :TRG }.purpose).must_equal :school_or_training
734
740
  end
735
741
  end
736
742
 
@@ -741,7 +747,7 @@ describe AIXM::Feature::Airport::UsageLimitation::Condition do
741
747
  subject.origin = :international
742
748
  subject.purpose = :school_or_training
743
749
  AIXM.ofmx!
744
- subject.to_xml.must_equal <<~END
750
+ _(subject.to_xml).must_equal <<~END
745
751
  <UsageCondition>
746
752
  <AircraftClass>
747
753
  <codeType>E</codeType>
@@ -758,7 +764,7 @@ describe AIXM::Feature::Airport::UsageLimitation::Condition do
758
764
 
759
765
  it "builds correct minimal OFMX" do
760
766
  AIXM.ofmx!
761
- subject.to_xml.must_equal <<~END
767
+ _(subject.to_xml).must_equal <<~END
762
768
  <UsageCondition>
763
769
  <AircraftClass>
764
770
  <codeType>E</codeType>