Class: AIPP::LF::AIP::NavigationalAids

Inherits:
AIP::Parser show all
Includes:
Helpers::Base
Defined in:
lib/aipp/regions/LF/aip/navigational_aids.rb

Constant Summary collapse

SOURCE_TYPES =
{
  'DME-ATT' => [:dme],
  'TACAN' => [:tacan],
  'VOR' => [:vor],
  'VOR-DME' => [:vor, :dme],
  'VORTAC' => [:vor, :tacan],
  'NDB' => [:ndb]
}.freeze

Constants included from Helpers::Base

Helpers::Base::VERSION

Instance Attribute Summary

Attributes inherited from Parser

#aixm

Instance Method Summary collapse

Methods included from Helpers::Base

#b_from, #d_from, #geometry_from, #layer_from, #organisation_lf, #origin_for, #setup, #source, #timetable_from, #xy_from, #z_from

Methods inherited from Parser

#add, dependencies, depends_on, #find, #find_by, #given, #initialize, #inspect, #link_to, #origin_for, #read, #section

Methods included from Patcher

#attach_patches, #detach_patches

Methods included from Debugger

#info, #original_warn, #verbose_info, #warn, #with_debugger

Constructor Details

This class inherits a constructor from AIPP::Parser

Instance Method Details

#parseObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/aipp/regions/LF/aip/navigational_aids.rb', line 15

def parse
  SOURCE_TYPES.each do |source_type, (primary_type, secondary_type)|
    verbose_info("processing #{source_type}")
    AIPP.cache.navfix.css(%Q(NavFix[lk^="[LF][#{source_type} "])).each do |navfix_node|
      attributes = {
        source: source(part: 'ENR', position: navfix_node.line),
        organisation: organisation_lf,
        id: navfix_node.(:Ident),
        xy: xy_from(navfix_node.(:Geometrie))
      }
      if radionav_node = AIPP.cache.radionav.at_css(%Q(RadioNav:has(NavFix[pk="#{navfix_node.attr(:pk)}"])))
        attributes.merge! send(primary_type, radionav_node)
        add(
          AIXM.send(primary_type, **attributes).tap do |navigational_aid|
            navigational_aid.name = radionav_node.(:NomPhraseo) || radionav_node.(:Station)
            navigational_aid.timetable = timetable_from(radionav_node.(:HorCode))
            navigational_aid.remarks = {
              "location/situation" => radionav_node.(:Situation),
              "range/portée" => range_from(radionav_node)
            }.to_remarks
            navigational_aid.send("associate_#{secondary_type}") if secondary_type
          end
        )
      else
        verbose_info("skipping incomplete #{source_type} #{attributes[:id]}")
      end
    end
  end
end