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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.yardopts +3 -0
- data/CHANGELOG.md +34 -14
- data/Guardfile +1 -0
- data/README.md +64 -257
- data/lib/aixm.rb +16 -7
- data/lib/aixm/component.rb +6 -0
- data/lib/aixm/component/frequency.rb +135 -0
- data/lib/aixm/component/geometry.rb +34 -23
- data/lib/aixm/component/geometry/arc.rb +37 -22
- data/lib/aixm/component/geometry/border.rb +29 -20
- data/lib/aixm/component/geometry/circle.rb +39 -22
- data/lib/aixm/component/geometry/point.rb +29 -13
- data/lib/aixm/component/helipad.rb +154 -0
- data/lib/aixm/component/layer.rb +91 -0
- data/lib/aixm/component/runway.rb +294 -0
- data/lib/aixm/component/service.rb +170 -0
- data/lib/aixm/component/timetable.rb +65 -0
- data/lib/aixm/component/vertical_limits.rb +65 -29
- data/lib/aixm/config.rb +87 -0
- data/lib/aixm/document.rb +66 -42
- data/lib/aixm/errors.rb +11 -0
- data/lib/aixm/f.rb +34 -20
- data/lib/aixm/feature.rb +38 -0
- data/lib/aixm/feature/airport.rb +473 -0
- data/lib/aixm/feature/airspace.rb +145 -92
- data/lib/aixm/feature/navigational_aid.rb +94 -0
- data/lib/aixm/feature/navigational_aid/designated_point.rb +50 -54
- data/lib/aixm/feature/navigational_aid/dme.rb +48 -40
- data/lib/aixm/feature/navigational_aid/marker.rb +55 -45
- data/lib/aixm/feature/navigational_aid/ndb.rb +54 -50
- data/lib/aixm/feature/navigational_aid/tacan.rb +38 -31
- data/lib/aixm/feature/navigational_aid/vor.rb +84 -76
- data/lib/aixm/feature/organisation.rb +97 -0
- data/lib/aixm/feature/unit.rb +152 -0
- data/lib/aixm/refinements.rb +132 -47
- data/lib/aixm/shortcuts.rb +11 -6
- data/lib/aixm/version.rb +1 -1
- data/lib/aixm/xy.rb +64 -20
- data/lib/aixm/z.rb +51 -22
- data/{lib/aixm/schemas → schemas/aixm}/4.5/AIXM-DataTypes.xsd +0 -0
- data/{lib/aixm/schemas → schemas/aixm}/4.5/AIXM-Features.xsd +0 -0
- data/{lib/aixm/schemas → schemas/aixm}/4.5/AIXM-Snapshot.xsd +0 -0
- data/schemas/ofmx/0/OFMX-DataTypes.xsd +5077 -0
- data/schemas/ofmx/0/OFMX-Features.xsd +9955 -0
- data/schemas/ofmx/0/OFMX-Snapshot.xsd +217 -0
- data/spec/factory.rb +209 -33
- data/spec/lib/aixm/component/frequency_spec.rb +75 -0
- data/spec/lib/aixm/component/geometry/arc_spec.rb +28 -22
- data/spec/lib/aixm/component/geometry/border_spec.rb +23 -20
- data/spec/lib/aixm/component/geometry/circle_spec.rb +31 -22
- data/spec/lib/aixm/component/geometry/point_spec.rb +11 -14
- data/spec/lib/aixm/component/geometry_spec.rb +150 -69
- data/spec/lib/aixm/component/helipad_spec.rb +136 -0
- data/spec/lib/aixm/component/layer_spec.rb +110 -0
- data/spec/lib/aixm/component/runway_spec.rb +402 -0
- data/spec/lib/aixm/component/service_spec.rb +61 -0
- data/spec/lib/aixm/component/timetable_spec.rb +49 -0
- data/spec/lib/aixm/component/vertical_limits_spec.rb +39 -20
- data/spec/lib/aixm/config_spec.rb +41 -0
- data/spec/lib/aixm/document_spec.rb +637 -147
- data/spec/lib/aixm/errors_spec.rb +14 -0
- data/spec/lib/aixm/f_spec.rb +17 -10
- data/spec/lib/aixm/feature/airport_spec.rb +546 -0
- data/spec/lib/aixm/feature/airspace_spec.rb +349 -226
- data/spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb +47 -36
- data/spec/lib/aixm/feature/navigational_aid/dme_spec.rb +61 -36
- data/spec/lib/aixm/feature/navigational_aid/marker_spec.rb +61 -113
- data/spec/lib/aixm/feature/navigational_aid/ndb_spec.rb +65 -79
- data/spec/lib/aixm/feature/navigational_aid/tacan_spec.rb +57 -36
- data/spec/lib/aixm/feature/navigational_aid/vor_spec.rb +86 -112
- data/spec/lib/aixm/feature/navigational_aid_spec.rb +52 -0
- data/spec/lib/aixm/feature/organisation_spec.rb +77 -0
- data/spec/lib/aixm/feature/unit_spec.rb +227 -0
- data/spec/lib/aixm/feature_spec.rb +58 -0
- data/spec/lib/aixm/refinements_spec.rb +187 -178
- data/spec/lib/aixm/xy_spec.rb +45 -34
- data/spec/lib/aixm/z_spec.rb +19 -21
- data/spec/macros/organisation.rb +11 -0
- data/spec/macros/remarks.rb +12 -0
- data/spec/macros/timetable.rb +11 -0
- data/spec/macros/xy.rb +11 -0
- data/spec/macros/z_qnh.rb +11 -0
- data/spec/spec_helper.rb +26 -0
- metadata +60 -19
- data/lib/aixm/base.rb +0 -10
- data/lib/aixm/component/base.rb +0 -6
- data/lib/aixm/component/class_layer.rb +0 -46
- data/lib/aixm/component/geometry/base.rb +0 -8
- data/lib/aixm/component/schedule.rb +0 -43
- data/lib/aixm/feature/base.rb +0 -6
- data/lib/aixm/feature/navigational_aid/base.rb +0 -79
- data/spec/lib/aixm/component/class_layer_spec.rb +0 -74
- data/spec/lib/aixm/component/schedule_spec.rb +0 -33
- data/spec/lib/aixm/feature/navigational_aid/base_spec.rb +0 -41
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require_relative '../../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe AIXM::Feature::Organisation do
|
|
4
|
+
subject do
|
|
5
|
+
AIXM::Factory.organisation
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe :name= do
|
|
9
|
+
it "fails on invalid values" do
|
|
10
|
+
[nil, :foobar, 123].wont_be_written_to subject, :name
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "upcases and transcodes valid values" do
|
|
14
|
+
subject.tap { |s| s.name = 'Nîmes-Alès' }.name.must_equal 'NIMES-ALES'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe :type= do
|
|
19
|
+
it "fails on invalid values" do
|
|
20
|
+
[nil, :foobar, 123].wont_be_written_to subject, :type
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "looks up valid values" do
|
|
24
|
+
subject.tap { |s| s.type = :state }.type.must_equal :state
|
|
25
|
+
subject.tap { |s| s.type = :IO }.type.must_equal :international_organisation
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe :id= do
|
|
30
|
+
it "fails on invalid values" do
|
|
31
|
+
[:foobar, 123].wont_be_written_to subject, :id
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "accepts nil value" do
|
|
35
|
+
[nil].must_be_written_to subject, :id
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "upcases valid values" do
|
|
39
|
+
subject.tap { |s| s.id = 'lf' }.id.must_equal 'LF'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe :remarks= do
|
|
44
|
+
macro :remarks
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe :to_xml do
|
|
48
|
+
it "builds correct complete OFMX" do
|
|
49
|
+
AIXM.ofmx!
|
|
50
|
+
subject.to_xml.must_equal <<~END
|
|
51
|
+
<!-- Organisation: FRANCE -->
|
|
52
|
+
<Org source="LF|GEN|0.0 FACTORY|0|0">
|
|
53
|
+
<OrgUid region="LF">
|
|
54
|
+
<txtName>FRANCE</txtName>
|
|
55
|
+
</OrgUid>
|
|
56
|
+
<codeId>LF</codeId>
|
|
57
|
+
<codeType>S</codeType>
|
|
58
|
+
<txtRmk>Oversea departments not included</txtRmk>
|
|
59
|
+
</Org>
|
|
60
|
+
END
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "builds correct minimal OFMX" do
|
|
64
|
+
AIXM.ofmx!
|
|
65
|
+
subject.id = subject.remarks = nil
|
|
66
|
+
subject.to_xml.must_equal <<~END
|
|
67
|
+
<!-- Organisation: FRANCE -->
|
|
68
|
+
<Org source="LF|GEN|0.0 FACTORY|0|0">
|
|
69
|
+
<OrgUid region="LF">
|
|
70
|
+
<txtName>FRANCE</txtName>
|
|
71
|
+
</OrgUid>
|
|
72
|
+
<codeType>S</codeType>
|
|
73
|
+
</Org>
|
|
74
|
+
END
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
require_relative '../../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe AIXM::Feature::Unit do
|
|
4
|
+
subject do
|
|
5
|
+
AIXM::Factory.unit
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe :organisation= do
|
|
9
|
+
macro :organisation
|
|
10
|
+
|
|
11
|
+
it "fails on nil value" do
|
|
12
|
+
[nil].wont_be_written_to subject, :organisation
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe :name= do
|
|
17
|
+
it "fails on invalid values" do
|
|
18
|
+
[nil, :foobar, 123].wont_be_written_to subject, :name
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "upcases and transcodes valid values" do
|
|
22
|
+
subject.tap { |s| s.name = 'Nîmes-Alès APP' }.name.must_equal 'NIMES-ALES APP'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe :type= do
|
|
27
|
+
it "fails on invalid values" do
|
|
28
|
+
[nil, :foobar, 123].wont_be_written_to subject, :type
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "looks up valid values" do
|
|
32
|
+
subject.tap { |s| s.type = :flight_information_centre }.type.must_equal :flight_information_centre
|
|
33
|
+
subject.tap { |s| s.type = :MET }.type.must_equal :meteorological_office
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe :class= do
|
|
38
|
+
it "fails on invalid values" do
|
|
39
|
+
[nil, :foobar, 123].wont_be_written_to subject, :class
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "looks up valid values" do
|
|
43
|
+
subject.tap { |s| s.class = :icao }.class.must_equal :icao
|
|
44
|
+
subject.tap { |s| s.class = :OTHER }.class.must_equal :other
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe :airport= do
|
|
49
|
+
it "fails on invalid values" do
|
|
50
|
+
[:foobar, 123].wont_be_written_to subject, :airport
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "accepts valid values" do
|
|
54
|
+
[nil, AIXM::Factory.airport].must_be_written_to subject, :airport
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe :remarks= do
|
|
59
|
+
macro :remarks
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe :to_xml do
|
|
63
|
+
let :service do
|
|
64
|
+
AIXM::Factory.service.tap do |service|
|
|
65
|
+
service.type = :AFIS
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "builds correct complete OFMX" do
|
|
70
|
+
2.times { subject.add_service(service) }
|
|
71
|
+
AIXM.ofmx!
|
|
72
|
+
subject.to_xml.must_equal <<~END
|
|
73
|
+
<!-- Unit: PUJAUT TWR -->
|
|
74
|
+
<Uni source="LF|GEN|0.0 FACTORY|0|0">
|
|
75
|
+
<UniUid region="LF">
|
|
76
|
+
<txtName>PUJAUT TWR</txtName>
|
|
77
|
+
</UniUid>
|
|
78
|
+
<OrgUid region="LF">
|
|
79
|
+
<txtName>FRANCE</txtName>
|
|
80
|
+
</OrgUid>
|
|
81
|
+
<AhpUid region="LF">
|
|
82
|
+
<codeId>LFNT</codeId>
|
|
83
|
+
</AhpUid>
|
|
84
|
+
<codeType>TWR</codeType>
|
|
85
|
+
<codeClass>ICAO</codeClass>
|
|
86
|
+
<txtRmk>A/A FR only</txtRmk>
|
|
87
|
+
</Uni>
|
|
88
|
+
<Ser>
|
|
89
|
+
<SerUid>
|
|
90
|
+
<UniUid region="LF">
|
|
91
|
+
<txtName>PUJAUT TWR</txtName>
|
|
92
|
+
</UniUid>
|
|
93
|
+
<codeType>AFIS</codeType>
|
|
94
|
+
<noSeq>1</noSeq>
|
|
95
|
+
</SerUid>
|
|
96
|
+
<Stt>
|
|
97
|
+
<codeWorkHr>H24</codeWorkHr>
|
|
98
|
+
</Stt>
|
|
99
|
+
<txtRmk>service remarks</txtRmk>
|
|
100
|
+
</Ser>
|
|
101
|
+
<Fqy>
|
|
102
|
+
<FqyUid>
|
|
103
|
+
<SerUid>
|
|
104
|
+
<UniUid region="LF">
|
|
105
|
+
<txtName>PUJAUT TWR</txtName>
|
|
106
|
+
</UniUid>
|
|
107
|
+
<codeType>AFIS</codeType>
|
|
108
|
+
<noSeq>1</noSeq>
|
|
109
|
+
</SerUid>
|
|
110
|
+
<valFreqTrans>123.35</valFreqTrans>
|
|
111
|
+
</FqyUid>
|
|
112
|
+
<valFreqRec>124.1</valFreqRec>
|
|
113
|
+
<uomFreq>MHZ</uomFreq>
|
|
114
|
+
<Ftt>
|
|
115
|
+
<codeWorkHr>H24</codeWorkHr>
|
|
116
|
+
</Ftt>
|
|
117
|
+
<txtRmk>frequency remarks</txtRmk>
|
|
118
|
+
<Cdl>
|
|
119
|
+
<txtCallSign>PUJAUT CONTROL</txtCallSign>
|
|
120
|
+
<codeLang>EN</codeLang>
|
|
121
|
+
</Cdl>
|
|
122
|
+
<Cdl>
|
|
123
|
+
<txtCallSign>PUJAUT CONTROLE</txtCallSign>
|
|
124
|
+
<codeLang>FR</codeLang>
|
|
125
|
+
</Cdl>
|
|
126
|
+
</Fqy>
|
|
127
|
+
<Ser>
|
|
128
|
+
<SerUid>
|
|
129
|
+
<UniUid region="LF">
|
|
130
|
+
<txtName>PUJAUT TWR</txtName>
|
|
131
|
+
</UniUid>
|
|
132
|
+
<codeType>AFIS</codeType>
|
|
133
|
+
<noSeq>2</noSeq>
|
|
134
|
+
</SerUid>
|
|
135
|
+
<Stt>
|
|
136
|
+
<codeWorkHr>H24</codeWorkHr>
|
|
137
|
+
</Stt>
|
|
138
|
+
<txtRmk>service remarks</txtRmk>
|
|
139
|
+
</Ser>
|
|
140
|
+
<Fqy>
|
|
141
|
+
<FqyUid>
|
|
142
|
+
<SerUid>
|
|
143
|
+
<UniUid region="LF">
|
|
144
|
+
<txtName>PUJAUT TWR</txtName>
|
|
145
|
+
</UniUid>
|
|
146
|
+
<codeType>AFIS</codeType>
|
|
147
|
+
<noSeq>2</noSeq>
|
|
148
|
+
</SerUid>
|
|
149
|
+
<valFreqTrans>123.35</valFreqTrans>
|
|
150
|
+
</FqyUid>
|
|
151
|
+
<valFreqRec>124.1</valFreqRec>
|
|
152
|
+
<uomFreq>MHZ</uomFreq>
|
|
153
|
+
<Ftt>
|
|
154
|
+
<codeWorkHr>H24</codeWorkHr>
|
|
155
|
+
</Ftt>
|
|
156
|
+
<txtRmk>frequency remarks</txtRmk>
|
|
157
|
+
<Cdl>
|
|
158
|
+
<txtCallSign>PUJAUT CONTROL</txtCallSign>
|
|
159
|
+
<codeLang>EN</codeLang>
|
|
160
|
+
</Cdl>
|
|
161
|
+
<Cdl>
|
|
162
|
+
<txtCallSign>PUJAUT CONTROLE</txtCallSign>
|
|
163
|
+
<codeLang>FR</codeLang>
|
|
164
|
+
</Cdl>
|
|
165
|
+
</Fqy>
|
|
166
|
+
<Ser>
|
|
167
|
+
<SerUid>
|
|
168
|
+
<UniUid region="LF">
|
|
169
|
+
<txtName>PUJAUT TWR</txtName>
|
|
170
|
+
</UniUid>
|
|
171
|
+
<codeType>APP</codeType>
|
|
172
|
+
<noSeq>1</noSeq>
|
|
173
|
+
</SerUid>
|
|
174
|
+
<Stt>
|
|
175
|
+
<codeWorkHr>H24</codeWorkHr>
|
|
176
|
+
</Stt>
|
|
177
|
+
<txtRmk>service remarks</txtRmk>
|
|
178
|
+
</Ser>
|
|
179
|
+
<Fqy>
|
|
180
|
+
<FqyUid>
|
|
181
|
+
<SerUid>
|
|
182
|
+
<UniUid region="LF">
|
|
183
|
+
<txtName>PUJAUT TWR</txtName>
|
|
184
|
+
</UniUid>
|
|
185
|
+
<codeType>APP</codeType>
|
|
186
|
+
<noSeq>1</noSeq>
|
|
187
|
+
</SerUid>
|
|
188
|
+
<valFreqTrans>123.35</valFreqTrans>
|
|
189
|
+
</FqyUid>
|
|
190
|
+
<valFreqRec>124.1</valFreqRec>
|
|
191
|
+
<uomFreq>MHZ</uomFreq>
|
|
192
|
+
<Ftt>
|
|
193
|
+
<codeWorkHr>H24</codeWorkHr>
|
|
194
|
+
</Ftt>
|
|
195
|
+
<txtRmk>frequency remarks</txtRmk>
|
|
196
|
+
<Cdl>
|
|
197
|
+
<txtCallSign>PUJAUT CONTROL</txtCallSign>
|
|
198
|
+
<codeLang>EN</codeLang>
|
|
199
|
+
</Cdl>
|
|
200
|
+
<Cdl>
|
|
201
|
+
<txtCallSign>PUJAUT CONTROLE</txtCallSign>
|
|
202
|
+
<codeLang>FR</codeLang>
|
|
203
|
+
</Cdl>
|
|
204
|
+
</Fqy>
|
|
205
|
+
END
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it "builds correct minimal OFMX" do
|
|
209
|
+
AIXM.ofmx!
|
|
210
|
+
subject.airport = subject.remarks = nil
|
|
211
|
+
subject.instance_variable_set(:'@services', [])
|
|
212
|
+
subject.to_xml.must_equal <<~END
|
|
213
|
+
<!-- Unit: PUJAUT TWR -->
|
|
214
|
+
<Uni source="LF|GEN|0.0 FACTORY|0|0">
|
|
215
|
+
<UniUid region="LF">
|
|
216
|
+
<txtName>PUJAUT TWR</txtName>
|
|
217
|
+
</UniUid>
|
|
218
|
+
<OrgUid region="LF">
|
|
219
|
+
<txtName>FRANCE</txtName>
|
|
220
|
+
</OrgUid>
|
|
221
|
+
<codeType>TWR</codeType>
|
|
222
|
+
<codeClass>ICAO</codeClass>
|
|
223
|
+
</Uni>
|
|
224
|
+
END
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require_relative '../../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe AIXM::Feature do
|
|
4
|
+
subject do
|
|
5
|
+
AIXM::Feature.send(:new)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe :source= do
|
|
9
|
+
it "fails on invalid values" do
|
|
10
|
+
[:foobar, 123].wont_be_written_to subject, :source
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "accepts nil value" do
|
|
14
|
+
[nil].must_be_written_to subject, :source
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe :region= do
|
|
19
|
+
it "fails on invalid values" do
|
|
20
|
+
-> { subject.region = 123 }.must_raise ArgumentError
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "accepts nil value" do
|
|
24
|
+
subject.tap { |s| s.region = nil }.region.must_be_nil
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "upcases value" do
|
|
28
|
+
subject.tap { |s| s.region = 'lol' }.region.must_equal 'LOL'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "falls back to configuration default" do
|
|
32
|
+
AIXM.config.region = 'foo'
|
|
33
|
+
subject.region.must_equal 'FOO'
|
|
34
|
+
AIXM.config.region = nil
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe :== do
|
|
39
|
+
it "recognizes features with identical UID as equal" do
|
|
40
|
+
a = AIXM::Factory.organisation
|
|
41
|
+
b = AIXM::Factory.organisation
|
|
42
|
+
a.must_equal b
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "recognizes features with different UID as unequal" do
|
|
46
|
+
a = AIXM::Factory.polygon_airspace
|
|
47
|
+
b = AIXM::Factory.circle_airspace
|
|
48
|
+
a.wont_equal b
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "recognizes objects of different class as unequal" do
|
|
52
|
+
a = AIXM::Factory.organisation
|
|
53
|
+
b = :oggy
|
|
54
|
+
a.wont_equal b
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -4,243 +4,252 @@ using AIXM::Refinements
|
|
|
4
4
|
|
|
5
5
|
describe AIXM::Refinements do
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe 'Array#to_digest' do
|
|
15
|
-
it "must digest single string" do
|
|
16
|
-
%w(a).to_digest.must_equal 140922416
|
|
17
|
-
end
|
|
7
|
+
context Array do
|
|
8
|
+
describe :to_digest do
|
|
9
|
+
it "must digest single string" do
|
|
10
|
+
%w(a).to_digest.must_equal "1f40fc92"
|
|
11
|
+
end
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
it "must digest double string" do
|
|
14
|
+
%w(a b).to_digest.must_equal "3c075e5f"
|
|
15
|
+
end
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
it "must digest integer" do
|
|
18
|
+
[5].to_digest.must_equal "06df0537"
|
|
19
|
+
end
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
it "must digest nested array" do
|
|
22
|
+
[1, [2, 3]].to_digest.must_equal "e9609e81"
|
|
23
|
+
end
|
|
30
24
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
it "must digest float" do
|
|
26
|
+
[5.0].to_digest.must_equal "78fc651d"
|
|
27
|
+
end
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
it "must digest boolean" do
|
|
30
|
+
[true, false].to_digest.must_equal "79bdc67a"
|
|
31
|
+
end
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
it "must digest nil" do
|
|
34
|
+
[nil].to_digest.must_equal "cf83e135"
|
|
35
|
+
end
|
|
41
36
|
end
|
|
42
37
|
end
|
|
43
38
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
context Hash do
|
|
40
|
+
describe :lookup do
|
|
41
|
+
subject do
|
|
42
|
+
{ one: 1, two: 2, three: 3, four: :three }
|
|
43
|
+
end
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
it "must return value for key if key is present" do
|
|
46
|
+
subject.lookup(:one).must_equal 1
|
|
47
|
+
end
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
it "must return value if key is not found but value is present" do
|
|
50
|
+
subject.lookup(1).must_equal 1
|
|
51
|
+
end
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
it "must return value for key if both key and value are present" do
|
|
54
|
+
subject.lookup(:three).must_equal 3
|
|
55
|
+
end
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
it "returns default if neither key nor value are present" do
|
|
58
|
+
subject.lookup(:foo, :default).must_equal :default
|
|
59
|
+
subject.lookup(:foo, nil).must_be_nil
|
|
60
|
+
end
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
it "fails if neither key, value nor default are present" do
|
|
63
|
+
-> { subject.lookup(:foo) }.must_raise KeyError
|
|
64
|
+
end
|
|
68
65
|
end
|
|
69
66
|
end
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
context String do
|
|
69
|
+
describe :indent do
|
|
70
|
+
it "must indent single line string" do
|
|
71
|
+
'foobar'.indent(2).must_equal ' foobar'
|
|
72
|
+
end
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
it "must indent multi line string" do
|
|
75
|
+
"foo\nbar".indent(2).must_equal " foo\n bar"
|
|
76
|
+
"foo\nbar\n".indent(2).must_equal " foo\n bar\n"
|
|
77
|
+
end
|
|
79
78
|
end
|
|
80
|
-
end
|
|
81
79
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
describe :uptrans do
|
|
81
|
+
it "must transliterate invalid characters" do
|
|
82
|
+
'DÉJÀ SCHÖN'.uptrans.must_equal 'DEJA SCHOEN'
|
|
83
|
+
end
|
|
85
84
|
end
|
|
86
|
-
end
|
|
87
85
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
describe :to_dd do
|
|
87
|
+
it "must convert +6.2 DMS to DD" do
|
|
88
|
+
%q(12°34'56.78").to_dd.must_equal 12.58243888888889
|
|
89
|
+
%q(12 34 56.78).to_dd.must_equal 12.58243888888889
|
|
90
|
+
%q(123456.78).to_dd.must_equal 12.58243888888889
|
|
91
|
+
end
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
it "must convert -6.2 DMS to DD" do
|
|
94
|
+
%q(-12°34'56.78").to_dd.must_equal(-12.58243888888889)
|
|
95
|
+
%q(-12 34 56.78).to_dd.must_equal(-12.58243888888889)
|
|
96
|
+
%q(-123456.78).to_dd.must_equal(-12.58243888888889)
|
|
97
|
+
end
|
|
100
98
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
99
|
+
it "must convert +7.2 DMS to DD" do
|
|
100
|
+
%q(111°22'33.44").to_dd.must_equal 111.37595555555555
|
|
101
|
+
%q(111 22 33.44).to_dd.must_equal 111.37595555555555
|
|
102
|
+
%q(1112233.44).to_dd.must_equal 111.37595555555555
|
|
103
|
+
end
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
it "must convert -7.2 DMS to DD" do
|
|
106
|
+
%q(-111°22'33.44").to_dd.must_equal(-111.37595555555555)
|
|
107
|
+
%q(-111 22 33.44).to_dd.must_equal(-111.37595555555555)
|
|
108
|
+
%q(-1112233.44).to_dd.must_equal(-111.37595555555555)
|
|
109
|
+
end
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
it "must convert +6.1 DMS to DD" do
|
|
112
|
+
%q(12°34'56.7").to_dd.must_equal 12.582416666666667
|
|
113
|
+
%q(12 34 56.7).to_dd.must_equal 12.582416666666667
|
|
114
|
+
%q(123456.7).to_dd.must_equal 12.582416666666667
|
|
115
|
+
end
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
117
|
+
it "must convert -6.1 DMS to DD" do
|
|
118
|
+
%q(-12°34'56.7").to_dd.must_equal(-12.582416666666667)
|
|
119
|
+
%q(-12 34 56.7).to_dd.must_equal(-12.582416666666667)
|
|
120
|
+
%q(-123456.7).to_dd.must_equal(-12.582416666666667)
|
|
121
|
+
end
|
|
124
122
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
it "must convert +7.1 DMS to DD" do
|
|
124
|
+
%q(111°22'33.4").to_dd.must_equal 111.37594444444444
|
|
125
|
+
%q(111 22 33.4).to_dd.must_equal 111.37594444444444
|
|
126
|
+
%q(1112233.4).to_dd.must_equal 111.37594444444444
|
|
127
|
+
end
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
it "must convert +7.1 DMS to DD" do
|
|
130
|
+
%q(-111°22'33.4").to_dd.must_equal(-111.37594444444444)
|
|
131
|
+
%q(-111 22 33.4).to_dd.must_equal(-111.37594444444444)
|
|
132
|
+
%q(-1112233.4).to_dd.must_equal(-111.37594444444444)
|
|
133
|
+
end
|
|
136
134
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
it "must convert +6.0 DMS to DD" do
|
|
136
|
+
%q(12°34'56").to_dd.must_equal 12.582222222222223
|
|
137
|
+
%q(12 34 56).to_dd.must_equal 12.582222222222223
|
|
138
|
+
%q(123456).to_dd.must_equal 12.582222222222223
|
|
139
|
+
end
|
|
142
140
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
141
|
+
it "must convert -6.0 DMS to DD" do
|
|
142
|
+
%q(-12°34'56").to_dd.must_equal(-12.582222222222223)
|
|
143
|
+
%q(-12 34 56).to_dd.must_equal(-12.582222222222223)
|
|
144
|
+
%q(-123456).to_dd.must_equal(-12.582222222222223)
|
|
145
|
+
end
|
|
148
146
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
it "must convert +7.0 DMS to DD" do
|
|
148
|
+
%q(111°22'33").to_dd.must_equal 111.37583333333333
|
|
149
|
+
%q(111 22 33).to_dd.must_equal 111.37583333333333
|
|
150
|
+
%q(1112233).to_dd.must_equal 111.37583333333333
|
|
151
|
+
end
|
|
154
152
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
it "must convert +7.0 DMS to DD" do
|
|
154
|
+
%q(-111°22'33").to_dd.must_equal(-111.37583333333333)
|
|
155
|
+
%q(-111 22 33).to_dd.must_equal(-111.37583333333333)
|
|
156
|
+
%q(-1112233).to_dd.must_equal(-111.37583333333333)
|
|
157
|
+
end
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
it "must do all possible roundtrip conversions" do
|
|
160
|
+
if ENV['SPEC_SCOPE'] == 'all'
|
|
161
|
+
2.times.with_index do |degrees|
|
|
162
|
+
60.times.with_index do |minutes|
|
|
163
|
+
60.times.with_index do |seconds|
|
|
164
|
+
100.times.with_index do |fractions|
|
|
165
|
+
subject = %q(%03d°%02d'%02d.%02d") % [degrees, minutes, seconds, fractions]
|
|
166
|
+
subject.to_dd.to_dms.must_equal subject
|
|
167
|
+
end
|
|
169
168
|
end
|
|
170
169
|
end
|
|
171
170
|
end
|
|
171
|
+
else
|
|
172
|
+
skip
|
|
172
173
|
end
|
|
173
|
-
else
|
|
174
|
-
skip
|
|
175
174
|
end
|
|
176
175
|
end
|
|
177
176
|
end
|
|
178
177
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
context Float do
|
|
179
|
+
describe :to_rad do
|
|
180
|
+
it "must convert correctly" do
|
|
181
|
+
0.0.to_rad.must_equal 0
|
|
182
|
+
180.0.to_rad.must_equal Math::PI
|
|
183
|
+
-123.0.to_rad.must_equal(-2.1467549799530254)
|
|
184
|
+
end
|
|
182
185
|
end
|
|
183
186
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
describe :to_dms do
|
|
188
|
+
it "must convert +1. DD to DMS" do
|
|
189
|
+
1.37595556.to_dms.must_equal %q(001°22'33.44")
|
|
190
|
+
end
|
|
187
191
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
192
|
+
it "must convert -1. DD to DMS" do
|
|
193
|
+
-1.37595556.to_dms.must_equal %q(-001°22'33.44")
|
|
194
|
+
end
|
|
191
195
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
196
|
+
it "must convert +2. DD to DMS" do
|
|
197
|
+
11.37595556.to_dms.must_equal %q(011°22'33.44")
|
|
198
|
+
end
|
|
195
199
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
it "must convert -2. DD to DMS" do
|
|
201
|
+
-11.37595556.to_dms.must_equal %q(-011°22'33.44")
|
|
202
|
+
end
|
|
199
203
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
it "must convert +3. DD to DMS" do
|
|
205
|
+
111.37595556.to_dms.must_equal %q(111°22'33.44")
|
|
206
|
+
end
|
|
203
207
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
it "must convert -3. DD to DMS" do
|
|
209
|
+
-111.37595556.to_dms.must_equal %q(-111°22'33.44")
|
|
210
|
+
end
|
|
207
211
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
212
|
+
it "must convert DD to DMS with degrees only" do
|
|
213
|
+
11.0.to_dms.must_equal %q(011°00'00.00")
|
|
214
|
+
end
|
|
211
215
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
216
|
+
it "must convert DD to DMS with degrees and minutes only" do
|
|
217
|
+
11.36666667.to_dms.must_equal %q(011°22'00.00")
|
|
218
|
+
end
|
|
215
219
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
it "must convert DD to DMS with tenth of seconds only" do
|
|
221
|
+
1.37594444.to_dms.must_equal %q(001°22'33.40")
|
|
222
|
+
end
|
|
219
223
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
it "must convert DD to DMS with whole seconds only" do
|
|
225
|
+
1.37583333.to_dms.must_equal %q(001°22'33.00")
|
|
226
|
+
end
|
|
223
227
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
end
|
|
228
|
+
it "must convert DD to two zero padded DMS" do
|
|
229
|
+
1.37595556.to_dms(2).must_equal %q(01°22'33.44")
|
|
230
|
+
end
|
|
228
231
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
+
it "must convert DD to no zero padded DMS" do
|
|
233
|
+
1.37595556.to_dms(0).must_equal %q(1°22'33.44")
|
|
234
|
+
end
|
|
232
235
|
end
|
|
233
236
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
+
describe :to_km do
|
|
238
|
+
it "must convert km to km" do
|
|
239
|
+
10.3.to_km(from: :km).must_equal 10.3
|
|
240
|
+
end
|
|
237
241
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
242
|
+
it "must convert m to km" do
|
|
243
|
+
10700.0.to_km(from: :m).must_be_close_to 10.7
|
|
244
|
+
end
|
|
241
245
|
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
it "must convert nm to km" do
|
|
247
|
+
3.7.to_km(from: :nm).must_be_close_to 6.8524
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
it "must convert ft to km" do
|
|
251
|
+
3200.0.to_km(from: :ft).must_be_close_to 0.97536
|
|
252
|
+
end
|
|
244
253
|
end
|
|
245
254
|
end
|
|
246
255
|
|