Class: AIPP::LF::AIP::DPRAirspaces

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

Constant Summary collapse

SOURCE_TYPES =

Map source types to type and optional local type

{
  'D' => { type: 'D' },
  'P' => { type: 'P' },
  'R' => { type: 'R' },
  'ZIT' => { type: 'P', local_type: 'ZIT' }
}.freeze
POINT_RADIUS =

Radius to use for zones consisting of one point only

AIXM.d(1, :km).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



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/aipp/regions/LF/aip/d_p_r_airspaces.rb', line 17

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|
# UPSTREAM: Espace[pk=300343] has no Partie/Volume (reported)
next if espace_node['pk'] == '300343'
      partie_node = AIPP.cache.partie.at_css(%Q(Partie:has(Espace[pk="#{espace_node['pk']}"])))
      volume_node = AIPP.cache.volume.at_css(%Q(Volume:has(Partie[pk="#{partie_node['pk']}"])))
      name = "#{AIPP.options.region}-#{source_type}#{espace_node.(:Nom)}".remove(/\s/)
      add(
        AIXM.airspace(
          source: source(part: 'ENR', position: espace_node.line),
          name: "#{name} #{partie_node.(:NomUsuel)}".strip,
          type: target[:type],
          local_type: target[:local_type]
        ).tap do |airspace|
          airspace.geometry = geometry_from(partie_node.(:Contour))
          if airspace.geometry.point?   # convert point to circle
            airspace.geometry = AIXM.geometry(
              AIXM.circle(
                center_xy: airspace.geometry.segments.first.xy,
                radius: POINT_RADIUS
              )
            )
          end
          fail("geometry is not closed") unless airspace.geometry.closed?
          airspace.add_layer layer_from(volume_node)
          airspace.layers.first.timetable = timetable_from(volume_node.(:HorCode))
          airspace.layers.first.remarks = volume_node.(:Activite)
        end
      )
    end
  end
end