Class: AIXM::Feature::NavigationalAid::NDB

Inherits:
AIXM::Feature::NavigationalAid show all
Defined in:
lib/aixm/feature/navigational_aid/ndb.rb

Overview

A non-directional radio beacon (NDB) is a radio transmitter at a known location operating in the frequency band between 190 kHz and 1750 kHz.

Cheat Sheet in Pseudo Code:

ndb = AIXM.ndb(
  source: String or nil
  organisation: AIXM.organisation
  id: String
  name: String
  xy: AIXM.xy
  z: AIXM.z or nil
  type: TYPES
  f: AIXM.f
)
ndb.timetable = AIXM.timetable or nil
ndb.remarks = String or nil

Constant Summary collapse

TYPES =
{
  B: :en_route,
  L: :locator,
  M: :marine,
  OTHER: :other   # specify in remarks
}.freeze

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature::NavigationalAid

#id, #name, #remarks, #timetable, #xy, #z

Attributes inherited from AIXM::Feature

#source

Instance Method Summary collapse

Methods inherited from AIXM::Feature::NavigationalAid

#inspect, #kind

Methods inherited from AIXM::Feature

#==

Constructor Details

#initialize(type:, f:, **arguments) ⇒ NDB


41
42
43
44
# File 'lib/aixm/feature/navigational_aid/ndb.rb', line 41

def initialize(type:, f:, **arguments)
  super(**arguments)
  self.type, self.f = type, f
end

Instance Attribute Details

#fAIXM::F


39
40
41
# File 'lib/aixm/feature/navigational_aid/ndb.rb', line 39

def f
  @f
end

#typeSymbol?


36
37
38
# File 'lib/aixm/feature/navigational_aid/ndb.rb', line 36

def type
  @type
end

Instance Method Details

#to_uidString


56
57
58
59
60
61
62
63
# File 'lib/aixm/feature/navigational_aid/ndb.rb', line 56

def to_uid
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.NdbUid do |ndb_uid|
    ndb_uid.codeId(id)
    ndb_uid.geoLat(xy.lat(AIXM.schema))
    ndb_uid.geoLong(xy.long(AIXM.schema))
  end.insert_payload_hash(region: AIXM.config.mid_region)
end

#to_xmlString


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/aixm/feature/navigational_aid/ndb.rb', line 66

def to_xml
  builder = to_builder
  builder.Ndb({ source: (source if AIXM.ofmx?) }.compact) do |ndb|
    ndb << to_uid.indent(2)
    ndb << organisation.to_uid.indent(2)
    ndb.txtName(name) if name
    ndb.valFreq(f.freq.trim)
    ndb.uomFreq(f.unit.upcase.to_s)
    ndb.codeClass(type_key.to_s) if type
    ndb.codeDatum('WGE')
    if z
      ndb.valElev(z.alt)
      ndb.uomDistVer(z.unit.upcase.to_s)
    end
    ndb << timetable.to_xml(as: :Ntt).indent(2) if timetable
    ndb.txtRmk(remarks) if remarks
    ndb.target!
  end
end