Class: AIPP::LF::ENR54

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

Overview

Obstacles

Constant Summary collapse

NAME_BLACKLIST =

Obstacles to be ignored

%w(51076 52055 59000 72039).freeze
TYPES =

Map type descriptions to AIXM types and remarks

{
  'Antenne' => [:antenna],
  'Bâtiment' => [:building],
  'Câble' => [:other, 'Cable / Câble'],
  'Centrale thermique' => [:building, 'Thermal power plant / Centrale thermique'],
  "Château d'eau" => [:tower, "Water tower / Château d'eau"],
  'Cheminée' => [:chimney],
  'Derrick' => [:tower, 'Derrick'],
  'Eglise' => [:tower, 'Church / Eglise'],
  'Eolienne(s)' => [:wind_turbine],
  'Grue' => [:tower, 'Crane / Grue'],
  'Mât' => [:mast],
  'Phare marin' => [:tower, 'Lighthouse / Phare marin'],
  'Pile de pont' => [:other, 'Bridge piers / Pile de pont'],
  'Portique' => [:building, 'Arch / Portique'],
  'Pylône' => [:mast, 'Pylon / Pylône'],
  'Silo' => [:tower, 'Silo'],
  'Terril' => [:other, 'Spoil heap / Teril'],
  'Torchère' => [:chimney, 'Flare / Torchère'],
  'Tour' => [:tower],
  'Treillis métallique' => [:other, 'Metallic grid / Treillis métallique']
}.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


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
# File 'lib/aipp/regions/LF/ENR-5.4.rb', line 36

def parse
  tbody = prepare(html: read).css('tbody').last
  tbody.css('tr').to_enum.with_index(1).each do |tr, index|
    tds = tr.css('td')
    name = tds[0].text.cleanup
    next if NAME_BLACKLIST.include? name
    elevation, height = tds[4].text.cleanup.split(/[()]/).map { _1.cleanup.remove("\n") }
    type, type_remarks = TYPES.fetch(tds[2].text.cleanup)
    count = tds[3].text.cleanup.to_i
    visibility = tds[5].text.cleanup
    obstacle = AIXM.obstacle(
      source: source(position: tr.line),
      name: name,
      type: type,
      xy: xy_from(tds[1].text),
      z: z_from(elevation + 'AMSL')
    ).tap do |obstacle|
      obstacle.height = d_from(height)
      obstacle.marking = visibility.match?(/jour/i)
      obstacle.lighting = visibility.match?(/nuit/i)
      obstacle.remarks = remarks_from(type_remarks, (count if count > 1), tds[6].text)
    end
    if count > 1
      obstacle_group = AIXM.obstacle_group(
        source: obstacle.source,
        name: obstacle.name
      ).tap do |obstacle_group|
        obstacle_group.remarks = "#{count} obstacles"
      end
      obstacle_group.add_obstacle obstacle
      add obstacle_group
    else
      add obstacle
    end
  rescue => error
    warn("error parsing obstacle at ##{index}: #{error.message}", pry: error)
  end
end