Class: AIPP::LF::ENR21

Inherits:
AIP show all
Includes:
Helpers::Base
Defined in:
lib/aipp/regions/LF/ENR-2.1.rb

Overview

FIR, TMA etc

Constant Summary collapse

NAME_BLACKLIST_RE =

Airspaces to be ignored

/deleg/i.freeze
SOURCE_TYPES =

Map source types to type and optional local type

{
  'FIR' => { type: 'FIR' },
  'UIR' => { type: 'UIR' },
  'UTA' => { type: 'UTA' },
  'CTA' => { type: 'CTA' },
  'LTA' => { type: 'CTA', local_type: 'LTA' },
  'TMA' => { type: 'TMA' },
  'SIV' => { type: 'SECTOR', local_type: 'SIV' }   # providing FIS
}.freeze
LOCATION_INDICATORS =

Map airspace “<type> <name>” to location indicator

{
  'FIR BORDEAUX' => 'LFBB',
  'FIR BREST' => 'LFRR',
  'FIR MARSEILLE' => 'LFMM',
  'FIR PARIS' => 'LFFF',
  'FIR REIMS' => 'LFRR'
}.freeze
SERVICE_FIXES =

Fix incomplete SIV service columns

{
  "IROISE INFO 135.825 / 119.575 (1)" => "APP IROISE\nIROISE INFO 135.825 / 119.575 (1)",
  "APP TOULOUSE\nTOULOUSE INFO" => "APP TOULOUSE\nTOULOUSE INFO 121.250"
}.freeze

Constants included from Helpers::Base

Helpers::Base::ANGLICISE_MAP, Helpers::Base::BORDERS, Helpers::Base::INTERSECTIONS, Helpers::Base::SURFACES

Constants inherited from AIP

AIP::DEPENDS

Instance Attribute Summary

Attributes inherited from AIP

#aip, #fixture

Instance Method Summary collapse

Methods included from Helpers::Base

#anglicise, #d_from, #elevation_from, #geometry_from, #layer_from, #organisation_lf, #prepare, #source, #timetable_from!, #xy_from, #z_from

Methods inherited from AIP

#add, #borders, #cache, #close, #config, #find, #find_by, #initialize, #options, #read

Methods included from Patcher

#attach_patches, #detach_patches, included

Constructor Details

This class inherits a constructor from AIPP::AIP

Instance Method Details

#parseObject


38
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
80
81
82
83
84
85
86
87
88
89
# File 'lib/aipp/regions/LF/ENR-2.1.rb', line 38

def parse
  prepare(html: read).css('tbody').each do |tbody|
    airspace = nil
    tbody.css('tr').to_enum.with_index(1).each do |tr, index|
      if tr.attr(:id).match?(/--TXT_NAME/)
        if airspace
          if airspace.name.match? NAME_BLACKLIST_RE
            verbose_info "Ignoring #{airspace.type} #{airspace.name}" unless airspace.type == :terminal_control_area
          else
            add airspace
          end
        end
        airspace = airspace_from tr.css(:td).first
        verbose_info "Parsing #{airspace.type} #{airspace.name}" unless airspace.type == :terminal_control_area
        next
      end
      begin
        tds = tr.css('td')
        if airspace.type == :terminal_control_area && tds[0].text.blank_to_nil
          if airspace.layers.any?
            if airspace.name.match? NAME_BLACKLIST_RE
              verbose_info "Ignoring #{airspace.type} #{airspace.name}"
            else
              add airspace
            end
          end
          airspace = airspace_from tds[0]
          verbose_info "Parsing #{airspace.type} #{airspace.name}"
        end
        if airspace
          remarks = tds[-1].text
          if tds[0].text.blank_to_nil
            airspace.geometry = geometry_from tds[0].text
            fail("geometry is not closed") unless airspace.geometry.closed?
          end
          layer = layer_from(tds[-3].text)
          layer.class = class_from(tds[1].text) if tds.count == 5
          layer.location_indicator = LOCATION_INDICATORS.fetch("#{airspace.type} #{airspace.name}", nil)
          if airspace.local_type == 'SIV'   # services parsed for SIV only
            layer.add_services services_from(tds[-2], remarks)
          end
          layer.timetable = timetable_from! remarks
          layer.remarks = remarks_from remarks
          airspace.add_layer layer
        end
      rescue => error
        warn("error parsing #{airspace.type} `#{airspace.name}' at ##{index}: #{error.message}", pry: error)
      end
    end
    add airspace if airspace
  end
end