Class: AIPP::LF::AIP::Services

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

Constant Summary collapse

SOURCE_TYPES =

Service types and how to treat them

{
  'A/A' => :address,
  'AFIS' => :service,
  'APP' => :service,
  'ATIS' => :service,
  'CCM' => :ignore,      # centre de contrôle militaire
  'CEV' => :ignore,      # centre d’essai en vol
  'D-ATIS' => :ignore,   # data link ATIS
  'FIS' => :service,
  'PAR' => :service,
  'SRE' => :ignore,      # surveillance radar element of PAR
  'TWR' => :service,
  'UAC' => :ignore,      # upper area control
  'VDF' => :service,
  'OTHER' => :service    # no <Service> specified at source
}.freeze
CALLSIGNS =

Map French callsigns to English and service type

{
  'Approche' => { en: 'Approach', service_type: 'APP' },
  'Contrôle' => { en: 'Control', service_type: 'ACS' },
  'Information' => { en: 'Information', service_type: 'FIS' },
  'GCA' => { en: 'GCA', service_type: 'GCA' },
  'Gonio' => { en: 'Gonio', service_type: 'VDF' },
  'Prévol' => { en: 'Delivery', service_type: 'SMC' },
  'Sol' => { en: 'Ground', service_type: 'SMC' },
  'Tour' => { en: 'Tower', service_type: 'TWR' },
  'Trafic' => { en: 'Apron', service_type: 'SMC' }
}.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



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/aipp/regions/LF/aip/services.rb', line 39

def parse
  AIPP.cache.service.css(%Q(Service[lk^="[LF]"][pk])).each do |service_node|
    # Ignore private services/frequencies
    next if service_node.(:IndicLieu) == 'XX'
    # Load referenced airport
    airport = given(service_node.at_css('Ad')&.attr('pk')) do
      find_by(:airport, meta: _1).first
    end
    # Build addresses and services
    case SOURCE_TYPES.fetch(type_for(service_node))
    when :address
      fail "dangling address without airport" unless airport
      addresses_from(service_node).each { airport.add_address(_1) }
    when :service
      given service_from(service_node) do |service|
        AIPP.cache.frequence.css(%Q(Frequence:has(Service[pk="#{service_node['pk']}"]))).each do |frequence_node|
          if frequency = frequency_from(frequence_node, service_node)
            service.add_frequency frequency
          end
        end
        if airport
          airport.add_unit(service.unit) if airport.units.find(service.unit).none?
          airport.add_service(service) if airport.services.find(service).none?
        end
        given service_node.at_css('Espace')&.attr('pk') do |espace_pk|
          find_by(:airspace, meta: espace_pk).each do |airspace|
            airspace.layers.each { _1.add_service(service) }
          end
        end
      end
    end
  end
  # Assign A/A address to all yet radioless airports
  find_by(:airport).each do |airport|
    unless airport.services.find_by(:service, type: :aerodrome_control_tower_service).any? || airport.addresses.any?
      airport.add_address(
        address_from_vac_for(airport) || fallback_address_for(airport)
      )
    end
  end
end