aixm 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,10 +0,0 @@
1
- module AIXM
2
- class Base
3
- using AIXM::Refinements
4
-
5
- def format_for(*extensions)
6
- extensions >> :ofm ? :ofm : :aixm
7
- end
8
-
9
- end
10
- end
@@ -1,6 +0,0 @@
1
- module AIXM
2
- module Component
3
- class Base < AIXM::Base
4
- end
5
- end
6
- end
@@ -1,46 +0,0 @@
1
- module AIXM
2
- module Component
3
-
4
- ##
5
- # Class layers consists of an optional airspace class and mandatory
6
- # vertical limits.
7
- class ClassLayer < Base
8
- using AIXM::Refinements
9
-
10
- CLASSES = %i(A B C D E F G)
11
-
12
- attr_reader :vertical_limits
13
-
14
- def initialize(class: nil, vertical_limits:)
15
- @klass, @vertical_limits = binding.local_variable_get(:class)&.to_sym, vertical_limits
16
- fail(ArgumentError, "invalid class `#{@klass}'") unless @klass.nil? || CLASSES.include?(@klass)
17
- fail(ArgumentError, "invalid vertical limits") unless @vertical_limits.is_a? AIXM::Component::VerticalLimits
18
- end
19
-
20
- ##
21
- # Read the airspace class
22
- #
23
- # This and other workarounds in the initializer are necessary due to "class"
24
- # being a reserved keyword in Ruby.
25
- def class
26
- @klass
27
- end
28
-
29
- ##
30
- # Digest to identify the payload
31
- def to_digest
32
- [self.class, vertical_limits.to_digest].to_digest
33
- end
34
-
35
- ##
36
- # Render AIXM markup
37
- def to_aixm(*extensions)
38
- builder = Builder::XmlMarkup.new(indent: 2)
39
- builder.codeClass(self.class.to_s) if self.class
40
- builder << vertical_limits.to_aixm(*extensions)
41
- builder.target! # see https://github.com/jimweirich/builder/issues/42
42
- end
43
- end
44
-
45
- end
46
- end
@@ -1,8 +0,0 @@
1
- module AIXM
2
- module Component
3
- class Geometry
4
- class Base < AIXM::Component::Base
5
- end
6
- end
7
- end
8
- end
@@ -1,43 +0,0 @@
1
- module AIXM
2
- module Component
3
-
4
- ##
5
- # Schedules define activity time windows. As of now, only predefined
6
- # schedules are imlemented either by use of explicit (e.g. +:continuous+)
7
- # or short codes (e.g. +:H24+) as listed by the +CODES+ constant.
8
- #
9
- # Shortcuts:
10
- # * +AIXM::H24+ - continuous 24/7
11
- class Schedule < Base
12
- using AIXM::Refinements
13
-
14
- CODES = {
15
- H24: :continuous,
16
- HJ: :sunrise_to_sunset,
17
- HN: :sunset_to_sunrise,
18
- HX: :unspecified,
19
- HO: :operational_request,
20
- NOTAM: :notam
21
- }.freeze
22
-
23
- attr_reader :code
24
-
25
- def initialize(code:)
26
- @code = CODES.lookup(code&.to_sym, nil) || fail(ArgumentError, "invalid code")
27
- end
28
-
29
- ##
30
- # Digest to identify the payload
31
- def to_digest
32
- [code].to_digest
33
- end
34
-
35
- ##
36
- # Render AIXM markup
37
- def to_aixm(*extensions)
38
- Builder::XmlMarkup.new(indent: 2).codeWorkHr(CODES.key(code).to_s)
39
- end
40
- end
41
-
42
- end
43
- end
@@ -1,6 +0,0 @@
1
- module AIXM
2
- module Feature
3
- class Base < AIXM::Base
4
- end
5
- end
6
- end
@@ -1,79 +0,0 @@
1
- module AIXM
2
- module Feature
3
- module NavigationalAid
4
-
5
- ##
6
- # Implements common attributes of all navigational aids
7
- #
8
- # Please note that the optional elevation +z+ must be in +:qnh+.
9
- class Base < AIXM::Feature::Base
10
- using AIXM::Refinements
11
-
12
- attr_reader :id, :name, :xy, :z, :schedule, :remarks
13
-
14
- private_class_method :new
15
-
16
- def initialize(id:, name: nil, xy:, z: nil)
17
- self.id, self.name, self.xy, self.z = id, name, xy, z
18
- end
19
-
20
- def id=(value)
21
- fail(ArgumentError, "invalid id") unless value.is_a? String
22
- @id = value.upcase
23
- end
24
-
25
- def name=(value)
26
- fail(ArgumentError, "invalid name") unless value.nil? || value.is_a?(String)
27
- @name = value&.upcase
28
- end
29
-
30
- def xy=(value)
31
- fail(ArgumentError, "invalid xy") unless value.is_a? AIXM::XY
32
- @xy = value
33
- end
34
-
35
- def z=(value)
36
- fail(ArgumentError, "invalid z") unless value.nil? || (value.is_a?(AIXM::Z) && value.qnh?)
37
- @z = value
38
- end
39
-
40
- def schedule=(value)
41
- fail(ArgumentError, "invalid schedule") unless value.nil? || value.is_a?(AIXM::Component::Schedule)
42
- @schedule = value
43
- end
44
-
45
- def remarks=(value)
46
- fail(ArgumentError, "invalid remarks") unless value.nil? || value.is_a?(String)
47
- @remarks = value
48
- end
49
-
50
- ##
51
- # Return a fully descriptive combination of +class+ and +type_key+
52
- def kind
53
- [self.class.name.split('::').last, type_key].compact.join(':')
54
- end
55
-
56
- ##
57
- # Digest to identify the payload
58
- def to_digest
59
- [kind, id, name, xy.to_digest, z&.to_digest, remarks].to_digest
60
- end
61
-
62
- ##
63
- # Create builder to render AIXM in subclasses
64
- def to_builder(*extensions)
65
- builder = Builder::XmlMarkup.new(indent: 2)
66
- builder.comment! "NavigationalAid: [#{kind}] #{name}"
67
- builder
68
- end
69
-
70
- ##
71
- # Fallback type key
72
- def type_key
73
- nil
74
- end
75
- end
76
-
77
- end
78
- end
79
- end
@@ -1,74 +0,0 @@
1
- require_relative '../../../spec_helper'
2
-
3
- describe AIXM::Component::ClassLayer do
4
- describe :initialize do
5
- it "won't accept invalid arguments" do
6
- -> { AIXM.class_layer(class: 'X', vertical_limits: AIXM::Factory.vertical_limits ) }.must_raise ArgumentError
7
- -> { AIXM.class_layer(class: 'A', vertical_limits: 'foobar') }.must_raise ArgumentError
8
- end
9
- end
10
-
11
- context "with class" do
12
- subject do
13
- AIXM.class_layer(class: :C, vertical_limits: AIXM::Factory.vertical_limits)
14
- end
15
-
16
- describe :to_digest do
17
- it "must return digest of payload" do
18
- subject.to_digest.must_equal 385936206
19
- end
20
- end
21
-
22
- describe :to_aixm do
23
- it "must build correct XML" do
24
- subject.to_aixm.must_equal <<~END
25
- <codeClass>C</codeClass>
26
- <codeDistVerUpper>STD</codeDistVerUpper>
27
- <valDistVerUpper>65</valDistVerUpper>
28
- <uomDistVerUpper>FL</uomDistVerUpper>
29
- <codeDistVerLower>STD</codeDistVerLower>
30
- <valDistVerLower>45</valDistVerLower>
31
- <uomDistVerLower>FL</uomDistVerLower>
32
- <codeDistVerMax>ALT</codeDistVerMax>
33
- <valDistVerMax>6000</valDistVerMax>
34
- <uomDistVerMax>FT</uomDistVerMax>
35
- <codeDistVerMnm>HEI</codeDistVerMnm>
36
- <valDistVerMnm>3000</valDistVerMnm>
37
- <uomDistVerMnm>FT</uomDistVerMnm>
38
- END
39
- end
40
- end
41
- end
42
-
43
- context "without class" do
44
- subject do
45
- AIXM.class_layer(vertical_limits: AIXM::Factory.vertical_limits)
46
- end
47
-
48
- describe :to_digest do
49
- it "must return digest of payload" do
50
- subject.to_digest.must_equal 5930767
51
- end
52
- end
53
-
54
- describe :to_aixm do
55
- it "must build correct XML" do
56
- subject.to_aixm.must_equal <<~END
57
- <codeDistVerUpper>STD</codeDistVerUpper>
58
- <valDistVerUpper>65</valDistVerUpper>
59
- <uomDistVerUpper>FL</uomDistVerUpper>
60
- <codeDistVerLower>STD</codeDistVerLower>
61
- <valDistVerLower>45</valDistVerLower>
62
- <uomDistVerLower>FL</uomDistVerLower>
63
- <codeDistVerMax>ALT</codeDistVerMax>
64
- <valDistVerMax>6000</valDistVerMax>
65
- <uomDistVerMax>FT</uomDistVerMax>
66
- <codeDistVerMnm>HEI</codeDistVerMnm>
67
- <valDistVerMnm>3000</valDistVerMnm>
68
- <uomDistVerMnm>FT</uomDistVerMnm>
69
- END
70
- end
71
- end
72
- end
73
-
74
- end
@@ -1,33 +0,0 @@
1
- require_relative '../../../spec_helper'
2
-
3
- describe AIXM::Component::Schedule do
4
- describe :initialize do
5
- it "won't accept invalid arguments" do
6
- -> { AIXM.schedule(code: 'foobar') }.must_raise ArgumentError
7
- end
8
-
9
- it "must accept explicit codes" do
10
- AIXM.schedule(code: :sunrise_to_sunset).code.must_equal :sunrise_to_sunset
11
- end
12
-
13
- it "must accept short codes" do
14
- AIXM.schedule(code: :H24).code.must_equal :continuous
15
- end
16
- end
17
-
18
- describe :to_digest do
19
- it "must return digest of payload" do
20
- subject = AIXM.schedule(code: :continuous)
21
- subject.to_digest.must_equal 349179367
22
- end
23
- end
24
-
25
- describe :to_aixm do
26
- it "must build correct XML" do
27
- subject = AIXM.schedule(code: :continuous)
28
- subject.to_aixm.must_equal <<~END
29
- <codeWorkHr>H24</codeWorkHr>
30
- END
31
- end
32
- end
33
- end
@@ -1,41 +0,0 @@
1
- require_relative '../../../../spec_helper'
2
-
3
- describe AIXM::Feature::NavigationalAid::Base do
4
- let :base do
5
- AIXM::Feature::NavigationalAid::Base
6
- end
7
-
8
- describe :initialize do
9
- it "won't accept invalid arguments" do
10
- -> { base.send(:new, id: 'id', name: 'name', xy: 0) }.must_raise ArgumentError
11
- -> { base.send(:new, id: 'id', name: 'name', xy: AIXM::Factory.xy, z: 0) }.must_raise ArgumentError
12
- -> { base.send(:new, id: 'id', name: 'name', xy: AIXM::Factory.xy, z: AIXM.z(1, :qne)) }.must_raise ArgumentError
13
- end
14
-
15
- it "accepts name to be nil" do
16
- base.send(:new, id: 'id', xy: AIXM::Factory.xy).name.must_be_nil
17
- end
18
-
19
- context "downcase attributes" do
20
- subject do
21
- base.send(:new, id: 'id', name: 'name', xy: AIXM::Factory.xy)
22
- end
23
-
24
- it "upcases ID" do
25
- subject.id.must_equal 'ID'
26
- end
27
-
28
- it "upcases name" do
29
- subject.name.must_equal 'NAME'
30
- end
31
- end
32
- end
33
-
34
- describe :to_digest do
35
- it "must return digest of payload" do
36
- subject = base.send(:new, id: 'id', name: 'name', xy: AIXM::Factory.xy, z: AIXM.z(100, :qnh))
37
- subject.to_digest.must_equal 711143170
38
- end
39
- end
40
-
41
- end