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
@@ -20,33 +20,32 @@ module AIXM
20
20
  # channel: String # either set channel directly
21
21
  # ghost_f: AIXM.f # or set channel via VOR ghost frequency
22
22
  # )
23
- # tacan.timetable = AIXM.timetable or nil
24
- # tacan.remarks = String or nil
23
+ # tacan.timetable = AIXM.timetable or nil
24
+ # tacan.remarks = String or nil
25
+ # tacan.comment = Object or nil
25
26
  #
26
27
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Navigational-aid#tcn-tacan
27
28
  class TACAN < DME
28
- include AIXM::Memoize
29
-
30
29
  public_class_method :new
31
30
 
32
- # @return [String] UID markup
33
- def to_uid
34
- builder = Builder::XmlMarkup.new(indent: 2)
31
+ # @!visibility private
32
+ def add_uid_to(builder)
35
33
  builder.TcnUid({ region: (region if AIXM.ofmx?) }.compact) do |tcn_uid|
36
34
  tcn_uid.codeId(id)
37
35
  tcn_uid.geoLat(xy.lat(AIXM.schema))
38
36
  tcn_uid.geoLong(xy.long(AIXM.schema))
39
37
  end
40
38
  end
41
- memoize :to_uid
42
39
 
43
- # @return [String] AIXM or OFMX markup
44
- def to_xml
45
- builder = to_builder
40
+ # @!visibility private
41
+ def add_to(builder)
42
+ builder.comment "NavigationalAid: [#{kind}] #{[id, name].compact.join(' / ')}".dress
43
+ builder.text "\n"
46
44
  builder.Tcn({ source: (source if AIXM.ofmx?) }.compact) do |tcn|
47
- tcn << to_uid.indent(2)
48
- tcn << organisation.to_uid.indent(2)
49
- tcn << vor.to_uid.indent(2) if vor
45
+ tcn.comment(indented_comment) if comment
46
+ add_uid_to(tcn)
47
+ organisation.add_uid_to(tcn)
48
+ vor.add_uid_to(tcn) if vor
50
49
  tcn.txtName(name) if name
51
50
  tcn.codeChannel(channel)
52
51
  if !vor && AIXM.ofmx?
@@ -56,11 +55,10 @@ module AIXM
56
55
  tcn.codeDatum('WGE')
57
56
  if z
58
57
  tcn.valElev(z.alt)
59
- tcn.uomDistVer(z.unit.upcase.to_s)
58
+ tcn.uomDistVer(z.unit.upcase)
60
59
  end
61
- tcn << timetable.to_xml(as: :Ttt).indent(2) if timetable
60
+ timetable.add_to(tcn, as: :Ttt) if timetable
62
61
  tcn.txtRmk(remarks) if remarks
63
- tcn.target!
64
62
  end
65
63
  end
66
64
  end
@@ -23,13 +23,12 @@ module AIXM
23
23
  # )
24
24
  # vor.timetable = AIXM.timetable or nil
25
25
  # vor.remarks = String or nil
26
+ # vor.comment = Object or nil
26
27
  # vor.associate_dme # turns the VOR into a VOR/DME
27
28
  # vor.associate_tacan # turns the VOR into a VORTAC
28
29
  #
29
30
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Navigational-aid#vor-vor
30
31
  class VOR < NavigationalAid
31
- include AIXM::Memoize
32
-
33
32
  public_class_method :new
34
33
 
35
34
  TYPES = {
@@ -132,39 +131,37 @@ module AIXM
132
131
  end
133
132
  end
134
133
 
135
- # @return [String] UID markup
136
- def to_uid
137
- builder = Builder::XmlMarkup.new(indent: 2)
134
+ # @!visibility private
135
+ def add_uid_to(builder)
138
136
  builder.VorUid({ region: (region if AIXM.ofmx?) }.compact) do |vor_uid|
139
137
  vor_uid.codeId(id)
140
138
  vor_uid.geoLat(xy.lat(AIXM.schema))
141
139
  vor_uid.geoLong(xy.long(AIXM.schema))
142
140
  end
143
141
  end
144
- memoize :to_uid
145
142
 
146
- # @return [String] AIXM or OFMX markup
147
- def to_xml
148
- builder = to_builder
143
+ # @!visibility private
144
+ def add_to(builder)
145
+ super
149
146
  builder.Vor({ source: (source if AIXM.ofmx?) }.compact) do |vor|
150
- vor << to_uid.indent(2)
151
- vor << organisation.to_uid.indent(2)
147
+ vor.comment(indented_comment) if comment
148
+ add_uid_to(vor)
149
+ organisation.add_uid_to(vor)
152
150
  vor.txtName(name) if name
153
- vor.codeType(type_key.to_s)
151
+ vor.codeType(type_key)
154
152
  vor.valFreq(f.freq.trim)
155
- vor.uomFreq(f.unit.upcase.to_s)
156
- vor.codeTypeNorth(north_key.to_s)
153
+ vor.uomFreq(f.unit.upcase)
154
+ vor.codeTypeNorth(north_key)
157
155
  vor.codeDatum('WGE')
158
156
  if z
159
157
  vor.valElev(z.alt)
160
- vor.uomDistVer(z.unit.upcase.to_s)
158
+ vor.uomDistVer(z.unit.upcase)
161
159
  end
162
- vor << timetable.to_xml(as: :Vtt).indent(2) if timetable
160
+ timetable.add_to(vor, as: :Vtt) if timetable
163
161
  vor.txtRmk(remarks) if remarks
164
162
  end
165
- builder << @dme.to_xml if @dme
166
- builder << @tacan.to_xml if @tacan
167
- builder.target!
163
+ @dme.add_to(builder) if @dme
164
+ @tacan.add_to(builder) if @tacan
168
165
  end
169
166
 
170
167
  # @api private
@@ -5,7 +5,7 @@ module AIXM
5
5
 
6
6
  # @abstract
7
7
  class NavigationalAid < Feature
8
- include AIXM::Association
8
+ include AIXM::Concerns::Association
9
9
  include AIXM::Concerns::Timetable
10
10
  include AIXM::Concerns::Remarks
11
11
 
@@ -84,17 +84,17 @@ module AIXM
84
84
  [self.class.name.split('::').last, type_key].compact.join(':'.freeze)
85
85
  end
86
86
 
87
+ # @!visibility private
88
+ def add_to(builder)
89
+ builder.comment "NavigationalAid: [#{kind}] #{[id, name].compact.join(' / ')}".dress
90
+ builder.text "\n"
91
+ end
92
+
87
93
  private
88
94
 
89
95
  def type_key
90
96
  nil
91
97
  end
92
-
93
- def to_builder
94
- builder = Builder::XmlMarkup.new(indent: 2)
95
- builder.comment! "NavigationalAid: [#{kind}] #{[id, name].compact.join(' / ')}"
96
- builder
97
- end
98
98
  end
99
99
 
100
100
  end
@@ -27,6 +27,7 @@ module AIXM
27
27
  # obstacle.valid_from = Time or Date or String or nil
28
28
  # obstacle.valid_until = Time or Date or String or nil
29
29
  # obstacle.remarks = String or nil
30
+ # obstacle.comment = Object or nil
30
31
  # obstacle.link_to # => AIXM.obstacle or nil
31
32
  # obstacle.link_type # => LINK_TYPE or nil
32
33
  #
@@ -41,8 +42,7 @@ module AIXM
41
42
  #
42
43
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Obstacle
43
44
  class Obstacle < Feature
44
- include AIXM::Association
45
- include AIXM::Memoize
45
+ include AIXM::Concerns::Association
46
46
  include AIXM::Concerns::Remarks
47
47
 
48
48
  public_class_method :new
@@ -208,7 +208,7 @@ module AIXM
208
208
 
209
209
  # @return [String]
210
210
  def inspect
211
- %Q(#<#{self.class} xy="#{xy.to_s}" type=#{type.inspect} name=#{name.inspect}>)
211
+ %Q(#<#{self.class} xy="#{xy}" type=#{type.inspect} name=#{name.inspect}>)
212
212
  end
213
213
 
214
214
  def name=(value)
@@ -306,31 +306,30 @@ module AIXM
306
306
  !!linked_to
307
307
  end
308
308
 
309
- # @return [String] UID markup
310
- def to_uid(as: :ObsUid)
309
+ # @!visibility private
310
+ def add_uid_to(builder, as: :ObsUid)
311
311
  obstacle_group = self.obstacle_group || singleton_obstacle_group
312
- builder = Builder::XmlMarkup.new(indent: 2)
313
- builder.tag!(as) do |tag|
314
- tag << obstacle_group.to_uid.indent(2) if AIXM.ofmx?
312
+ builder.send(as) do |tag|
313
+ obstacle_group.add_uid_to(tag) if AIXM.ofmx?
315
314
  tag.geoLat((xy.lat(AIXM.schema)))
316
315
  tag.geoLong((xy.long(AIXM.schema)))
317
316
  end
318
317
  end
319
- memoize :to_uid
320
318
 
321
- # @return [String] AIXM or OFMX markup
322
- def to_xml(delegate: true)
319
+ # @!visibility private
320
+ def add_to(builder, delegate: true)
323
321
  obstacle_group = self.obstacle_group || singleton_obstacle_group
324
- return obstacle_group.to_xml if delegate && AIXM.ofmx?
325
- builder = Builder::XmlMarkup.new(indent: 2)
326
- builder.comment! "Obstacle: [#{type}] #{xy.to_s} #{name}".strip
322
+ return obstacle_group.add_to(builder) if delegate && AIXM.ofmx?
323
+ builder.comment "Obstacle: [#{type}] #{xy.to_s} #{name}".dress
324
+ builder.text "\n"
327
325
  builder.Obs({ source: (source if AIXM.ofmx?) }.compact) do |obs|
328
- obs << to_uid.indent(2)
326
+ obs.comment(indented_comment) if comment
327
+ add_uid_to(obs)
329
328
  obs.txtName(name) if name
330
329
  if AIXM.ofmx?
331
- obs.codeType(TYPES.key(type).to_s)
330
+ obs.codeType(TYPES.key(type))
332
331
  else
333
- obs.txtDescrType(TYPES.key(type).to_s)
332
+ obs.txtDescrType(TYPES.key(type))
334
333
  end
335
334
  obs.codeGroup(grouped? ? 'Y' : 'N')
336
335
  if AIXM.ofmx?
@@ -344,7 +343,7 @@ module AIXM
344
343
  obs.codeDatum('WGE')
345
344
  if AIXM.aixm? && obstacle_group.xy_accuracy
346
345
  obs.valGeoAccuracy(obstacle_group.xy_accuracy.dim.trim)
347
- obs.uomGeoAccuracy(obstacle_group.xy_accuracy.unit.upcase.to_s)
346
+ obs.uomGeoAccuracy(obstacle_group.xy_accuracy.unit.upcase)
348
347
  end
349
348
  obs.valElev(z.alt)
350
349
  if AIXM.aixm? && obstacle_group.z_accuracy
@@ -358,11 +357,11 @@ module AIXM
358
357
  if AIXM.ofmx?
359
358
  if radius
360
359
  obs.valRadius(radius.dim.trim)
361
- obs.uomRadius(radius.unit.upcase.to_s)
360
+ obs.uomRadius(radius.unit.upcase)
362
361
  end
363
362
  if grouped? && linked?
364
- obs << linked_to.to_uid(as: :ObsUidLink).indent(2)
365
- obs.codeLinkType(LINK_TYPES.key(link_type).to_s)
363
+ linked_to.add_uid_to(obs, as: :ObsUidLink)
364
+ obs.codeLinkType(LINK_TYPES.key(link_type))
366
365
  end
367
366
  obs.datetimeValidWef(valid_from.xmlschema) if valid_from
368
367
  obs.datetimeValidTil(valid_until.xmlschema) if valid_until
@@ -11,11 +11,11 @@ module AIXM
11
11
  # source: String or nil # see remarks below
12
12
  # region: String or nil
13
13
  # name: String or nil
14
- # ).tap do |obstacle_group|
15
- # obstacle_group.xy_accuracy = AIXM.d or nil
16
- # obstacle_group.z_accuracy = AIXM.d or nil
17
- # obstacle_group.remarks = String or nil
18
- # end
14
+ # )
15
+ # obstacle_group.xy_accuracy = AIXM.d or nil
16
+ # obstacle_group.z_accuracy = AIXM.d or nil
17
+ # obstacle_group.remarks = String or nil
18
+ # obstacle_group.comment = Object or nil
19
19
  # obstacle_group.add_obstacle( # add an obstacle to the group
20
20
  # AIXM.obstacle
21
21
  # )
@@ -38,8 +38,7 @@ module AIXM
38
38
  #
39
39
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Obstacle
40
40
  class ObstacleGroup < Feature
41
- include AIXM::Association
42
- include AIXM::Memoize
41
+ include AIXM::Concerns::Association
43
42
  include AIXM::Concerns::Remarks
44
43
 
45
44
  public_class_method :new
@@ -88,7 +87,7 @@ module AIXM
88
87
 
89
88
  # @return [String]
90
89
  def inspect
91
- %Q(#<#{self.class} #{@obstacles.count} obstacle(s)>)
90
+ %Q(#<#{self.class} #{obstacles.count} obstacle(s)>)
92
91
  end
93
92
 
94
93
  def name=(value)
@@ -106,28 +105,27 @@ module AIXM
106
105
  @z_accuracy = value
107
106
  end
108
107
 
109
- # @return [String] UID markup
110
- def to_uid
111
- builder = Builder::XmlMarkup.new(indent: 2)
108
+ # @!visibility private
109
+ def add_uid_to(builder)
112
110
  builder.OgrUid({ region: (region if AIXM.ofmx?) }.compact) do |ogr_uid|
113
111
  ogr_uid.txtName(name)
114
112
  ogr_uid.geoLat(obstacles.first.xy.lat(AIXM.schema))
115
113
  ogr_uid.geoLong(obstacles.first.xy.long(AIXM.schema))
116
114
  end
117
115
  end
118
- memoize :to_uid
119
116
 
120
- # @return [String] AIXM or OFMX markup
121
- def to_xml
122
- builder = Builder::XmlMarkup.new(indent: 2)
117
+ # @!visibility private
118
+ def add_to(builder)
123
119
  if AIXM.ofmx?
124
- builder.comment! "Obstacle group: #{name}".strip
120
+ builder.comment "Obstacle group: #{name}".dress
121
+ builder.text "\n"
125
122
  builder.Ogr({ source: (source if AIXM.ofmx?) }.compact) do |ogr|
126
- ogr << to_uid.indent(2)
123
+ ogr.comment(indented_comment) if comment
124
+ add_uid_to(ogr)
127
125
  ogr.codeDatum('WGE')
128
126
  if xy_accuracy
129
127
  ogr.valGeoAccuracy(xy_accuracy.dim.trim)
130
- ogr.uomGeoAccuracy(xy_accuracy.unit.upcase.to_s)
128
+ ogr.uomGeoAccuracy(xy_accuracy.unit.upcase)
131
129
  end
132
130
  if z_accuracy
133
131
  ogr.valElevAccuracy(z_accuracy.to_ft.dim.round)
@@ -136,8 +134,9 @@ module AIXM
136
134
  ogr.txtRmk(remarks) if remarks
137
135
  end
138
136
  end
139
- obstacles.each { builder << _1.to_xml(delegate: false) }
140
- builder.target!
137
+ obstacles.each do |obstacle|
138
+ obstacle.add_to(builder, delegate: false)
139
+ end
141
140
  end
142
141
  end
143
142
 
@@ -15,11 +15,11 @@ module AIXM
15
15
  # )
16
16
  # organisation.id = String or nil
17
17
  # organisation.remarks = String or nil
18
+ # organisation.comment = Object or nil
18
19
  #
19
20
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Organisation#org-organisation
20
21
  class Organisation < Feature
21
- include AIXM::Association
22
- include AIXM::Memoize
22
+ include AIXM::Concerns::Association
23
23
  include AIXM::Concerns::Remarks
24
24
 
25
25
  public_class_method :new
@@ -96,23 +96,22 @@ module AIXM
96
96
  @id = value&.upcase
97
97
  end
98
98
 
99
- # @return [String] UID markup
100
- def to_uid
101
- builder = Builder::XmlMarkup.new(indent: 2)
99
+ # @!visibility private
100
+ def add_uid_to(builder)
102
101
  builder.OrgUid({ region: (region if AIXM.ofmx?) }.compact) do |org_uid|
103
102
  org_uid.txtName(name)
104
103
  end
105
104
  end
106
- memoize :to_uid
107
105
 
108
- # @return [String] AIXM or OFMX markup
109
- def to_xml
110
- builder = Builder::XmlMarkup.new(indent: 2)
111
- builder.comment! "Organisation: #{name}"
106
+ # @!visibility private
107
+ def add_to(builder)
108
+ builder.comment "Organisation: #{name}".dress
109
+ builder.text "\n"
112
110
  builder.Org({ source: (source if AIXM.ofmx?) }.compact) do |org|
113
- org << to_uid.indent(2)
111
+ org.comment(indented_comment) if comment
112
+ add_uid_to(org)
114
113
  org.codeId(id) if id
115
- org.codeType(TYPES.key(type).to_s)
114
+ org.codeType(TYPES.key(type))
116
115
  org.txtRmk(remarks) if remarks
117
116
  end
118
117
  end
@@ -17,12 +17,12 @@ module AIXM
17
17
  # )
18
18
  # unit.airport = AIXM.airport or nil
19
19
  # unit.remarks = String or nil
20
+ # unit.comment = Object or nil
20
21
  # unit.add_service(AIXM.service)
21
22
  #
22
23
  # @see https://gitlab.com/openflightmaps/ofmx/wikis/Organisation#uni-unit
23
24
  class Unit < Feature
24
- include AIXM::Association
25
- include AIXM::Memoize
25
+ include AIXM::Concerns::Association
26
26
  include AIXM::Concerns::Remarks
27
27
 
28
28
  public_class_method :new
@@ -151,32 +151,30 @@ module AIXM
151
151
  @klass = CLASSES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid class")
152
152
  end
153
153
 
154
- # @return [String] UID markup
155
- def to_uid
156
- builder = Builder::XmlMarkup.new(indent: 2)
154
+ # @!visibility private
155
+ def add_uid_to(builder)
157
156
  builder.UniUid({ region: (region if AIXM.ofmx?) }.compact) do |uni_uid|
158
157
  uni_uid.txtName(name)
159
- uni_uid.codeType(TYPES.key(type).to_s) if AIXM.ofmx?
158
+ uni_uid.codeType(TYPES.key(type)) if AIXM.ofmx?
160
159
  end
161
160
  end
162
- memoize :to_uid
163
161
 
164
- # @return [String] AIXM or OFMX markup
165
- def to_xml
166
- builder = Builder::XmlMarkup.new(indent: 2)
167
- builder.comment! "Unit: #{name_with_type}"
162
+ # @!visibility private
163
+ def add_to(builder)
164
+ builder.comment "Unit: #{name_with_type}".dress
165
+ builder.text "\n"
168
166
  builder.Uni({ source: (source if AIXM.ofmx?) }.compact) do |uni|
169
- uni << to_uid.indent(2)
170
- uni << organisation.to_uid.indent(2)
171
- uni << airport.to_uid.indent(2) if airport
172
- uni.codeType(TYPES.key(type).to_s) unless AIXM.ofmx?
173
- uni.codeClass(CLASSES.key(self.class).to_s)
167
+ uni.comment(indented_comment) if comment
168
+ add_uid_to(uni)
169
+ organisation.add_uid_to(uni)
170
+ airport.add_uid_to(uni) if airport
171
+ uni.codeType(TYPES.key(type)) unless AIXM.ofmx?
172
+ uni.codeClass(CLASSES.key(self.class))
174
173
  uni.txtRmk(remarks) if remarks
175
174
  end
176
175
  services.sort { |a, b| a.type <=> b.type }.each do |service|
177
- builder << service.to_xml
176
+ service.add_to(builder)
178
177
  end
179
- builder.target!
180
178
  end
181
179
 
182
180
  private
data/lib/aixm/feature.rb CHANGED
@@ -1,17 +1,21 @@
1
+ using AIXM::Refinements
2
+
1
3
  module AIXM
2
4
 
3
5
  # @abstract
4
- class Feature
5
- include AIXM::Concerns::HashEquality
6
+ class Feature < Component
6
7
 
7
8
  REGION_RE = /\A[A-Z]{2}\z/.freeze
8
9
 
9
10
  private_class_method :new
10
11
 
11
- # Freely usable e.g. to find_by foreign keys.
12
+ # Freely usable XML comment e.g. to include raw source data
12
13
  #
13
- # @return [Object]
14
- attr_accessor :meta
14
+ # @overload comment
15
+ # @return [String]
16
+ # @overload comment=(value)
17
+ # @param value [Object]
18
+ attr_reader :comment
15
19
 
16
20
  # Reference to source of the feature data.
17
21
  #
@@ -34,6 +38,10 @@ module AIXM
34
38
  self.region = region || AIXM.config.region
35
39
  end
36
40
 
41
+ def comment=(value)
42
+ @comment = value.to_s.strip
43
+ end
44
+
37
45
  def source=(value)
38
46
  fail(ArgumentError, "invalid source") unless value.nil? || value.is_a?(String)
39
47
  @source = value
@@ -46,12 +54,23 @@ module AIXM
46
54
 
47
55
  # @see Object#==
48
56
  def ==(other)
49
- self.__class__ === other && self.to_uid == other.to_uid
57
+ self.__class__ === other && self.to_uid.to_s == other.to_uid.to_s
50
58
  end
51
59
 
52
60
  # @see Object#eql?
53
61
  def hash
54
- [self.__class__, to_uid].hash
62
+ [self.__class__, to_uid.to_s].hash
63
+ end
64
+
65
+ protected
66
+
67
+ # @return [String]
68
+ def indented_comment
69
+ if comment.include?("\n")
70
+ [nil, comment.indent(4), ' '].join("\n")
71
+ else
72
+ comment.dress
73
+ end
55
74
  end
56
75
  end
57
76
 
data/lib/aixm/object.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # This monkey patch is necessary because some classes have to introduce
2
2
  # attributes named +class+ (e.g. for airspace classes as described by
3
3
  # +AIXM::Component::Layer+) which clash with this core method. Other parts
4
- # such as +AIXM::Association+ need the original implementation for introspection
4
+ # such as +AIXM::Concerns::Association+ need the original implementation for introspection
5
5
  # which is why this alias +Object#__class__+ makes it globally and consistently
6
6
  # available again.
7
7
  class Object
@@ -15,6 +15,16 @@ module AIXM
15
15
  "Ø" => "Oe"
16
16
  }.freeze
17
17
 
18
+ PRETTY_XSLT = <<~END.then { Nokogiri::XSLT(_1) }
19
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
20
+ <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
21
+ <xsl:strip-space elements="*"/>
22
+ <xsl:template match="/">
23
+ <xsl:copy-of select="."/>
24
+ </xsl:template>
25
+ </xsl:stylesheet>
26
+ END
27
+
18
28
  # @!method to_digest
19
29
  # Builds a 4 byte hex digest from the Array payload.
20
30
  #
@@ -108,6 +118,7 @@ module AIXM
108
118
  # @note This is a refinement for +Hash+
109
119
  # @param key_or_value [Object] key or value of the hash
110
120
  # @param fallback [Object] fallback value
121
+ # @return [Object]
111
122
  # @raise [KeyError] if neither a matching hash key nor hash value are
112
123
  # found and no fallback value has been passed
113
124
  refine Hash do
@@ -118,6 +129,36 @@ module AIXM
118
129
  end
119
130
  end
120
131
 
132
+ # @!method pretty
133
+ # Transform the XML document to be pretty when sending +to_xml+
134
+ #
135
+ # @example
136
+ # xml = <<~END
137
+ # <xml><aaa> AAA </aaa>
138
+ # <bbb/>
139
+ # <ccc foo="bar" >
140
+ # CCC
141
+ # </ccc>
142
+ # </xml>
143
+ # END
144
+ # Nokogiri.XML(xml).pretty.to_xml
145
+ # # => <?xml version=\"1.0\" encoding=\"UTF-8\"?>
146
+ # <xml>
147
+ # <aaa> AAA </aaa>
148
+ # <bbb/>
149
+ # <ccc foo="bar">
150
+ # CCC
151
+ # </ccc>
152
+ # </xml>
153
+ #
154
+ # @note This is a refinement for +Nokogiri::XML::Document+
155
+ # @return [Nokogiri::XML::Document]
156
+ refine Nokogiri::XML::Document do
157
+ def pretty
158
+ PRETTY_XSLT.transform(self)
159
+ end
160
+ end
161
+
121
162
  # @!method then_if
122
163
  # Same as +Object#then+ but only applied if the condition is true.
123
164
  #
@@ -169,6 +210,22 @@ module AIXM
169
210
  end
170
211
  end
171
212
 
213
+ # @!method dress
214
+ # Prepends and appends the given +string+ after stripping +self+. Quite
215
+ # the contrary of +strip+, hence the name.
216
+ #
217
+ # @example
218
+ # " foobar\n\n".dress # => " foobar "
219
+ #
220
+ # @note This is a refinement for +String+
221
+ # @param padding [String] string to prepend and append
222
+ # @return [String]
223
+ refine String do
224
+ def dress(padding=' ')
225
+ [padding, strip, padding].join
226
+ end
227
+ end
228
+
172
229
  # @!method to_class
173
230
  # Convert string to class
174
231
  #
data/lib/aixm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module AIXM
2
- VERSION = "1.2.1".freeze
2
+ VERSION = "1.3.0".freeze
3
3
  end
data/lib/aixm.rb CHANGED
@@ -8,7 +8,6 @@ require 'forwardable'
8
8
  require 'digest'
9
9
  require 'optparse'
10
10
 
11
- require 'builder'
12
11
  require 'nokogiri'
13
12
  require 'dry/inflector'
14
13
  require 'sun'
@@ -22,10 +21,11 @@ require_relative 'aixm/errors'
22
21
 
23
22
  require_relative 'aixm/classes'
24
23
  require_relative 'aixm/constants'
25
- require_relative 'aixm/memoize'
26
- require_relative 'aixm/association'
27
24
  require_relative 'aixm/payload_hash'
28
25
 
26
+ require_relative 'aixm/concerns/memoize'
27
+ require_relative 'aixm/concerns/association'
28
+ require_relative 'aixm/concerns/xml_builder'
29
29
  require_relative 'aixm/concerns/hash_equality'
30
30
  require_relative 'aixm/concerns/timetable'
31
31
  require_relative 'aixm/concerns/intensity'
@@ -82,6 +82,7 @@ require_relative 'aixm/feature/obstacle'
82
82
  require_relative 'aixm/feature/obstacle_group'
83
83
  require_relative 'aixm/feature/organisation'
84
84
  require_relative 'aixm/feature/unit'
85
+ require_relative 'aixm/feature/generic'
85
86
 
86
87
  require_relative 'aixm/shortcuts'
87
88
  require_relative 'aixm/executables'
@@ -215,7 +215,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
215
215
  </xsd:attribute>
216
216
  <xsd:attribute name="effective" type="xsd:dateTime" use="required">
217
217
  <xsd:annotation>
218
- <xsd:documentation>The date and time used as criteria to select valid versions included in the message</xsd:documentation>
218
+ <xsd:documentation>The beginning date and time used as criteria to select valid versions included in the message</xsd:documentation>
219
+ </xsd:annotation>
220
+ </xsd:attribute>
221
+ <xsd:attribute name="expiration" type="xsd:dateTime">
222
+ <xsd:annotation>
223
+ <xsd:documentation>The optional end date and time used as criteria to select valid versions included in the message</xsd:documentation>
219
224
  </xsd:annotation>
220
225
  </xsd:attribute>
221
226
  </xsd:complexType>
data.tar.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- /5�D�����owD~
2
- Z��.W;6��(s���Γ��~3��=�P(˲n/�f��,v����R�S��Bi��Lb@��:*�<Ɨ�٩}W���wcFv�ܼ�VC��
3
- uL��y4Du3��"�����jwnTT���m����O*���n
1
+ f���}fu���D`,F��E���ZQ�{�FA��g\���f�,P�*��ϗ@P���;���:7���ܫ�\俭��z ��-}����ʢ挰��N��A�ь�Z*��J�xÕ�smЖ�?Wd4��.7�7�)���
2
+ =sZ���/���!wv���cUp��#�����]��yY��R �S �OS� �����՚�af5
3
+ �?����"��8.�lCHv;���P�՗(��e.���m�v��7