Module: AIPP::LF::Helpers::ADRadio
Constant Summary collapse
- IGNORED_TYPES =
Service types to be ignored
%w(D-ATIS).freeze
- ADDRESS_TYPES =
Service types to be encoded as addresses
%w(A/A A/G).freeze
- SERVICE_TYPES =
Unknown service types to be encoded as units
{ 'CEV' => { type: :other, remarks: "CEV (centre d'essais en vol / flight test center)" }, 'SRE' => { type: :other, remarks: "SRE (elément radar de surveillance du PAR / surveillance radar element of PAR)" } }.freeze
Instance Method Summary collapse
Instance Method Details
#addresses_from(trs) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aipp/regions/LF/helpers/AD_radio.rb', line 27 def addresses_from(trs) trs.map do |tr| tds = tr.css('td') type = tds[0].text.strip next if IGNORED_TYPES.include? type f, callsign, _, remarks = parts_from(tds).values if ADDRESS_TYPES.include?(type) AIXM.address( source: source(position: tr.line), type: :radio_frequency, address: f.to_s ).tap do |address| address.remarks = ["#{type} - indicatif/callsign #{callsign}", remarks.blank_to_nil].compact.join("\n") end end end.compact end |
#parts_from(tds) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/aipp/regions/LF/helpers/AD_radio.rb', line 18 def parts_from(tds) { f: AIXM.f(tds[2].css('span').first.text.to_f, tds[2].css('span').last.text), callsign: tds[1].text.strip, timetable: tds[3].text.strip, remarks: tds[4].text.strip.sub(/Canal (8.33|25)/i, '') # TEMP: ignore canal spacing warnings } end |
#units_from(trs) ⇒ Object
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 80 81 82 83 84 85 |
# File 'lib/aipp/regions/LF/helpers/AD_radio.rb', line 45 def units_from(trs) trs.each_with_object({}) do |tr, services| tds = tr.css('td') type = tds[0].text.strip next if IGNORED_TYPES.include?(type) || ADDRESS_TYPES.include?(type) f, callsign, , remarks = parts_from(tds).values if SERVICE_TYPES.include? type type = SERVICE_TYPES.dig(type, :type) remarks = [SERVICE_TYPES.dig(type, :remarks), remarks.blank_to_nil].compact.join("\n") end unless services.include? type services[type] = AIXM.service( source: source(position: tr.line), type: type ) end code = $1 if .sub!(/(#{AIXM::H_RE})\b/, '') services[type].add_frequency( AIXM.frequency( transmission_f: f, callsigns: { fr: callsign } ).tap do |frequency| frequency.type = :standard frequency.type = :alternative if remarks.sub!(%r{fréquence supplétive/auxiliary frequency\S*}i, '') frequency. = AIXM.(code: code) if code frequency.remarks = [remarks, .blank_to_nil].compact.join("\n").cleanup.blank_to_nil end ) end.values.map do |service| AIXM.unit( source: service.source, organisation: organisation_lf, # TODO: not yet implemented type: (type = service.guessed_unit_type), name: "#{@id} #{AIXM::Feature::Unit::TYPES.key(type)}", class: :icao # TODO: verify whether all units are ICAO ).tap do |unit| unit.airport = @airport unit.add_service(service) end end end |