Class: AIXM::Feature::NavigationalAid::DME

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

Overview

Distance measuring equipment (DME) is a transponder-based radio navigation technology which measures slant range distance by timing the propagation delay of VHF or UHF signals. They operate in the frequency band between 962 MHz and 1213 MHz.

Cheat Sheet in Pseudo Code:

dme = AIXM.dme(
  source: String or nil
  organisation: AIXM.organisation
  id: String
  name: String
  xy: AIXM.xy
  z: AIXM.z or nil
  channel: String
)
dme.timetable = AIXM.timetable or nil
dme.remarks = String or nil

Direct Known Subclasses

TACAN

Constant Summary collapse

CHANNEL_RE =
/\A([1-9]|[1-9]\d|1[0-1]\d|12[0-6])[XY]\z/.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(channel:, **arguments) ⇒ DME


37
38
39
40
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 37

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

Instance Attribute Details

#channelString


32
33
34
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 32

def channel
  @channel
end

#vorAIXM::Feature::NavigationalAid::VOR?


35
36
37
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 35

def vor
  @vor
end

Instance Method Details

#ghost_fAIXM::F


48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 48

def ghost_f
  if channel
    number, letter = channel.split(/(?=[XY])/)
    integer = case number.to_i
      when (1..16) then 13430
      when (17..59) then 10630
      when (60..69) then 12730
      when (70..126) then 10530
    end
    integer += number.to_i * 10
    integer += 5 if letter == 'Y'
    AIXM.f(integer.to_f / 100, :mhz)
  end
end

#to_uidString


70
71
72
73
74
75
76
77
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 70

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

#to_xmlString


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/aixm/feature/navigational_aid/dme.rb', line 80

def to_xml
  builder = to_builder
  builder.Dme({ source: (source if AIXM.ofmx?) }.compact) do |dme|
    dme << to_uid.indent(2)
    dme << organisation.to_uid.indent(2)
    dme << vor.to_uid.indent(2) if vor
    dme.txtName(name) if name
    dme.codeChannel(channel)
    unless vor
      dme.valGhostFreq(ghost_f.freq.trim)
      dme.uomGhostFreq('MHZ')
    end
    dme.codeDatum('WGE')
    if z
      dme.valElev(z.alt)
      dme.uomDistVer(z.unit.upcase.to_s)
    end
    dme << timetable.to_xml(as: :Dtt).indent(2) if timetable
    dme.txtRmk(remarks) if remarks
    dme.target!
  end
end