Class: AIPP::LF::AIP::ServicedAirspaces

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

Constant Summary collapse

SOURCE_TYPES =

Map source types to type and optional local type and skip regexp

{
  'FIR' => { type: 'FIR' },
  'UIR' => { type: 'UIR' },
  'UTA' => { type: 'UTA' },
  'CTA' => { type: 'CTA' },
  'LTA' => { type: 'CTA', local_type: 'LTA' },
  'TMA' => { type: 'TMA', skip: /geneve/i },   # Geneva listed FYI only
  'SIV' => { type: 'SECTOR', local_type: 'FIZ/SIV' },   # providing FIS
  'CTR' => { type: 'CTR' },
  'RMZ' => { type: 'RAS', local_type: 'RMZ' },
  'TMZ' => { type: 'RAS', local_type: 'TMZ' },
  'RMZ-TMZ' => { type: 'RAS', local_type: 'RMZ-TMZ' }
}.freeze
FIR_LOCATION_INDICATORS =

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

{
  'BORDEAUX' => 'LFBB',
  'BREST' => 'LFRR',
  'MARSEILLE' => 'LFMM',
  'PARIS' => 'LFFF',
  'REIMS' => 'LFRR'
}.freeze
DELEGATED_RE =
/(?:deleg\.|delegated|delegation)/i.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



32
33
34
35
36
37
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
# File 'lib/aipp/regions/LF/aip/serviced_airspaces.rb', line 32

def parse
  SOURCE_TYPES.each do |source_type, target|
    verbose_info("processing #{source_type}")
    AIPP.cache.espace.css(%Q(Espace[lk^="[LF][#{source_type} "])).each do |espace_node|
      next if espace_node.(:Nom).match? DELEGATED_RE
      next if (re = target[:skip]) && espace_node.(:Nom).match?(re)
      # Build airspaces and layers
      AIPP.cache.partie.css(%Q(Partie:has(Espace[pk="#{espace_node['pk']}"]))).each do |partie_node|
        next if partie_node.(:NomPartie).match? DELEGATED_RE
        add(
          AIXM.airspace(
            source: source(part: 'ENR', position: espace_node.line),
            name: [
              espace_node.(:Nom),
              partie_node.(:NomPartie).remove(/^\.$/).blank_to_nil
            ].compact.join(' '),
            type: target[:type],
            local_type: target[:local_type]
          ).tap do |airspace|
            airspace.meta = espace_node.attr('pk')
            airspace.geometry = geometry_from(partie_node.(:Contour))
            fail("geometry is not closed") unless airspace.geometry.closed?
            AIPP.cache.volume.css(%Q(Volume:has(Partie[pk="#{partie_node['pk']}"]))).each do |volume_node|
              airspace.add_layer(
                layer_from(volume_node).tap do |layer|
                  layer.location_indicator = FIR_LOCATION_INDICATORS.fetch(airspace.name) if airspace.type == :flight_information_region
                end
              )
            end
          end
        )
      end
    end
  end
end