Class: AIPP::LF::AIP::DesignatedPoints

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

Constant Summary collapse

SOURCE_TYPES =
{
  'VFR' => :vfr_reporting_point,
  'WPT' => :icao
}.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, included

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



13
14
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
# File 'lib/aipp/regions/LF/aip/designated_points.rb', line 13

def parse
  SOURCE_TYPES.each do |source_type, type|
    verbose_info("processing #{source_type}")
    AIPP.cache.navfix.css(%Q(NavFix[lk^="[LF][#{source_type} "])).each do |navfix_node|
      ident = navfix_node.(:Ident)
      add(
        AIXM.designated_point(
          source: source(part: 'ENR', position: navfix_node.line),
          type: type,
          id: ident.split('-').last.remove(/[^a-z\d]/i),   # only use last segment of ID
          name: ident,
          xy: xy_from(navfix_node.(:Geometrie))
        ).tap do |designated_point|
          designated_point.remarks = navfix_node.(:Description)
          if ident.match? /-/
            airport = find_by(:airport, id: "LF#{ident.split('-').first}").first
            designated_point.airport = airport
          end
        end
      )
    end
  end
  AIXM::Concerns::Memoize.method :to_uid do
    aixm.features.find_by(:designated_point).duplicates.each do |duplicates|
      duplicates.first.name += '/' + duplicates[1..].map(&:name).join('/')
      aixm.remove_features(duplicates[1..])
    end
  end
end