Class: AIXM::Component::Layer

Inherits:
Object
  • Object
show all
Defined in:
lib/aixm/component/layer.rb

Overview

Each airspace has one or more layers with optional airspace class and mandatory vertical limits.

Cheat Sheet in Pseudo Code:

layer = AIXM.layer(
  class: String or nil
  location_indicator: String or nil
  vertical_limits: AIXM.vertical_limits
)
layer.activity = String or nil
layer.timetable = AIXM.timetable or nil
layer.selective = true or false (default)
layer.remarks = String or nil

Constant Summary collapse

CLASSES =
(:A..:G).freeze
ACTIVITIES =
{
  ACCIDENT: :accident_investigation,
  ACROBAT: :acrobatics,
  AIRGUN: :aerial_gunnery,
  AIRMODEL: :aeromodelling,
  AIRSHOW: :air_show,
  ANTIHAIL: :anti_hail_rocket,
  ARTILERY: :artillary_firing,
  ASCENT: :probe,
  ATS: :air_traffic_services,
  BALLOON: :balloon,
  BIRD: :bird_hazard,
  'BIRD-MGR': :bird_migration,
  BLAST: :blasting_operation,
  DROP: :dropping,
  DUSTING: :crop_dusting,
  EQUIPMENT: :special_equipment_required,
  'EQUIPMENT-833': :radio_8_33_required,
  'EQUIPMENT-RNAV': :rnav_equipment_required,
  'EQUIPMENT-RSVM': :rsvm_equipment_required,
  EXERCISE: :combat_exercise,
  FAUNA: :sensitive_fauna,
  FIRE: :fire_suppression,
  FIREWORK: :fireworks,
  GAZ: :gaz_field,
  GLIDER: :gliding,
  HANGGLIDER: :hanggliding,
  'HI-LIGHT': :high_intensity_light,
  'HI-RADIO': :high_intensity_radio,
  'IND-CHEM': :chemical_plant,
  'IND-NUCLEAR': :nuclear_activity,
  'IND-OIL': :oil_refinery,
  JETCLIMB: :jet_climb,
  LASER: :laser_light,
  MILOPS: :military_operation,
  MISSILES: :guided_missiles,
  NATURE: :natural_reserve,
  NAVAL: :ship_exercise,
  'NO-NOISE': :noise_abatement,
  OIL: :oil_field,
  PARACHUTE: :parachuting,
  PARAGLIDER: :paragliding,
  POPULATION: :highly_populated,
  PROCEDURE: :special_procedure,
  REFUEL: :refuelling,
  SHOOT: :shooting_from_ground,
  SPACEFLT: :space_flight,
  SPORT: :sport,
  TECHNICAL:  :technical_activity,
  'TFC-AD': :aerodrome_traffic,
  'TFC-HELI': :helicopter_traffic,
  TOWING: :towing_traffic,
  TRG: :training,
  UAV: :drone,
  ULM: :ultra_light_flight,
  VIP: :vip,
  'VIP-PRES': :president,
  'VIP-VICE': :vice_president,
  WATERBLAST: :underwater_explosion,
  WINCH: :glider_winch,
  WORK: :aerial_work,
  OTHER: :other
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class: nil, location_indicator: nil, vertical_limits:) ⇒ Layer


103
104
105
106
107
# File 'lib/aixm/component/layer.rb', line 103

def initialize(class: nil, location_indicator: nil, vertical_limits:)
  self.class = binding.local_variable_get(:class)
  self.location_indicator, self.vertical_limits = location_indicator, vertical_limits
  self.selective = false
end

Instance Attribute Details

#activityString?


95
96
97
# File 'lib/aixm/component/layer.rb', line 95

def activity
  @activity
end

#classSymbol

Note:

Use original_class to query the Ruby object class.

Returns class of layer (see CLASSES)


117
# File 'lib/aixm/component/layer.rb', line 117

alias_method :original_class, :class

#location_indicatorString?


89
90
91
# File 'lib/aixm/component/layer.rb', line 89

def location_indicator
  @location_indicator
end

#remarksString?


101
102
103
# File 'lib/aixm/component/layer.rb', line 101

def remarks
  @remarks
end

#selective=(value) ⇒ Boolean (writeonly)


148
149
150
# File 'lib/aixm/component/layer.rb', line 148

def selective?
  @selective
end

#timetableAIXM::Component::Timetable?


98
99
100
# File 'lib/aixm/component/layer.rb', line 98

def timetable
  @timetable
end

#vertical_limitsAIXM::Component::VerticalLimits


92
93
94
# File 'lib/aixm/component/layer.rb', line 92

def vertical_limits
  @vertical_limits
end

Instance Method Details

#inspectString


110
111
112
# File 'lib/aixm/component/layer.rb', line 110

def inspect
  %Q(#<#{original_class} class=#{@klass.inspect}>)
end

#original_classSymbol

Note:

Use original_class to query the Ruby object class.

Returns class of layer (see CLASSES)


117
# File 'lib/aixm/component/layer.rb', line 117

alias_method :original_class, :class

#selective?Boolean


148
149
150
# File 'lib/aixm/component/layer.rb', line 148

def selective?
  @selective
end

#to_xmlString


162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/aixm/component/layer.rb', line 162

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.codeClass(self.class.to_s) if self.class
  builder.codeLocInd(location_indicator) if location_indicator
  if activity
    builder.codeActivity(ACTIVITIES.key(activity).to_s.then_if(AIXM.aixm?) { |a| { 'AIRMODEL' => 'UAV', 'WINCH' => 'GLIDER' }[a] || a })
  end
  builder << vertical_limits.to_xml
  builder << timetable.to_xml(as: :Att) if timetable
  builder.codeSelAvbl(selective? ? 'Y' : 'N') if AIXM.ofmx?
  builder.txtRmk(remarks) if remarks
  builder.target!
end