Sha256: 726d099be0ae81101dcf4a912bb5b536ef149d7c23a3b070e4f68325594eeef2

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module AIPP
  module LF

    class DesignatedPoints < AIP

      include AIPP::LF::Helpers::Base

      DEPENDS = %w(aerodromes)

      SOURCE_TYPES = {
        'VFR' => :vfr_reporting_point,
        'WPT' => :icao
      }.freeze

      def parse
        SOURCE_TYPES.each do |source_type, type|
          verbose_info("processing #{source_type}")
          cache.navfix.css(%Q(NavFix[lk^="[LF][#{source_type} "])).each do |navfix_node|
            ident = navfix_node.(:Ident)
            add(
              AIXM.designated_point(
                source: source(section: '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::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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aipp-1.0.0 lib/aipp/regions/LF/designated_points.rb