aixm 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +14 -3
  4. data/README.md +30 -2
  5. data/exe/ckmid +1 -7
  6. data/exe/mkmid +1 -7
  7. data/lib/aixm/classes.rb +2 -1
  8. data/lib/aixm/component/address.rb +12 -15
  9. data/lib/aixm/component/approach_lighting.rb +11 -16
  10. data/lib/aixm/component/fato.rb +22 -34
  11. data/lib/aixm/component/frequency.rb +10 -15
  12. data/lib/aixm/component/geometry/arc.rb +2 -3
  13. data/lib/aixm/component/geometry/border.rb +6 -10
  14. data/lib/aixm/component/geometry/circle.rb +4 -4
  15. data/lib/aixm/component/geometry/point.rb +4 -4
  16. data/lib/aixm/component/geometry/rhumb_line.rb +4 -4
  17. data/lib/aixm/component/geometry.rb +4 -4
  18. data/lib/aixm/component/helipad.rb +13 -20
  19. data/lib/aixm/component/layer.rb +6 -8
  20. data/lib/aixm/component/lighting.rb +12 -17
  21. data/lib/aixm/component/runway.rb +26 -38
  22. data/lib/aixm/component/service.rb +12 -16
  23. data/lib/aixm/component/surface.rb +8 -10
  24. data/lib/aixm/component/timesheet.rb +9 -10
  25. data/lib/aixm/component/timetable.rb +6 -7
  26. data/lib/aixm/component/vasis.rb +6 -8
  27. data/lib/aixm/component/vertical_limit.rb +8 -8
  28. data/lib/aixm/component.rb +3 -2
  29. data/lib/aixm/concerns/association.rb +381 -0
  30. data/lib/aixm/concerns/memoize.rb +107 -0
  31. data/lib/aixm/concerns/xml_builder.rb +34 -0
  32. data/lib/aixm/document.rb +52 -21
  33. data/lib/aixm/feature/airport.rb +44 -47
  34. data/lib/aixm/feature/airspace.rb +27 -34
  35. data/lib/aixm/feature/generic.rb +67 -0
  36. data/lib/aixm/feature/navigational_aid/designated_point.rb +11 -13
  37. data/lib/aixm/feature/navigational_aid/dme.rb +12 -15
  38. data/lib/aixm/feature/navigational_aid/marker.rb +12 -15
  39. data/lib/aixm/feature/navigational_aid/ndb.rb +13 -16
  40. data/lib/aixm/feature/navigational_aid/tacan.rb +15 -17
  41. data/lib/aixm/feature/navigational_aid/vor.rb +16 -19
  42. data/lib/aixm/feature/navigational_aid.rb +7 -7
  43. data/lib/aixm/feature/obstacle.rb +20 -21
  44. data/lib/aixm/feature/obstacle_group.rb +19 -20
  45. data/lib/aixm/feature/organisation.rb +11 -12
  46. data/lib/aixm/feature/unit.rb +16 -18
  47. data/lib/aixm/feature.rb +26 -7
  48. data/lib/aixm/object.rb +1 -1
  49. data/lib/aixm/refinements.rb +57 -0
  50. data/lib/aixm/version.rb +1 -1
  51. data/lib/aixm.rb +4 -3
  52. data/schemas/ofmx/0.1/OFMX-Snapshot.xsd +6 -1
  53. data.tar.gz.sig +3 -3
  54. metadata +7 -19
  55. metadata.gz.sig +0 -0
  56. data/lib/aixm/association.rb +0 -378
  57. data/lib/aixm/memoize.rb +0 -105
@@ -23,6 +23,7 @@ module AIXM
23
23
  # airport.timetable = AIXM.timetable or nil
24
24
  # airport.operator = String or nil
25
25
  # airport.remarks = String or nil
26
+ # airport.comment = Object or nil
26
27
  # airport.add_runway(AIXM.runway)
27
28
  # airport.add_fato(AIXM.fato)
28
29
  # airport.add_helipad(AIXM.helipad)
@@ -36,8 +37,7 @@ module AIXM
36
37
  #
37
38
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airport#ahp-airport
38
39
  class Airport < Feature
39
- include AIXM::Association
40
- include AIXM::Memoize
40
+ include AIXM::Concerns::Association
41
41
  include AIXM::Concerns::Timetable
42
42
  include AIXM::Concerns::Remarks
43
43
 
@@ -269,81 +269,78 @@ module AIXM
269
269
  @operator = value&.uptrans
270
270
  end
271
271
 
272
- # @return [String] UID markup
273
- def to_uid(as: :AhpUid)
274
- builder = Builder::XmlMarkup.new(indent: 2)
275
- builder.tag!(as, ({ region: (region if AIXM.ofmx?) }.compact)) do |tag|
272
+ # @!visibility private
273
+ def add_uid_to(builder, as: :AhpUid)
274
+ builder.send(as, { region: (region if AIXM.ofmx?) }.compact) do |tag|
276
275
  tag.codeId(id)
277
276
  end
278
277
  end
279
- memoize :to_uid
280
278
 
281
- # @return [String] UID markup
282
- def to_wrapped_uid(as: :AhpUid, with:)
283
- builder = Builder::XmlMarkup.new(indent: 2)
284
- builder.tag!(with) do |tag|
285
- tag << to_uid(as: as).indent(2)
279
+ # @!visibility private
280
+ def add_wrapped_uid_to(builder, as: :AhpUid, with:)
281
+ builder.send(with) do |tag|
282
+ add_uid_to(builder, as: as)
286
283
  end
287
284
  end
288
285
 
289
- # @return [String] AIXM or OFMX markup
290
- def to_xml
291
- builder = Builder::XmlMarkup.new(indent: 2)
292
- builder.comment! "Airport: #{id} #{name}"
286
+ # @!visibility private
287
+ def add_to(builder)
288
+ builder.comment "Airport: #{id} #{name}".dress
289
+ builder.text "\n"
293
290
  builder.Ahp({ source: (source if AIXM.ofmx?) }.compact) do |ahp|
294
- ahp << to_uid.indent(2)
295
- ahp << organisation.to_uid.indent(2)
291
+ ahp.comment(indented_comment) if comment
292
+ add_uid_to(ahp)
293
+ organisation.add_uid_to(ahp)
296
294
  ahp.txtName(name)
297
295
  ahp.codeIcao(id) if id.length == 4
298
296
  ahp.codeIata(id) if id.length == 3
299
297
  ahp.codeGps(gps) if AIXM.ofmx? && gps
300
- ahp.codeType(TYPES.key(type).to_s) if type
298
+ ahp.codeType(TYPES.key(type)) if type
301
299
  ahp.geoLat(xy.lat(AIXM.schema))
302
300
  ahp.geoLong(xy.long(AIXM.schema))
303
301
  ahp.codeDatum('WGE')
304
302
  if z
305
303
  ahp.valElev(z.alt)
306
- ahp.uomDistVer(z.unit.upcase.to_s)
304
+ ahp.uomDistVer(z.unit.upcase)
307
305
  end
308
306
  ahp.valMagVar(declination) if declination
309
307
  ahp.txtNameAdmin(operator) if operator
310
308
  if transition_z
311
309
  ahp.valTransitionAlt(transition_z.alt)
312
- ahp.uomTransitionAlt(transition_z.unit.upcase.to_s)
310
+ ahp.uomTransitionAlt(transition_z.unit.upcase)
313
311
  end
314
- ahp << timetable.to_xml(as: :Aht).indent(2) if timetable
312
+ timetable.add_to(ahp, as: :Aht) if timetable
315
313
  ahp.txtRmk(remarks) if remarks
316
314
  end
317
315
  runways.each do |runway|
318
- builder << runway.to_xml
316
+ runway.add_to(builder)
319
317
  end
320
318
  fatos.each do |fato|
321
- builder << fato.to_xml
319
+ fato.add_to(builder)
322
320
  end
323
321
  helipads.each do |helipad|
324
- builder << helipad.to_xml
322
+ helipad.add_to(builder)
325
323
  end
326
324
  if usage_limitations.any?
327
325
  builder.Ahu do |ahu|
328
- ahu << to_wrapped_uid(with: :AhuUid).indent(2)
326
+ add_wrapped_uid_to(ahu, with: :AhuUid)
329
327
  usage_limitations.each do |usage_limitation|
330
- ahu << usage_limitation.to_xml.indent(2)
328
+ usage_limitation.add_to(ahu)
331
329
  end
332
330
  end
333
331
  end
334
332
  addresses.each.with_object({}) do |address, sequences|
335
333
  sequences[address.type] = (sequences[address.type] || 0) + 1
336
- builder << address.to_xml(as: :Aha, sequence: sequences[address.type])
334
+ address.add_to(builder, as: :Aha, sequence: sequences[address.type])
337
335
  end
338
336
  services.each do |service|
339
337
  builder.Sah do |sah|
340
338
  sah.SahUid do |sah_uid|
341
- sah_uid << to_uid.indent(4)
342
- sah_uid << service.to_uid.indent(4)
339
+ add_uid_to(sah_uid)
340
+ service.add_uid_to(sah_uid)
343
341
  end
344
342
  end
345
343
  end
346
- builder.target!
347
344
  end
348
345
 
349
346
  # Limitations concerning the availability of an airport for certain flight
@@ -376,7 +373,8 @@ module AIXM
376
373
  # @see AIXM::Feature::Airport#add_usage_limitation
377
374
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airport#ahu-airport-usage
378
375
  class UsageLimitation
379
- include AIXM::Association
376
+ include AIXM::Concerns::Association
377
+ include AIXM::Concerns::XMLBuilder
380
378
  include AIXM::Concerns::Timetable
381
379
  include AIXM::Concerns::Remarks
382
380
 
@@ -422,15 +420,14 @@ module AIXM
422
420
  @type = TYPES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid type")
423
421
  end
424
422
 
425
- # @return [String] AIXM or OFMX markup
426
- def to_xml
427
- builder = Builder::XmlMarkup.new(indent: 2)
423
+ # @!visibility private
424
+ def add_to(builder)
428
425
  builder.UsageLimitation do |usage_limitation|
429
- usage_limitation.codeUsageLimitation(TYPES.key(type).to_s)
426
+ usage_limitation.codeUsageLimitation(TYPES.key(type))
430
427
  conditions.each do |condition|
431
- usage_limitation << condition.to_xml.indent(2)
428
+ condition.add_to(usage_limitation)
432
429
  end
433
- usage_limitation << timetable.to_xml(as: :Timetable).indent(2) if timetable
430
+ timetable.add_to(usage_limitation, as: :Timetable) if timetable
434
431
  usage_limitation.txtRmk(remarks) if remarks
435
432
  end
436
433
  end
@@ -441,7 +438,8 @@ module AIXM
441
438
  # @see AIXM::Feature::Airport#add_usage_limitation
442
439
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airport#ahu-airport-usage
443
440
  class Condition
444
- include AIXM::Association
441
+ include AIXM::Concerns::Association
442
+ include AIXM::Concerns::XMLBuilder
445
443
 
446
444
  AIRCRAFT = {
447
445
  L: :landplane,
@@ -557,21 +555,20 @@ module AIXM
557
555
  @purpose = value.nil? ? nil : PURPOSES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid purpose")
558
556
  end
559
557
 
560
- # @return [String] AIXM or OFMX markup
561
- def to_xml
562
- builder = Builder::XmlMarkup.new(indent: 2)
558
+ # @!visibility private
559
+ def add_to(builder)
563
560
  builder.UsageCondition do |usage_condition|
564
561
  if aircraft
565
562
  usage_condition.AircraftClass do |aircraft_class|
566
- aircraft_class.codeType(AIRCRAFT.key(aircraft).to_s)
563
+ aircraft_class.codeType(AIRCRAFT.key(aircraft))
567
564
  end
568
565
  end
569
566
  if rule || realm || origin || purpose
570
567
  usage_condition.FlightClass do |flight_class|
571
- flight_class.codeRule(RULES.key(rule).to_s) if rule
572
- flight_class.codeMil(REALMS.key(realm).to_s) if realm
573
- flight_class.codeOrigin(ORIGINS.key(origin).to_s) if origin
574
- flight_class.codePurpose(PURPOSES.key(purpose).to_s) if purpose
568
+ flight_class.codeRule(RULES.key(rule)) if rule
569
+ flight_class.codeMil(REALMS.key(realm)) if realm
570
+ flight_class.codeOrigin(ORIGINS.key(origin)) if origin
571
+ flight_class.codePurpose(PURPOSES.key(purpose)) if purpose
575
572
  end
576
573
  end
577
574
  end
@@ -14,6 +14,7 @@ module AIXM
14
14
  # local_type: String or nil
15
15
  # name: String or nil
16
16
  # )
17
+ # airspace.comment = Object or nil
17
18
  # airspace.add_layer(AIXM.layer)
18
19
  # airspace.geometry.add_segment(AIXM.point or AIXM.arc or AIXM.border or AIXM.circle)
19
20
  #
@@ -30,8 +31,7 @@ module AIXM
30
31
  #
31
32
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airspace#ase-airspace
32
33
  class Airspace < Feature
33
- include AIXM::Association
34
- include AIXM::Memoize
34
+ include AIXM::Concerns::Association
35
35
 
36
36
  public_class_method :new
37
37
 
@@ -165,61 +165,55 @@ module AIXM
165
165
  @name = value&.uptrans
166
166
  end
167
167
 
168
- # @return [String] UID markup
169
- def to_uid(as: :AseUid)
170
- builder = Builder::XmlMarkup.new(indent: 2)
171
- builder.tag!(as, ({ region: (region if AIXM.ofmx?) }.compact)) do |tag|
172
- tag.codeType(TYPES.key(type).to_s)
168
+ # @!visibility private
169
+ def add_uid_to(builder, as: :AseUid)
170
+ builder.send(as, ({ region: (region if AIXM.ofmx?) }.compact)) do |tag|
171
+ tag.codeType(TYPES.key(type))
173
172
  tag.codeId(id)
174
173
  tag.txtLocalType(local_type) if AIXM.ofmx? && local_type && local_type != name
175
174
  end
176
175
  end
177
- memoize :to_uid
178
176
 
179
- # @return [String] UID markup
180
- def to_wrapped_uid(as: :AseUid, with:)
181
- builder = Builder::XmlMarkup.new(indent: 2)
182
- builder.tag!(with) do |tag|
183
- tag << to_uid(as: as).indent(2)
177
+ # @!visibility private
178
+ def add_wrapped_uid_to(builder, as: :AseUid, with:)
179
+ builder.send(with) do |tag|
180
+ add_uid_to(tag, as: as)
184
181
  end
185
182
  end
186
183
 
187
- # @raise [AIXM::GeometryError] if the geometry is not closed
188
- # @raise [AIXM::LayerError] if no layers are defined
189
- # @return [String] AIXM or OFMX markup
190
- def to_xml
184
+ # @!visibility private
185
+ def add_to(builder)
191
186
  fail(LayerError.new("no layers defined", self)) unless layers.any?
192
- builder = Builder::XmlMarkup.new(indent: 2)
193
- builder.comment! "Airspace: [#{TYPES.key(type)}] #{name || :UNNAMED}"
187
+ builder.comment "Airspace: [#{TYPES.key(type)}] #{name || :UNNAMED}".dress
188
+ builder.text "\n"
194
189
  builder.Ase({ source: (source if AIXM.ofmx?) }.compact) do |ase|
195
- ase << to_uid.indent(2)
190
+ ase.comment(indented_comment) if comment
191
+ add_uid_to(ase)
196
192
  ase.txtLocalType(local_type) if AIXM.aixm? && local_type && local_type != name
197
193
  ase.txtName(name) if name
198
- unless layered?
199
- ase << layers.first.to_xml.indent(2)
200
- end
194
+ layers.first.add_to(ase) unless layered?
201
195
  end
202
196
  builder.Abd do |abd|
203
- abd << to_wrapped_uid(with: :AbdUid).indent(2)
204
- abd << geometry.to_xml.indent(2)
197
+ add_wrapped_uid_to(abd, with: :AbdUid)
198
+ geometry.add_to(abd)
205
199
  end
206
200
  if layered?
207
201
  layers.each.with_index do |layer, index|
208
202
  layer_airspace = AIXM.airspace(region: region, type: 'CLASS', name: "#{name} LAYER #{index + 1}")
209
203
  builder.Ase do |ase|
210
- ase << layer_airspace.to_uid.indent(2)
204
+ layer_airspace.add_uid_to(ase)
211
205
  ase.txtName(layer_airspace.name)
212
- ase << layers[index].to_xml.indent(2)
206
+ layers[index].add_to(ase)
213
207
  end
214
208
  builder.Adg do |adg|
215
- adg << layer_airspace.to_wrapped_uid(with: :AdgUid).indent(2)
216
- adg << to_uid(as: :AseUidSameExtent).indent(2)
209
+ layer_airspace.add_wrapped_uid_to(adg, with: :AdgUid)
210
+ add_uid_to(adg, as: :AseUidSameExtent)
217
211
  end
218
212
  layer.services.each do |service|
219
213
  builder.Sae do |sae|
220
214
  sae.SaeUid do |sae_uid|
221
- sae_uid << service.to_uid.indent(4)
222
- sae_uid << layer_airspace.to_uid.indent(4)
215
+ service.add_uid_to(sae_uid)
216
+ layer_airspace.add_uid_to(sae_uid)
223
217
  end
224
218
  end
225
219
  end
@@ -228,13 +222,12 @@ module AIXM
228
222
  layers.first.services.each do |service|
229
223
  builder.Sae do |sae|
230
224
  sae.SaeUid do |sae_uid|
231
- sae_uid << service.to_uid.indent(4)
232
- sae_uid << to_uid.indent(4)
225
+ service.add_uid_to(sae_uid)
226
+ add_uid_to(sae_uid)
233
227
  end
234
228
  end
235
229
  end
236
230
  end
237
- builder.target!
238
231
  end
239
232
 
240
233
  private
@@ -0,0 +1,67 @@
1
+ using AIXM::Refinements
2
+
3
+ module AIXM
4
+ class Feature
5
+
6
+ # Generic feature represented as XML document fragment.
7
+ #
8
+ # ===Cheat Sheet in Pseudo Code:
9
+ # generic = AIXM.generic(
10
+ # fragment: Nokogiri::XML::DocumentFragment or String
11
+ # )
12
+ class Generic < Feature
13
+ public_class_method :new
14
+
15
+ # XML document fragment
16
+ #
17
+ # @overload fragment
18
+ # @return [Nokogiri::XML::DocumentFragment]
19
+ # @overload fragment=(value)
20
+ # @param value [Nokogiri::XML::DocumentFragment, Object] XML document
21
+ # fragment or object which is converted to string and then parsed
22
+ attr_reader :fragment
23
+
24
+ # See the {cheat sheet}[AIXM::Feature::Generic] for examples on how to
25
+ # create instances of this class.
26
+ def initialize(source: nil, region: nil, fragment:)
27
+ super(source: source, region: region)
28
+ self.fragment = fragment
29
+ end
30
+
31
+ # @return [String]
32
+ def inspect
33
+ %Q(#<#{self.class} #{fragment.elements.first.name}>)
34
+ end
35
+
36
+ def fragment=(value)
37
+ @fragment = case value
38
+ when Nokogiri::XML::DocumentFragment then value
39
+ else Nokogiri::XML::DocumentFragment.parse(value.to_s)
40
+ end
41
+ end
42
+
43
+ # @return [Integer] pseudo UID fragment
44
+ def to_uid
45
+ fragment.to_xml.hash
46
+ end
47
+
48
+ # @!visibility private
49
+ def add_to(builder)
50
+ builder.comment "Generic".dress
51
+ builder.text "\n"
52
+ if comment
53
+ builder.comment(indented_comment)
54
+ builder.text "\n"
55
+ end
56
+ decorated_fragment = fragment.dup
57
+ if AIXM.ofmx?
58
+ decorated_fragment.css('*').each do |element|
59
+ element['region'] ||= region if element.name.match?(/Uid$/)
60
+ end
61
+ end
62
+ builder << decorated_fragment.to_xml
63
+ end
64
+ end
65
+
66
+ end
67
+ end
@@ -18,11 +18,11 @@ module AIXM
18
18
  # )
19
19
  # designated_point.airport = AIXM.airport or nil
20
20
  # designated_point.remarks = String or nil
21
+ # designated_point.comment = Object or nil
21
22
  #
22
23
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Navigational-aid#dpn-designated-point
23
24
  class DesignatedPoint < NavigationalAid
24
- include AIXM::Association
25
- include AIXM::Memoize
25
+ include AIXM::Concerns::Association
26
26
 
27
27
  public_class_method :new
28
28
 
@@ -60,28 +60,26 @@ module AIXM
60
60
  @type = TYPES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid type")
61
61
  end
62
62
 
63
- # @return [String] UID markup
64
- def to_uid
65
- builder = Builder::XmlMarkup.new(indent: 2)
63
+ # @!visibility private
64
+ def add_uid_to(builder)
66
65
  builder.DpnUid({ region: (region if AIXM.ofmx?) }.compact) do |dpn_uid|
67
66
  dpn_uid.codeId(id)
68
67
  dpn_uid.geoLat(xy.lat(AIXM.schema))
69
68
  dpn_uid.geoLong(xy.long(AIXM.schema))
70
69
  end
71
70
  end
72
- memoize :to_uid
73
71
 
74
- # @return [String] AIXM or OFMX markup
75
- def to_xml
76
- builder = to_builder
72
+ # @!visibility private
73
+ def add_to(builder)
74
+ super
77
75
  builder.Dpn({ source: (source if AIXM.ofmx?) }.compact) do |dpn|
78
- dpn << to_uid.indent(2)
79
- dpn << airport.to_uid(as: :AhpUidAssoc).indent(2) if airport
76
+ dpn.comment(indented_comment) if comment
77
+ add_uid_to(dpn)
78
+ airport.add_uid_to(dpn, as: :AhpUidAssoc) if airport
80
79
  dpn.codeDatum('WGE')
81
- dpn.codeType(AIXM.aixm? && type_key =~ /^VFR/ ? 'OTHER' : type_key.to_s)
80
+ dpn.codeType(AIXM.aixm? && type_key =~ /^VFR/ ? 'OTHER' : type_key)
82
81
  dpn.txtName(name) if name
83
82
  dpn.txtRmk(remarks) if remarks
84
- dpn.target!
85
83
  end
86
84
  end
87
85
 
@@ -23,11 +23,10 @@ module AIXM
23
23
  # )
24
24
  # dme.timetable = AIXM.timetable or nil
25
25
  # dme.remarks = String or nil
26
+ # dme.comment = Object or nil
26
27
  #
27
28
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Navigational-aid#dme-dme
28
29
  class DME < NavigationalAid
29
- include AIXM::Memoize
30
-
31
30
  public_class_method :new
32
31
 
33
32
  CHANNEL_RE = /\A([1-9]|[1-9]\d|1[0-1]\d|12[0-6])[XY]\z/.freeze
@@ -93,24 +92,23 @@ module AIXM
93
92
  end
94
93
  end
95
94
 
96
- # @return [String] UID markup
97
- def to_uid
98
- builder = Builder::XmlMarkup.new(indent: 2)
95
+ # @!visibility private
96
+ def add_uid_to(builder)
99
97
  builder.DmeUid({ region: (region if AIXM.ofmx?) }.compact) do |dme_uid|
100
98
  dme_uid.codeId(id)
101
99
  dme_uid.geoLat(xy.lat(AIXM.schema))
102
100
  dme_uid.geoLong(xy.long(AIXM.schema))
103
101
  end
104
102
  end
105
- memoize :to_uid
106
103
 
107
- # @return [String] AIXM or OFMX markup
108
- def to_xml
109
- builder = to_builder
104
+ # @!visibility private
105
+ def add_to(builder)
106
+ super
110
107
  builder.Dme({ source: (source if AIXM.ofmx?) }.compact) do |dme|
111
- dme << to_uid.indent(2)
112
- dme << organisation.to_uid.indent(2)
113
- dme << vor.to_uid.indent(2) if vor
108
+ dme.comment(indented_comment) if comment
109
+ add_uid_to(dme)
110
+ organisation.add_uid_to(dme)
111
+ vor.add_uid_to(dme) if vor
114
112
  dme.txtName(name) if name
115
113
  dme.codeChannel(channel)
116
114
  unless vor
@@ -120,11 +118,10 @@ module AIXM
120
118
  dme.codeDatum('WGE')
121
119
  if z
122
120
  dme.valElev(z.alt)
123
- dme.uomDistVer(z.unit.upcase.to_s)
121
+ dme.uomDistVer(z.unit.upcase)
124
122
  end
125
- dme << timetable.to_xml(as: :Dtt).indent(2) if timetable
123
+ timetable.add_to(dme, as: :Dtt) if timetable
126
124
  dme.txtRmk(remarks) if remarks
127
- dme.target!
128
125
  end
129
126
  end
130
127
  end
@@ -21,14 +21,13 @@ module AIXM
21
21
  # )
22
22
  # marker.timetable = AIXM.timetable or nil
23
23
  # marker.remarks = String or nil
24
+ # marker.comment = Object or nil
24
25
  #
25
26
  # @note Marker are not fully implemented because they usually have to be
26
27
  # associated with an ILS which are not implemented as of now.
27
28
  #
28
29
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Navigational-aid#mkr-marker-beacon
29
30
  class Marker < NavigationalAid
30
- include AIXM::Memoize
31
-
32
31
  public_class_method :new
33
32
 
34
33
  TYPES = {
@@ -60,35 +59,33 @@ module AIXM
60
59
  @type = value.nil? ? nil : TYPES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid type")
61
60
  end
62
61
 
63
- # @return [String] UID markup
64
- def to_uid
65
- builder = Builder::XmlMarkup.new(indent: 2)
62
+ # @!visibility private
63
+ def add_uid_to(builder)
66
64
  builder.MkrUid({ region: (region if AIXM.ofmx?) }.compact) do |mkr_uid|
67
65
  mkr_uid.codeId(id)
68
66
  mkr_uid.geoLat(xy.lat(AIXM.schema))
69
67
  mkr_uid.geoLong(xy.long(AIXM.schema))
70
68
  end
71
69
  end
72
- memoize :to_uid
73
70
 
74
- # @return [String] AIXM or OFMX markup
75
- def to_xml
76
- builder = to_builder
71
+ # @!visibility private
72
+ def add_to(builder)
73
+ super
77
74
  builder.Mkr({ source: (source if AIXM.ofmx?) }.compact) do |mkr|
78
- mkr << to_uid.indent(2)
79
- mkr << organisation.to_uid.indent(2)
80
- mkr.codePsnIls(type_key.to_s) if type_key
75
+ mkr.comment(indented_comment) if comment
76
+ add_uid_to(mkr)
77
+ organisation.add_uid_to(mkr)
78
+ mkr.codePsnIls(type_key) if type_key
81
79
  mkr.valFreq(75)
82
80
  mkr.uomFreq('MHZ')
83
81
  mkr.txtName(name) if name
84
82
  mkr.codeDatum('WGE')
85
83
  if z
86
84
  mkr.valElev(z.alt)
87
- mkr.uomDistVer(z.unit.upcase.to_s)
85
+ mkr.uomDistVer(z.unit.upcase)
88
86
  end
89
- mkr << timetable.to_xml(as: :Mtt).indent(2) if timetable
87
+ timetable.add_to(mkr, as: :Mtt) if timetable
90
88
  mkr.txtRmk(remarks) if remarks
91
- mkr.target!
92
89
  end
93
90
  end
94
91
 
@@ -21,11 +21,10 @@ module AIXM
21
21
  # )
22
22
  # ndb.timetable = AIXM.timetable or nil
23
23
  # ndb.remarks = String or nil
24
+ # ndb.comment = Object or nil
24
25
  #
25
26
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Navigational-aid#ndb-ndb
26
27
  class NDB < NavigationalAid
27
- include AIXM::Memoize
28
-
29
28
  public_class_method :new
30
29
 
31
30
  TYPES = {
@@ -67,35 +66,33 @@ module AIXM
67
66
  @f = value
68
67
  end
69
68
 
70
- # @return [String] UID markup
71
- def to_uid
72
- builder = Builder::XmlMarkup.new(indent: 2)
69
+ # @!visibility private
70
+ def add_uid_to(builder)
73
71
  builder.NdbUid({ region: (region if AIXM.ofmx?) }.compact) do |ndb_uid|
74
72
  ndb_uid.codeId(id)
75
73
  ndb_uid.geoLat(xy.lat(AIXM.schema))
76
74
  ndb_uid.geoLong(xy.long(AIXM.schema))
77
75
  end
78
76
  end
79
- memoize :to_uid
80
77
 
81
- # @return [String] AIXM or OFMX markup
82
- def to_xml
83
- builder = to_builder
78
+ # @!visibility private
79
+ def add_to(builder)
80
+ super
84
81
  builder.Ndb({ source: (source if AIXM.ofmx?) }.compact) do |ndb|
85
- ndb << to_uid.indent(2)
86
- ndb << organisation.to_uid.indent(2)
82
+ ndb.comment(indented_comment) if comment
83
+ add_uid_to(ndb)
84
+ organisation.add_uid_to(ndb)
87
85
  ndb.txtName(name) if name
88
86
  ndb.valFreq(f.freq.trim)
89
- ndb.uomFreq(f.unit.upcase.to_s)
90
- ndb.codeClass(type_key.to_s) if type
87
+ ndb.uomFreq(f.unit.upcase)
88
+ ndb.codeClass(type_key) if type
91
89
  ndb.codeDatum('WGE')
92
90
  if z
93
91
  ndb.valElev(z.alt)
94
- ndb.uomDistVer(z.unit.upcase.to_s)
92
+ ndb.uomDistVer(z.unit.upcase)
95
93
  end
96
- ndb << timetable.to_xml(as: :Ntt).indent(2) if timetable
94
+ timetable.add_to(ndb, as: :Ntt) if timetable
97
95
  ndb.txtRmk(remarks) if remarks
98
- ndb.target!
99
96
  end
100
97
  end
101
98