aixm 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ describe AIXM::Component::Geometry::Circle do
4
4
  subject do
5
5
  AIXM.circle(
6
6
  center_xy: AIXM.xy(lat: 12.12345678, long: -23.12345678),
7
- radius: 15
7
+ radius: AIXM.d(15, :km)
8
8
  )
9
9
  end
10
10
 
@@ -20,11 +20,7 @@ describe AIXM::Component::Geometry::Circle do
20
20
 
21
21
  describe :radius= do
22
22
  it "fails on invalid values" do
23
- [nil, 0, -5].wont_be_written_to subject, :radius
24
- end
25
-
26
- it "converts Numeric to Float" do
27
- subject.tap { |s| s.radius = 5 }.radius.must_equal 5.0
23
+ [nil, 0, 2, AIXM.d(0, :m)].wont_be_written_to subject, :radius
28
24
  end
29
25
  end
30
26
 
@@ -38,7 +34,7 @@ describe AIXM::Component::Geometry::Circle do
38
34
  it "builds correct AIXM for circles not near the equator" do
39
35
  subject = AIXM.circle(
40
36
  center_xy: AIXM.xy(lat: 11.1, long: 22.2),
41
- radius: 25
37
+ radius: AIXM.d(25, :km)
42
38
  )
43
39
  AIXM.aixm!
44
40
  subject.to_xml.must_equal <<~END
@@ -56,7 +52,7 @@ describe AIXM::Component::Geometry::Circle do
56
52
  it "builds correct AIXM for circles near the equator" do
57
53
  subject = AIXM.circle(
58
54
  center_xy: AIXM.xy(lat: -0.0005, long: -22.2),
59
- radius: 50
55
+ radius: AIXM.d(50, :km)
60
56
  )
61
57
  AIXM.aixm!
62
58
  subject.to_xml.must_equal <<~END
@@ -272,7 +272,7 @@ describe AIXM::Component::Geometry do
272
272
  context "circle" do
273
273
  subject do
274
274
  AIXM.geometry.tap do |geometry|
275
- geometry << AIXM.circle(center_xy: AIXM.xy(lat: 11, long: 22), radius: 10)
275
+ geometry << AIXM.circle(center_xy: AIXM.xy(lat: 11, long: 22), radius: AIXM.d(10, :km))
276
276
  end
277
277
  end
278
278
 
@@ -301,7 +301,7 @@ describe AIXM::Component::Geometry do
301
301
  context "circle with additional elements" do
302
302
  subject do
303
303
  AIXM.geometry.tap do |geometry|
304
- geometry << AIXM.circle(center_xy: AIXM.xy(lat: 11, long: 22), radius: 10)
304
+ geometry << AIXM.circle(center_xy: AIXM.xy(lat: 11, long: 22), radius: AIXM.d(10, :km))
305
305
  geometry << AIXM.point(xy: AIXM.xy(lat: 22, long: 33))
306
306
  end
307
307
  end
@@ -29,30 +29,22 @@ describe AIXM::Component::Helipad do
29
29
 
30
30
  describe :length= do
31
31
  it "fails on invalid values" do
32
- [:foobar, 0, -1].wont_be_written_to subject, :length
32
+ [:foobar, 0, 1, AIXM.d(0, :m)].wont_be_written_to subject, :length
33
33
  end
34
34
 
35
35
  it "accepts nil value" do
36
36
  [nil].must_be_written_to subject, :length
37
37
  end
38
-
39
- it "converts valid Numeric values to Integer" do
40
- subject.tap { |s| s.length = 1000.5 }.length.must_equal 1000
41
- end
42
38
  end
43
39
 
44
40
  describe :width= do
45
41
  it "fails on invalid values" do
46
- [:foobar, 0, -1].wont_be_written_to subject, :width
42
+ [:foobar, 0, 1, AIXM.d(0, :m)].wont_be_written_to subject, :width
47
43
  end
48
44
 
49
45
  it "accepts nil value" do
50
46
  [nil].must_be_written_to subject, :width
51
47
  end
52
-
53
- it "converts valid Numeric values to Integer" do
54
- subject.tap { |s| s.width = 150.5 }.width.must_equal 150
55
- end
56
48
  end
57
49
 
58
50
  describe :composition= do
@@ -30,30 +30,22 @@ describe AIXM::Component::Runway do
30
30
 
31
31
  describe :length= do
32
32
  it "fails on invalid values" do
33
- [:foobar, 0, -1].wont_be_written_to subject, :length
33
+ [:foobar, 0, 1, AIXM.d(0, :m)].wont_be_written_to subject, :length
34
34
  end
35
35
 
36
36
  it "accepts nil value" do
37
37
  [nil].must_be_written_to subject, :length
38
38
  end
39
-
40
- it "converts valid values to integer" do
41
- subject.tap { |s| s.length = 1000.5 }.length.must_equal 1000
42
- end
43
39
  end
44
40
 
45
41
  describe :width= do
46
42
  it "fails on invalid values" do
47
- [:foobar, 0, -1].wont_be_written_to subject, :width
43
+ [:foobar, 0, 1, AIXM.d(0, :m)].wont_be_written_to subject, :width
48
44
  end
49
45
 
50
46
  it "accepts nil value" do
51
47
  [nil].must_be_written_to subject, :width
52
48
  end
53
-
54
- it "converts valid values to integer" do
55
- subject.tap { |s| s.width = 150.5 }.width.must_equal 150
56
- end
57
49
  end
58
50
 
59
51
  describe :composition= do
@@ -310,17 +302,13 @@ describe AIXM::Component::Runway::Direction do
310
302
 
311
303
  describe :displaced_threshold= do
312
304
  it "fails on invalid values" do
313
- [:foobar].wont_be_written_to subject, :displaced_threshold
314
- end
315
-
316
- it "converts valid Numeric values to Integer" do
317
- subject.tap { |s| s.displaced_threshold = 222.0 }.displaced_threshold.must_equal 222
305
+ [:foobar, 1, AIXM.d(0, :m)].wont_be_written_to subject, :displaced_threshold
318
306
  end
319
307
 
320
308
  it "converts coordinates to distance" do
321
309
  subject.xy = AIXM.xy(lat: %q(43°59'54.71"N), long: %q(004°45'28.35"E))
322
310
  subject.displaced_threshold = AIXM.xy(lat: %q(43°59'48.47"N), long: %q(004°45'30.62"E))
323
- subject.displaced_threshold.must_equal 199
311
+ subject.displaced_threshold.must_equal AIXM.d(199, :m)
324
312
  end
325
313
  end
326
314
 
@@ -0,0 +1,130 @@
1
+ require_relative '../../spec_helper'
2
+
3
+ describe AIXM::D do
4
+ subject do
5
+ AIXM::Factory.d
6
+ end
7
+
8
+ describe :dist= do
9
+ it "fails on invalid values" do
10
+ [:foobar, -1].wont_be_written_to subject, :dist
11
+ end
12
+
13
+ it "converts Numeric to Float" do
14
+ subject.tap { |s| s.dist = 5 }.dist.must_equal 5.0
15
+ end
16
+ end
17
+
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 = "NM" }.unit.must_equal :nm
25
+ end
26
+ end
27
+
28
+ describe :<=> do
29
+ it "recognizes objects with identical unit and distance as equal" do
30
+ a = AIXM.d(123, :m)
31
+ b = AIXM.d(123.0, 'M')
32
+ a.must_equal b
33
+ end
34
+
35
+ it "recognizes objects with different units and converted distance as equal" do
36
+ a = AIXM.d(123, :m)
37
+ b = AIXM.d(403.54330709, 'FT')
38
+ a.must_equal b
39
+ end
40
+
41
+ it "recognizes objects with different units and identical distance as unequal" do
42
+ a = AIXM.d(123, :m)
43
+ b = AIXM.d(123, :ft)
44
+ a.wont_equal b
45
+ end
46
+
47
+ it "recognizes objects of different class as unequal" do
48
+ a = AIXM.d(123, :m)
49
+ b = :oggy
50
+ a.wont_equal b
51
+ end
52
+ end
53
+
54
+ describe :to_ft do
55
+ it "leaves feet untouched" do
56
+ subject = AIXM.d(2, :ft)
57
+ subject.to_ft.must_be_same_as subject
58
+ end
59
+
60
+ it "converts kilometers to feet" do
61
+ AIXM.d(0.5, :km).to_ft.must_equal AIXM.d(1640.4199475, :ft)
62
+ end
63
+
64
+ it "converts meters to feet" do
65
+ AIXM.d(200, :m).to_ft.must_equal AIXM.d(656.167979, :ft)
66
+ end
67
+
68
+ it "converts nautical miles to feet" do
69
+ AIXM.d(0.5, :nm).to_ft.must_equal AIXM.d(3038.05774277, :ft)
70
+ end
71
+ end
72
+
73
+ describe :to_km do
74
+ it "leaves kilometers untouched" do
75
+ subject = AIXM.d(2, :km)
76
+ subject.to_km.must_be_same_as subject
77
+ end
78
+
79
+ it "converts feet to kilometers" do
80
+ AIXM.d(10_000, :ft).to_km.must_equal AIXM.d(3.048, :km)
81
+ end
82
+
83
+ it "converts meters to kilometers" do
84
+ AIXM.d(2000, :m).to_km.must_equal AIXM.d(2, :km)
85
+ end
86
+
87
+ it "converts nautical miles to kilometers" do
88
+ AIXM.d(10, :nm).to_km.must_equal AIXM.d(18.52, :km)
89
+ end
90
+ end
91
+
92
+ describe :to_m do
93
+ it "leaves meters untouched" do
94
+ subject = AIXM.d(2, :m)
95
+ subject.to_m.must_be_same_as subject
96
+ end
97
+
98
+ it "converts feet to meters" do
99
+ AIXM.d(500, :ft).to_m.must_equal AIXM.d(152.4, :m)
100
+ end
101
+
102
+ it "converts kilometers to meters" do
103
+ AIXM.d(1.3, :km).to_m.must_equal AIXM.d(1300, :m)
104
+ end
105
+
106
+ it "converts nautical miles to meters" do
107
+ AIXM.d(0.8, :nm).to_m.must_equal AIXM.d(1481.6, :m)
108
+ end
109
+ end
110
+
111
+ describe :to_nm do
112
+ it "leaves nautical miles untouched" do
113
+ subject = AIXM.d(2, :nm)
114
+ subject.to_nm.must_be_same_as subject
115
+ end
116
+
117
+ it "converts feet to nautical miles" do
118
+ AIXM.d(11_000, :ft).to_nm.must_equal AIXM.d(1.81036717, :nm)
119
+ end
120
+
121
+ it "converts kilometers to nautical miles" do
122
+ AIXM.d(17, :km).to_nm.must_equal AIXM.d(9.17926565, :nm)
123
+ end
124
+
125
+ it "converts meters to nautical miles" do
126
+ AIXM.d(5800, :m).to_nm.must_equal AIXM.d(3.13174946, :nm)
127
+ end
128
+ end
129
+
130
+ end
@@ -27,7 +27,7 @@ describe AIXM::Document do
27
27
 
28
28
  describe :created_at= do
29
29
  it "fails on invalid values" do
30
- [:foobar, 123].wont_be_written_to subject, :created_at
30
+ ['foobar', '2018-01-77'].wont_be_written_to subject, :created_at
31
31
  end
32
32
 
33
33
  it "parses dates and times" do
@@ -49,7 +49,7 @@ describe AIXM::Document do
49
49
 
50
50
  describe :effective_at= do
51
51
  it "fails on invalid values" do
52
- [:foobar, 123].wont_be_written_to subject, :effective_at
52
+ ['foobar', '2018-01-77'].wont_be_written_to subject, :effective_at
53
53
  end
54
54
 
55
55
  it "parses dates and times" do
@@ -617,6 +617,98 @@ describe AIXM::Document do
617
617
  </Ttt>
618
618
  <txtRmk>vortac navaid</txtRmk>
619
619
  </Tcn>
620
+ <!-- Obstacle: [tower] 48.85825000N 002.29458889E EIFFEL TOWER -->
621
+ <Obs>
622
+ <ObsUid>
623
+ <geoLat>485129.70N</geoLat>
624
+ <geoLong>0021740.52E</geoLong>
625
+ </ObsUid>
626
+ <txtName>EIFFEL TOWER</txtName>
627
+ <txtDescrType>TOWER</txtDescrType>
628
+ <codeGroup>N</codeGroup>
629
+ <codeLgt>Y</codeLgt>
630
+ <txtDescrLgt>red strobes</txtDescrLgt>
631
+ <codeDatum>WGE</codeDatum>
632
+ <valGeoAccuracy>2</valGeoAccuracy>
633
+ <uomGeoAccuracy>M</uomGeoAccuracy>
634
+ <valElev>1187</valElev>
635
+ <valElevAccuracy>3</valElevAccuracy>
636
+ <valHgt>1063</valHgt>
637
+ <uomDistVer>FT</uomDistVer>
638
+ <txtRmk>Temporary light installations (white strobes, gyro light etc)</txtRmk>
639
+ </Obs>
640
+ <!-- Obstacle: [wind_turbine] 44.67501389N 004.87256667E LA TEISSONIERE 1 -->
641
+ <Obs>
642
+ <ObsUid>
643
+ <geoLat>444030.05N</geoLat>
644
+ <geoLong>0045221.24E</geoLong>
645
+ </ObsUid>
646
+ <txtName>LA TEISSONIERE 1</txtName>
647
+ <txtDescrType>WINDTURBINE</txtDescrType>
648
+ <codeGroup>Y</codeGroup>
649
+ <codeLgt>N</codeLgt>
650
+ <codeDatum>WGE</codeDatum>
651
+ <valGeoAccuracy>50</valGeoAccuracy>
652
+ <uomGeoAccuracy>M</uomGeoAccuracy>
653
+ <valElev>1764</valElev>
654
+ <valElevAccuracy>33</valElevAccuracy>
655
+ <valHgt>262</valHgt>
656
+ <uomDistVer>FT</uomDistVer>
657
+ </Obs>
658
+ <!-- Obstacle: [wind_turbine] 44.67946667N 004.87381111E LA TEISSONIERE 2 -->
659
+ <Obs>
660
+ <ObsUid>
661
+ <geoLat>444046.08N</geoLat>
662
+ <geoLong>0045225.72E</geoLong>
663
+ </ObsUid>
664
+ <txtName>LA TEISSONIERE 2</txtName>
665
+ <txtDescrType>WINDTURBINE</txtDescrType>
666
+ <codeGroup>Y</codeGroup>
667
+ <codeLgt>N</codeLgt>
668
+ <codeDatum>WGE</codeDatum>
669
+ <valGeoAccuracy>50</valGeoAccuracy>
670
+ <uomGeoAccuracy>M</uomGeoAccuracy>
671
+ <valElev>1738</valElev>
672
+ <valElevAccuracy>33</valElevAccuracy>
673
+ <valHgt>262</valHgt>
674
+ <uomDistVer>FT</uomDistVer>
675
+ </Obs>
676
+ <!-- Obstacle: [mast] 52.29639722N 002.10675278W DROITWICH LW NORTH -->
677
+ <Obs>
678
+ <ObsUid>
679
+ <geoLat>521747.03N</geoLat>
680
+ <geoLong>0020624.31W</geoLong>
681
+ </ObsUid>
682
+ <txtName>DROITWICH LW NORTH</txtName>
683
+ <txtDescrType>MAST</txtDescrType>
684
+ <codeGroup>Y</codeGroup>
685
+ <codeLgt>N</codeLgt>
686
+ <codeDatum>WGE</codeDatum>
687
+ <valGeoAccuracy>0</valGeoAccuracy>
688
+ <uomGeoAccuracy>M</uomGeoAccuracy>
689
+ <valElev>848</valElev>
690
+ <valElevAccuracy>0</valElevAccuracy>
691
+ <valHgt>700</valHgt>
692
+ <uomDistVer>FT</uomDistVer>
693
+ </Obs>
694
+ <!-- Obstacle: [mast] 52.29457778N 002.10568611W DROITWICH LW NORTH -->
695
+ <Obs>
696
+ <ObsUid>
697
+ <geoLat>521740.48N</geoLat>
698
+ <geoLong>0020620.47W</geoLong>
699
+ </ObsUid>
700
+ <txtName>DROITWICH LW NORTH</txtName>
701
+ <txtDescrType>MAST</txtDescrType>
702
+ <codeGroup>Y</codeGroup>
703
+ <codeLgt>N</codeLgt>
704
+ <codeDatum>WGE</codeDatum>
705
+ <valGeoAccuracy>0</valGeoAccuracy>
706
+ <uomGeoAccuracy>M</uomGeoAccuracy>
707
+ <valElev>848</valElev>
708
+ <valElevAccuracy>0</valElevAccuracy>
709
+ <valHgt>700</valHgt>
710
+ <uomDistVer>FT</uomDistVer>
711
+ </Obs>
620
712
  </AIXM-Snapshot>
621
713
  END
622
714
  end
@@ -1175,6 +1267,127 @@ describe AIXM::Document do
1175
1267
  </Ttt>
1176
1268
  <txtRmk>vortac navaid</txtRmk>
1177
1269
  </Tcn>
1270
+ <!-- Obstacle: [tower] 48.85825000N 002.29458889E EIFFEL TOWER -->
1271
+ <Obs>
1272
+ <ObsUid>
1273
+ <geoLat>48.85825000N</geoLat>
1274
+ <geoLong>002.29458889E</geoLong>
1275
+ </ObsUid>
1276
+ <txtName>EIFFEL TOWER</txtName>
1277
+ <codeType>TOWER</codeType>
1278
+ <codeLgt>Y</codeLgt>
1279
+ <txtDescrLgt>red strobes</txtDescrLgt>
1280
+ <codeDatum>WGE</codeDatum>
1281
+ <valGeoAccuracy>2</valGeoAccuracy>
1282
+ <uomGeoAccuracy>M</uomGeoAccuracy>
1283
+ <valElev>1187</valElev>
1284
+ <valElevAccuracy>3</valElevAccuracy>
1285
+ <valHgt>1063</valHgt>
1286
+ <codeHgtAccuracy>Y</codeHgtAccuracy>
1287
+ <uomDistVer>FT</uomDistVer>
1288
+ <valRadius>88</valRadius>
1289
+ <uomRadius>M</uomRadius>
1290
+ <datetimeValidWef>2018-01-01T12:00:00+01:00</datetimeValidWef>
1291
+ <datetimeValidTil>2019-01-01T12:00:00+01:00</datetimeValidTil>
1292
+ <txtRmk>Temporary light installations (white strobes, gyro light etc)</txtRmk>
1293
+ </Obs>
1294
+ <!-- Obstacle: [wind_turbine] 44.67501389N 004.87256667E LA TEISSONIERE 1 -->
1295
+ <Obs>
1296
+ <ObsUid>
1297
+ <geoLat>44.67501389N</geoLat>
1298
+ <geoLong>004.87256667E</geoLong>
1299
+ </ObsUid>
1300
+ <txtName>LA TEISSONIERE 1</txtName>
1301
+ <codeType>WINDTURBINE</codeType>
1302
+ <codeLgt>N</codeLgt>
1303
+ <codeMarking>N</codeMarking>
1304
+ <codeDatum>WGE</codeDatum>
1305
+ <valGeoAccuracy>50</valGeoAccuracy>
1306
+ <uomGeoAccuracy>M</uomGeoAccuracy>
1307
+ <valElev>1764</valElev>
1308
+ <valElevAccuracy>33</valElevAccuracy>
1309
+ <valHgt>262</valHgt>
1310
+ <codeHgtAccuracy>N</codeHgtAccuracy>
1311
+ <uomDistVer>FT</uomDistVer>
1312
+ <valRadius>80</valRadius>
1313
+ <uomRadius>M</uomRadius>
1314
+ <codeGroupId>462c8d00-981a-0995-09aa-4ba39161bb41</codeGroupId>
1315
+ <txtGroupName>MIRMANDE EOLIENNES</txtGroupName>
1316
+ </Obs>
1317
+ <!-- Obstacle: [wind_turbine] 44.67946667N 004.87381111E LA TEISSONIERE 2 -->
1318
+ <Obs>
1319
+ <ObsUid>
1320
+ <geoLat>44.67946667N</geoLat>
1321
+ <geoLong>004.87381111E</geoLong>
1322
+ </ObsUid>
1323
+ <txtName>LA TEISSONIERE 2</txtName>
1324
+ <codeType>WINDTURBINE</codeType>
1325
+ <codeLgt>N</codeLgt>
1326
+ <codeMarking>N</codeMarking>
1327
+ <codeDatum>WGE</codeDatum>
1328
+ <valGeoAccuracy>50</valGeoAccuracy>
1329
+ <uomGeoAccuracy>M</uomGeoAccuracy>
1330
+ <valElev>1738</valElev>
1331
+ <valElevAccuracy>33</valElevAccuracy>
1332
+ <valHgt>262</valHgt>
1333
+ <codeHgtAccuracy>N</codeHgtAccuracy>
1334
+ <uomDistVer>FT</uomDistVer>
1335
+ <valRadius>80</valRadius>
1336
+ <uomRadius>M</uomRadius>
1337
+ <codeGroupId>462c8d00-981a-0995-09aa-4ba39161bb41</codeGroupId>
1338
+ <txtGroupName>MIRMANDE EOLIENNES</txtGroupName>
1339
+ </Obs>
1340
+ <!-- Obstacle: [mast] 52.29639722N 002.10675278W DROITWICH LW NORTH -->
1341
+ <Obs>
1342
+ <ObsUid>
1343
+ <geoLat>52.29639722N</geoLat>
1344
+ <geoLong>002.10675278W</geoLong>
1345
+ </ObsUid>
1346
+ <txtName>DROITWICH LW NORTH</txtName>
1347
+ <codeType>MAST</codeType>
1348
+ <codeLgt>N</codeLgt>
1349
+ <codeMarking>N</codeMarking>
1350
+ <codeDatum>WGE</codeDatum>
1351
+ <valGeoAccuracy>0</valGeoAccuracy>
1352
+ <uomGeoAccuracy>M</uomGeoAccuracy>
1353
+ <valElev>848</valElev>
1354
+ <valElevAccuracy>0</valElevAccuracy>
1355
+ <valHgt>700</valHgt>
1356
+ <codeHgtAccuracy>Y</codeHgtAccuracy>
1357
+ <uomDistVer>FT</uomDistVer>
1358
+ <valRadius>200</valRadius>
1359
+ <uomRadius>M</uomRadius>
1360
+ <codeGroupId>18e65683-798d-0941-8de4-cb65a6427035</codeGroupId>
1361
+ <txtGroupName>DROITWICH LONGWAVE ANTENNA</txtGroupName>
1362
+ </Obs>
1363
+ <!-- Obstacle: [mast] 52.29457778N 002.10568611W DROITWICH LW NORTH -->
1364
+ <Obs>
1365
+ <ObsUid>
1366
+ <geoLat>52.29457778N</geoLat>
1367
+ <geoLong>002.10568611W</geoLong>
1368
+ </ObsUid>
1369
+ <txtName>DROITWICH LW NORTH</txtName>
1370
+ <codeType>MAST</codeType>
1371
+ <codeLgt>N</codeLgt>
1372
+ <codeMarking>N</codeMarking>
1373
+ <codeDatum>WGE</codeDatum>
1374
+ <valGeoAccuracy>0</valGeoAccuracy>
1375
+ <uomGeoAccuracy>M</uomGeoAccuracy>
1376
+ <valElev>848</valElev>
1377
+ <valElevAccuracy>0</valElevAccuracy>
1378
+ <valHgt>700</valHgt>
1379
+ <codeHgtAccuracy>Y</codeHgtAccuracy>
1380
+ <uomDistVer>FT</uomDistVer>
1381
+ <valRadius>200</valRadius>
1382
+ <uomRadius>M</uomRadius>
1383
+ <codeGroupId>18e65683-798d-0941-8de4-cb65a6427035</codeGroupId>
1384
+ <txtGroupName>DROITWICH LONGWAVE ANTENNA</txtGroupName>
1385
+ <ObsUidLink>
1386
+ <geoLat>52.29639722N</geoLat>
1387
+ <geoLong>002.10675278W</geoLong>
1388
+ </ObsUidLink>
1389
+ <codeLinkType>CABLE</codeLinkType>
1390
+ </Obs>
1178
1391
  </OFMX-Snapshot>
1179
1392
  END
1180
1393
  end