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

Inherits:
Object
  • Object
show all
Includes:
Association, Memoize
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

Methods included from Memoize

cache, included, method

Methods included from Association

included

Constructor Details

#initialize(name:) ⇒ Direction


220
221
222
# File 'lib/aixm/component/runway.rb', line 220

def initialize(name:)
  self.name = name
end

Instance Attribute Details

#displaced_thresholdAIXM::XY, ...


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

def displaced_threshold
  @displaced_threshold
end

#geographic_orientationAIXM::A?


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

def geographic_orientation
  @geographic_orientation
end

#nameAIXM::A


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

def name
  @name
end

#remarksString?


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

def remarks
  @remarks
end

#vfr_patternSymbol?


215
216
217
# File 'lib/aixm/component/runway.rb', line 215

def vfr_pattern
  @vfr_pattern
end

#xyAIXM::XY


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

def xy
  @xy
end

#zAIXM::Z?


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

def z
  @z
end

Instance Method Details

#add_lighting(lighting) ⇒ self


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

has_many :lightings, as: :lightable

#inspectString


225
226
227
# File 'lib/aixm/component/runway.rb', line 225

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

#lightingsArray<AIXM::Component::Lighting>


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

has_many :lightings, as: :lightable

#magnetic_orientationAIXM::A


273
274
275
276
277
# File 'lib/aixm/component/runway.rb', line 273

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

#runwayAIXM::Component::Runway


195
# File 'lib/aixm/component/runway.rb', line 195

belongs_to :runway, readonly: true

#to_uidString


280
281
282
283
284
285
286
# File 'lib/aixm/component/runway.rb', line 280

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
end

#to_xmlString


290
291
292
293
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
# File 'lib/aixm/component/runway.rb', line 290

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