class AIXM::Feature::Airspace

Three-dimensional volume most notably defining flight zones.

Cheat Sheet in Pseudo Code:

airspace = AIXM.airspace(
  source: String or nil
  region: 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.add_layer(AIXM.layer)
airspace.geometry.add_segment(AIXM.point or AIXM.arc or AIXM.border or AIXM.circle)

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")

@see gitlab.com/openflightmaps/ofmx/wikis/Airspace#ase-airspace

Constants

TYPES

Attributes

id[R]

@note When assigning nil, a 4 byte hex derived from {#type}, {#name}

and {#local_type} is written instead.

@return [String] published identifier (e.g. “LFP81”)

local_type[R]

Some regions define additional types. They are usually specified with

@return [String, nil] local type (e.g. “RMZ” or “TMZ”)

name[R]

@return [String, nil] full name (e.g. “LF P 81 CHERBOURG”)

type[R]

@return [Symbol] type of airspace (see {TYPES})

Public Class Methods

new(source: nil, region: nil) click to toggle source
   # File lib/aixm/feature.rb
15 def initialize(source: nil, region: nil)
16   self.source = source
17   self.region = region || AIXM.config.region
18 end
new(source: nil, region: nil, id: nil, type:, local_type: nil, name: nil) click to toggle source
Calls superclass method AIXM::Feature::new
    # File lib/aixm/feature/airspace.rb
109 def initialize(source: nil, region: nil, id: nil, type:, local_type: nil, name: nil)
110   super(source: source, region: region)
111   self.type, self.local_type, self.name = type, local_type, name
112   self.id = id
113   self.geometry = AIXM.geometry
114 end

Public Instance Methods

id=(value) click to toggle source

The id is mandatory, however, you may assign nil which will generate an 8 character digest from type, local_type and name.

    # File lib/aixm/feature/airspace.rb
123 def id=(value)
124   fail(ArgumentError, "invalid id") unless value.nil? || value.is_a?(String)
125   @id = value&.uptrans || [type, local_type, name].to_digest.upcase
126 end
inspect() click to toggle source

@return [String]

    # File lib/aixm/feature/airspace.rb
117 def inspect
118   %Q(#<#{self.class} type=#{type.inspect} name=#{name.inspect}>)
119 end
local_type=(value) click to toggle source
    # File lib/aixm/feature/airspace.rb
132 def local_type=(value)
133   fail(ArgumentError, "invalid short name") unless value.nil? || value.is_a?(String)
134   @local_type = value&.uptrans
135 end
name=(value) click to toggle source
    # File lib/aixm/feature/airspace.rb
137 def name=(value)
138   fail(ArgumentError, "invalid name") unless value.nil? || value.is_a?(String)
139   @name = value&.uptrans
140 end
to_uid(as: :AseUid) click to toggle source

@return [String] UID markup

    # File lib/aixm/feature/airspace.rb
143 def to_uid(as: :AseUid)
144   builder = Builder::XmlMarkup.new(indent: 2)
145   builder.tag!(as, ({ region: (region if AIXM.ofmx?) }.compact)) do |tag|
146     tag.codeType(TYPES.key(type).to_s)
147     tag.codeId(id)
148   end
149 end
to_wrapped_uid(as: :AseUid, with:) click to toggle source

@return [String] UID markup

    # File lib/aixm/feature/airspace.rb
153 def to_wrapped_uid(as: :AseUid, with:)
154   builder = Builder::XmlMarkup.new(indent: 2)
155   builder.tag!(with) do |tag|
156     tag << to_uid(as: as).indent(2)
157   end
158 end
to_xml() click to toggle source

@raise [AIXM::GeometryError] if the geometry is not closed @raise [AIXM::LayerError] if no layers are defined @return [String] AIXM or OFMX markup

    # File lib/aixm/feature/airspace.rb
163 def to_xml
164   fail(LayerError.new("no layers defined", self)) unless layers.any?
165   builder = Builder::XmlMarkup.new(indent: 2)
166   builder.comment! "Airspace: [#{TYPES.key(type)}] #{name || :UNNAMED}"
167   builder.Ase({ source: (source if AIXM.ofmx?) }.compact) do |ase|
168     ase << to_uid.indent(2)
169     ase.txtLocalType(local_type) if local_type && local_type != name
170     ase.txtName(name) if name
171     unless layered?
172       ase << layers.first.to_xml.indent(2)
173     end
174   end
175   builder.Abd do |abd|
176     abd << to_wrapped_uid(with: :AbdUid).indent(2)
177     abd << geometry.to_xml.indent(2)
178   end
179   if layered?
180     layers.each.with_index do |layer, index|
181       layer_airspace = AIXM.airspace(region: region, type: 'CLASS', name: "#{name} LAYER #{index + 1}")
182       builder.Ase do |ase|
183         ase << layer_airspace.to_uid.indent(2)
184         ase.txtName(layer_airspace.name)
185         ase << layers[index].to_xml.indent(2)
186       end
187       builder.Adg do |adg|
188         adg << layer_airspace.to_wrapped_uid(with: :AdgUid).indent(2)
189         adg << to_uid(as: :AseUidSameExtent).indent(2)
190       end
191       layer.services.each do |service|
192         builder.Sae do |sae|
193           sae.SaeUid do |sae_uid|
194             sae_uid << service.to_uid.indent(4)
195             sae_uid << layer_airspace.to_uid.indent(4)
196           end
197         end
198       end
199     end
200   else
201     layers.first.services.each do |service|
202       builder.Sae do |sae|
203         sae.SaeUid do |sae_uid|
204           sae_uid << service.to_uid.indent(4)
205           sae_uid << to_uid.indent(4)
206         end
207       end
208     end
209   end
210   builder.target!
211 end
type=(value) click to toggle source
    # File lib/aixm/feature/airspace.rb
128 def type=(value)
129   @type = TYPES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid type")
130 end

Private Instance Methods

layered?() click to toggle source
    # File lib/aixm/feature/airspace.rb
215 def layered?
216   layers.count > 1
217 end