Class: AIPP::LF::ENR41

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

Overview

ENR Navaids

Constant Summary

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::NavigationalAid

#navigational_aid_from

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


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aipp/regions/LF/ENR-4.1.rb', line 10

def parse
  prepare(html: read).css('tbody').each do |tbody|
    tbody.css('tr').to_enum.with_index(1).each do |tr, index|
      tds = tr.css('td')
      navigational_aid = navigational_aid_from(
        {
          name: tds[0],
          type: tds[1],
          id: tds[2],
          f: tds[3],
          schedule: tds[4],
          xy: tds[5],
          z: tds[6]
        },
        source: source(position: tr.line),
        sections: {
          range: tds[5].css('span[id*="PORTEE"], span[id*="COUVERTURE"]'),
          situation: tds[7],
          observations: tds[9]
        }
      )
      if navigational_aid && aixm.features.find_by(navigational_aid.class, id: navigational_aid.id, xy: navigational_aid.xy).none?
        add navigational_aid
      end
    rescue => error
      warn("error parsing navigational aid at ##{index}: #{error.message}", pry: error)
    end
  end
end