Class: AIXM::Component::Runway::Direction

Inherits:
Object
  • Object
show all
Defined in:
lib/aixm/component/runway.rb

Overview

Runway directions further describe each direction #forth and #back of a runway.

Constant Summary collapse

VFR_PATTERNS =
{
  L: :left,
  R: :right,
  E: :left_or_right
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runway:, name:) ⇒ Direction


207
208
209
210
# File 'lib/aixm/component/runway.rb', line 207

def initialize(runway:, name:)
  self.runway, self.name = runway, name
  @lightings = []
end

Instance Attribute Details

#displaced_thresholdAIXM::XY, ...


196
197
198
# File 'lib/aixm/component/runway.rb', line 196

def displaced_threshold
  @displaced_threshold
end

#geographic_orientationAIXM::A?


185
186
187
# File 'lib/aixm/component/runway.rb', line 185

def geographic_orientation
  @geographic_orientation
end

#lightingsArray<AIXM::Component::Lighting> (readonly)


205
206
207
# File 'lib/aixm/component/runway.rb', line 205

def lightings
  @lightings
end

#nameAIXM::A


182
183
184
# File 'lib/aixm/component/runway.rb', line 182

def name
  @name
end

#remarksString?


202
203
204
# File 'lib/aixm/component/runway.rb', line 202

def remarks
  @remarks
end

#runway=(value) ⇒ Object


217
218
219
220
# File 'lib/aixm/component/runway.rb', line 217

def runway=(value)
  fail(ArgumentError, "invalid runway") unless value.is_a? AIXM::Component::Runway
  @runway = value
end

#vfr_patternSymbol?


199
200
201
# File 'lib/aixm/component/runway.rb', line 199

def vfr_pattern
  @vfr_pattern
end

#xyAIXM::XY


188
189
190
# File 'lib/aixm/component/runway.rb', line 188

def xy
  @xy
end

#zAIXM::Z?


191
192
193
# File 'lib/aixm/component/runway.rb', line 191

def z
  @z
end

Instance Method Details

#add_lighting(lighting) ⇒ self

Add a lighting system to the runway direction.


270
271
272
273
274
275
# File 'lib/aixm/component/runway.rb', line 270

def add_lighting(lighting)
  fail(ArgumentError, "invalid lighting") unless lighting.is_a? AIXM::Component::Lighting
  lighting.send(:lightable=, self)
  @lightings << lighting
  self
end

#inspectString


213
214
215
# File 'lib/aixm/component/runway.rb', line 213

def inspect
  %Q(#<#{self.class} airport=#{runway&.airport&.id.inspect} name=#{name.inspect}>)
end

#magnetic_orientationAIXM::A


278
279
280
281
282
# File 'lib/aixm/component/runway.rb', line 278

def magnetic_orientation
  if geographic_orientation && runway.airport.declination
    geographic_orientation - runway.airport.declination
  end
end

#to_uidString


285
286
287
288
289
290
291
# File 'lib/aixm/component/runway.rb', line 285

def to_uid
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.RdnUid do |rdn_uid|
    rdn_uid << runway.to_uid.indent(2)
    rdn_uid.txtDesig(name)
  end.insert_payload_hash(region: AIXM.config.mid_region)
end

#to_xmlString


294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/aixm/component/runway.rb', line 294

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.Rdn do |rdn|
    rdn << to_uid.indent(2)
    rdn.geoLat(xy.lat(AIXM.schema))
    rdn.geoLong(xy.long(AIXM.schema))
    rdn.valTrueBrg(geographic_orientation) if geographic_orientation
    rdn.valMagBrg(magnetic_orientation) if magnetic_orientation
    if z
      rdn.valElevTdz(z.alt)
      rdn.uomElevTdz(z.unit.upcase.to_s)
    end
    rdn.codeVfrPattern(VFR_PATTERNS.key(vfr_pattern).to_s) if vfr_pattern
    rdn.txtRmk(remarks) if remarks
  end
  if displaced_threshold
    builder.Rdd do |rdd|
      rdd.RddUid do |rdd_uid|
        rdd_uid << to_uid.indent(4)
        rdd_uid.codeType('DPLM')
        rdd_uid.codeDayPeriod('A')
      end
      rdd.valDist(displaced_threshold.dist.trim)
      rdd.uomDist(displaced_threshold.unit.to_s.upcase)
      rdd.txtRmk(remarks) if remarks
    end
  end
  lightings.each do |lighting|
    builder << lighting.to_xml(as: :Rls)
  end
  builder.target!
end