Class: AIPP::LF::AIP::Helipads

Inherits:
AIP::Parser show all
Includes:
Helpers::Base, Helpers::Surface, Helpers::UsageLimitation
Defined in:
lib/aipp/regions/LF/aip/helipads.rb

Constant Summary collapse

HOSTILITIES =
{
  'hostile habitée' => 'Zone hostile habitée / hostile populated area',
  'hostile non habitée' => 'Zone hostile non habitée / hostile unpopulated area',
  'non hostile' => 'Zone non hostile / non-hostile area'
}.freeze
ELEVATED =
{
  true => 'En terrasse / on deck',
  false => 'En surface / on ground'
}.freeze

Constants included from Helpers::Surface

Helpers::Surface::SURFACES

Constants included from Helpers::UsageLimitation

Helpers::UsageLimitation::LIMITATION_TYPES

Constants included from Helpers::Base

Helpers::Base::VERSION

Instance Attribute Summary

Attributes inherited from Parser

#aixm

Instance Method Summary collapse

Methods included from Helpers::Surface

#surface_from

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



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
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
90
91
92
93
# File 'lib/aipp/regions/LF/aip/helipads.rb', line 21

def parse
  AIPP.cache.helistation.css(%Q(Helistation[lk^="[LF]"])).each do |helistation_node|
    # Build airport if necessary
    next unless limitation_type = LIMITATION_TYPES.fetch(helistation_node.(:Statut))
    name = helistation_node.(:Nom)
    airport = find_by(:airport, name: name).first || add(
      AIXM.airport(
        source: source(part: 'AD', position: helistation_node.line),
        organisation: organisation_lf,
        id: AIPP.options.region,
        name: name,
        xy: xy_from(helistation_node.(:Geometrie))
      ).tap do |airport|
        airport.z = AIXM.z(helistation_node.(:AltitudeFt).to_i, :qnh)
        airport.add_usage_limitation(type: limitation_type.fetch(:limitation)) do |limitation|
          limitation.remarks = limitation_type[:remarks]
          [:private].each do |purpose|   # TODO: check and simplify
            limitation.add_condition do |condition|
              condition.realm = limitation_type.fetch(:realm)
              condition.origin = :any
              condition.rule = case
                when helistation_node.(:Ifr?) then :ifr_and_vfr
                else :vfr
              end
              condition.purpose = purpose
            end
          end
        end
      end
    )
# TODO: link to VAC once supported downstream
#       # Link to VAC
#       if helistation_node.(:Atlas?)
#         vac = "VAC-#{airport.id}" if airport.id.match?(/^LF[A-Z]{2}$/)
#         vac ||= "VACH-H#{airport.name[0, 3].upcase}"
#         airport.remarks = [
#           airport.remarks.to_s,
#           link_to('VAC-HP', origin_for(vac).file)
#         ].join("\n")
#       end
    # Add helipad and FATO
    airport.add_helipad(
      AIXM.helipad(
        name: 'TLOF',
        xy: xy_from(helistation_node.(:Geometrie))
      ).tap do |helipad|
        helipad.z = AIXM.z(helistation_node.(:AltitudeFt).to_i, :qnh)
        helipad.dimensions = dimensions_from(helistation_node.(:DimTlof))
      end.tap do |helipad|
        airport.add_helipad(helipad)
        helipad.performance_class = performance_class_from(helistation_node.(:ClassePerf))
        helipad.surface = surface_from(helistation_node)
        helipad.marking = helistation_node.(:Balisage) unless helistation_node.(:Balisage)&.match?(/^nil$/i)
        helipad.add_lighting(AIXM.lighting(position: :other)) if helistation_node.(:Nuit?) || helistation_node.(:Balisage)&.match?(/feu/i)
        helipad.remarks = {
          'position/positioning' => [
            (HOSTILITIES.fetch(helistation_node.(:ZoneHabitee)) if helistation_node.(:ZoneHabitee)),
            (ELEVATED.fetch(helistation_node.(:EnTerrasse?)) if helistation_node.(:EnTerrasse)),
          ].compact.join("\n"),
          'hauteur/height' => given(helistation_node.(:HauteurFt)) { "#{_1} ft" },
          'exploitant/operator' => helistation_node.(:Exploitant)
        }.to_remarks
        if fato_dimensions = dimensions_from(helistation_node.(:DimFato))
          AIXM.fato(name: 'FATO').tap do |fato|
            fato.dimensions = fato_dimensions
            airport.add_fato(fato)
            helipad.fato = fato
          end
        end
      end
    )
  end
end