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

Returns a new instance of 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, ...

Returns displaced threshold point either as coordinates (AIXM::XY) or distance (AIXM::D) from the beginning point.

Returns:

  • (AIXM::XY, AIXM::D, nil)

    displaced threshold point either as coordinates (AIXM::XY) or distance (AIXM::D) from the beginning point


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

def displaced_threshold
  @displaced_threshold
end

#geographic_orientationAIXM::A?

Returns geographic orientation (true bearing) in degrees.

Returns:

  • (AIXM::A, nil)

    geographic orientation (true bearing) in degrees


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

def geographic_orientation
  @geographic_orientation
end

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

Returns installed lighting systems.

Returns:


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

def lightings
  @lightings
end

#nameAIXM::A

Returns partial name of runway (e.g. “12” or “16L”).

Returns:

  • (AIXM::A)

    partial name of runway (e.g. “12” or “16L”)


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

def name
  @name
end

#remarksString?

Returns free text remarks.

Returns:

  • (String, nil)

    free text remarks


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?

Returns direction of the VFR flight pattern (see VFR_PATTERNS).

Returns:

  • (Symbol, nil)

    direction of the VFR flight pattern (see VFR_PATTERNS)


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

def vfr_pattern
  @vfr_pattern
end

#xyAIXM::XY

Returns beginning point (middle of the runway width).

Returns:

  • (AIXM::XY)

    beginning point (middle of the runway width)


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

def xy
  @xy
end

#zAIXM::Z?

Returns elevation of the touch down zone in qnh.

Returns:

  • (AIXM::Z, nil)

    elevation of the touch down zone in qnh


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.

Parameters:

Returns:

  • (self)

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

Returns:

  • (String)

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

Returns magnetic orientation (magnetic bearing) in degrees.

Returns:

  • (AIXM::A)

    magnetic orientation (magnetic bearing) in degrees


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

Returns UID markup.

Returns:

  • (String)

    UID markup


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

Returns AIXM or OFMX markup.

Returns:

  • (String)

    AIXM or OFMX markup


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