Class: AIXM::Feature::Airspace

Inherits:
AIXM::Feature show all
Defined in:
lib/aixm/feature/airspace.rb

Overview

Three-dimensional volume most notably defining flight zones.

Cheat Sheet in Pseudo Code:

airspace = AIXM.airspace(
  source: String or nil
  id: String or nil   # nil is converted to an 8 character digest
  type: String or Symbol
  local_type: String or nil
  name: String or nil
)
airspace.geometry << AIXM.point or AIXM.arc or AIXM.border or AIXM.circle
airspace.layers << AIXM.layer

The id is mandatory, however, you may omit it when initializing a new airspace or assign nil to an existing airspace which will generate a 8 character digest from type, local_type and name.

Some regions define additional airspace types. In LF (France) for intance, the types RMZ (radio mandatory zone) and TMZ (transponder mandatory zone) exist. Such airspaces are usually specified together with a generic type such as :regulated_airspace:

airspace= AIXM.airspace(type: :regulated_airspace, local_type: "RMZ")

Constant Summary collapse

TYPES =
{
  NAS: :national_airspace_system,
  FIR: :flight_information_region,
  'FIR-P': :part_of_flight_information_region,
  UIR: :upper_flight_information_region,
  'UIR-P': :part_of_upper_flight_information_region,
  CTA: :control_area,
  'CTA-P': :part_of_control_area,
  OCA: :oceanic_control_area,
  'OCA-P': :part_of_oceanic_control_area,
  UTA: :upper_control_area,
  'UTA-P': :part_of_upper_control_area,
  TMA: :terminal_control_area,
  'TMA-P': :part_of_terminal_control_area,
  CTR: :control_zone,
  'CTR-P': :part_of_control_zone,
  CLASS: :airspace_with_class,
  OTA: :oceanic_transition_area,
  SECTOR: :control_sector,
  'SECTOR-C': :temporarily_consolidated_sector,
  TSA: :temporary_segregated_area,
  TRA: :temporary_reserved_area,
  CBA: :cross_border_area,
  RCA: :reduced_coordination_airspace_procedure,
  RAS: :regulated_airspace,
  AWY: :airway,
  P: :prohibited_area,
  R: :restricted_area,
  'R-AMC': :amc_manageable_restricted_area,
  D: :danger_area,
  'D-AMC': :amc_manageable_danger_area,
  'D-OTHER': :dangerous_activities_area,
  ADIZ: :air_defense_identification_zone,
  A: :alert_area,
  W: :warning_area,
  PROTECT: :protected_from_specific_air_traffic,
  AMA: :minimum_altitude_area,
  ASR: :altimeter_setting_region,
  'NO-FIR': :airspace_outside_any_flight_information_region,
  POLITICAL: :political_area,
  PART: :part_of_airspace
}.freeze

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature

#source

Instance Method Summary collapse

Methods inherited from AIXM::Feature

#==

Constructor Details

#initialize(source: nil, id: nil, type:, local_type: nil, name: nil) ⇒ Airspace


99
100
101
102
103
104
105
# File 'lib/aixm/feature/airspace.rb', line 99

def initialize(source: nil, id: nil, type:, local_type: nil, name: nil)
  super(source: source)
  self.type, self.local_type, self.name = type, local_type, name
  self.id = id
  @geometry = AIXM.geometry
  @layers = []
end

Instance Attribute Details

#geometryAIXM::Component::Geometry


94
95
96
# File 'lib/aixm/feature/airspace.rb', line 94

def geometry
  @geometry
end

#idString

Note:

When assigning nil, a 4 byte hex derived from #type, #name and #local_type is written instead.

Returns published identifier (e.g. “LFP81”)


80
81
82
# File 'lib/aixm/feature/airspace.rb', line 80

def id
  @id
end

#layersArray<AIXM::Compoment::Layer>


97
98
99
# File 'lib/aixm/feature/airspace.rb', line 97

def layers
  @layers
end

#local_typeString?

Some regions define additional types. They are usually specified with


88
89
90
# File 'lib/aixm/feature/airspace.rb', line 88

def local_type
  @local_type
end

#nameString?


91
92
93
# File 'lib/aixm/feature/airspace.rb', line 91

def name
  @name
end

#typeSymbol


83
84
85
# File 'lib/aixm/feature/airspace.rb', line 83

def type
  @type
end

Instance Method Details

#inspectString


108
109
110
# File 'lib/aixm/feature/airspace.rb', line 108

def inspect
  %Q(#<#{self.class} type=#{type.inspect} name=#{name.inspect}>)
end

#to_uid(as: :AseUid) ⇒ String


134
135
136
137
138
139
140
# File 'lib/aixm/feature/airspace.rb', line 134

def to_uid(as: :AseUid)
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.tag!(as) do |tag|
    tag.codeType(TYPES.key(type).to_s)
    tag.codeId(id)
  end
end

#to_xmlString

Returns AIXM or OFMX markup

Raises:


145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/aixm/feature/airspace.rb', line 145

def to_xml
  fail(LayerError.new("no layers defined", self)) unless layers.any?
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.comment! "Airspace: [#{TYPES.key(type)}] #{name || :UNNAMED}"
  builder.Ase({ source: (source if AIXM.ofmx?) }.compact) do |ase|
    ase << to_uid.indent(2)
    ase.txtLocalType(local_type) if local_type && local_type != name
    ase.txtName(name) if name
    unless layered?
      ase << layers.first.to_xml.indent(2)
    end
  end
  builder.Abd do |abd|
    abd.AbdUid do |abd_uid|
      abd_uid << to_uid.indent(4)
    end
    abd << geometry.to_xml.indent(2)
  end
  if layered?
    layers.each.with_index do |layer, index|
      layer_airspace = AIXM.airspace(type: 'CLASS', name: "#{name} LAYER #{index + 1}")
      builder.Ase do |ase|
        ase << layer_airspace.to_uid.indent(2)
        ase.txtName(layer_airspace.name)
        ase << layers[index].to_xml.indent(2)
      end
      builder.Adg do |adg|
        adg.AdgUid do |adg_uid|
          adg_uid << layer_airspace.to_uid.indent(4)
        end
        adg << to_uid(as: :AseUidSameExtent).indent(2)
      end
    end
  end
  builder.target!
end