class AIXM::Feature::Airport

Defined area on land or water to be used for the arrival, departure and surface movement of aircraft.

Cheat Sheet in Pseudo Code:

airport = AIXM.airport(
  source: String or nil
  region: String or nil
  organisation: AIXM.organisation
  id: String
  name: String
  xy: AIXM.xy
)
airport.gps = String or nil
airport.type = TYPES
airport.z = AIXM.z or nil
airport.declination = Float or nil
airport.transition_z = AIXM.z or nil
airport.timetable = AIXM.timetable or nil
airport.operator = String or nil
airport.remarks = String or nil
airport.add_runway(AIXM.runway)
airport.add_fato(AIXM.fato)
airport.add_helipad(AIXM.helipad)
airport.add_usage_limitation(UsageLimitation::TYPES)
airport.add_address(AIXM.address)

For airports without an id, you may assign the two character region (e.g. “LF”) which will be combined with an 8 character digest of name.

@see gitlab.com/openflightmaps/ofmx/wikis/Airport#ahp-airport

Constants

ID_RE
TYPES

Attributes

declination[R]

When looking towards the geographic (aka: true) north, a positive declination represents the magnetic north is to the right (aka: east) by this angle.

To convert a magnetic bearing to the corresponding geographic (aka: true) bearing, the declination has to be added.

@see en.wikipedia.org/wiki/Magnetic_declination @return [Float, nil] magnetic declination in degrees

gps[R]

@return [String, nil] GPS code

id[R]

ICAO indicator, IATA indicator or generated indicator

  • four letter ICAO indicator (e.g. “LFMV”)

  • three letter IATA indicator (e.g. “AVN”)

  • two letter ICAO country code + four digit number (e.g. “LF1234”)

  • two letter ICAO country code + at least four letters/digits (e.g. “LFFOOBAR123” or “LF” + GPS code)

@return [String] airport indicator

name[R]

@return [String] full name

operator[R]

@return [String, nil] operator of the airport

remarks[R]

@return [String, nil] free text remarks

timetable[R]

@return [AIXM::Component::Timetable, nil] operating hours

transition_z[R]

@return [AIXM::Z, nil] transition altitude in :qnh

xy[R]

@return [AIXM::XY] reference point

z[R]

@return [AIXM::Z, nil] elevation in :qnh

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, organisation:, id: nil, name:, xy:) click to toggle source
Calls superclass method AIXM::Feature::new
    # File lib/aixm/feature/airport.rb
145 def initialize(source: nil, region: nil, organisation:, id: nil, name:, xy:)
146   super(source: source, region: region)
147   self.organisation, self.name, self.xy = organisation, name, xy
148   self.id = id   # name must already be set
149 end

Public Instance Methods

declination=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
205 def declination=(value)
206   return @declination = value if value.nil?
207   fail(ArgumentError, "invalid declination") unless value.is_a?(Numeric) && (-180..180).include?(value)
208   @declination = value.to_f + 0   # adding zero prevents -0.0
209 end
gps=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
169 def gps=(value)
170   fail(ArgumentError, "invalid gps") unless value.nil? || value.is_a?(String)
171   @gps = value&.upcase
172 end
id=(value) click to toggle source

For airports without an id, you may assign the two character region (e.g. “LF”) which will be combined with an 8 character digest of name.

    # File lib/aixm/feature/airport.rb
158 def id=(value)
159   value = [value, [name].to_digest].join.upcase if value&.upcase&.match? AIXM::Feature::REGION_RE
160   fail(ArgumentError, "invalid id") unless value&.upcase&.match? ID_RE
161   @id = value.upcase
162 end
inspect() click to toggle source

@return [String]

    # File lib/aixm/feature/airport.rb
152 def inspect
153   %Q(#<#{self.class} id=#{id.inspect}>)
154 end
name=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
164 def name=(value)
165   fail(ArgumentError, "invalid name") unless value.is_a? String
166   @name = value.uptrans
167 end
operator=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
221 def operator=(value)
222   fail(ArgumentError, "invalid name") unless value.nil? || value.is_a?(String)
223   @operator = value&.uptrans
224 end
remarks=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
226 def remarks=(value)
227   @remarks = value&.to_s
228 end
timetable=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
216 def timetable=(value)
217   fail(ArgumentError, "invalid timetable") unless value.nil? || value.is_a?(AIXM::Component::Timetable)
218   @timetable = value
219 end
to_uid(as: :AhpUid) click to toggle source

@return [String] UID markup

    # File lib/aixm/feature/airport.rb
231 def to_uid(as: :AhpUid)
232   builder = Builder::XmlMarkup.new(indent: 2)
233   builder.tag!(as, ({ region: (region if AIXM.ofmx?) }.compact)) do |tag|
234     tag.codeId(id)
235   end
236 end
to_wrapped_uid(as: :AhpUid, with:) click to toggle source

@return [String] UID markup

    # File lib/aixm/feature/airport.rb
240 def to_wrapped_uid(as: :AhpUid, with:)
241   builder = Builder::XmlMarkup.new(indent: 2)
242   builder.tag!(with) do |tag|
243     tag << to_uid(as: as).indent(2)
244   end
245 end
to_xml() click to toggle source

@return [String] AIXM or OFMX markup

    # File lib/aixm/feature/airport.rb
248 def to_xml
249   builder = Builder::XmlMarkup.new(indent: 2)
250   builder.comment! "Airport: #{id} #{name}"
251   builder.Ahp({ source: (source if AIXM.ofmx?) }.compact) do |ahp|
252     ahp << to_uid.indent(2)
253     ahp << organisation.to_uid.indent(2)
254     ahp.txtName(name)
255     ahp.codeIcao(id) if id.length == 4
256     ahp.codeIata(id) if id.length == 3
257     ahp.codeGps(gps) if AIXM.ofmx? && gps
258     ahp.codeType(TYPES.key(type).to_s) if type
259     ahp.geoLat(xy.lat(AIXM.schema))
260     ahp.geoLong(xy.long(AIXM.schema))
261     ahp.codeDatum('WGE')
262     if z
263       ahp.valElev(z.alt)
264       ahp.uomDistVer(z.unit.upcase.to_s)
265     end
266     ahp.valMagVar(declination) if declination
267     ahp.txtNameAdmin(operator) if operator
268     if transition_z
269       ahp.valTransitionAlt(transition_z.alt)
270       ahp.uomTransitionAlt(transition_z.unit.upcase.to_s)
271     end
272     ahp << timetable.to_xml(as: :Aht).indent(2) if timetable
273     ahp.txtRmk(remarks) if remarks
274   end
275   runways.each do |runway|
276     builder << runway.to_xml
277   end
278   fatos.each do |fato|
279     builder << fato.to_xml
280   end
281   helipads.each do |helipad|
282     builder << helipad.to_xml
283   end
284   if usage_limitations.any?
285     builder.Ahu do |ahu|
286       ahu << to_wrapped_uid(with: :AhuUid).indent(2)
287       usage_limitations.each do |usage_limitation|
288         ahu << usage_limitation.to_xml.indent(2)
289       end
290     end
291   end
292   addresses.each.with_object({}) do |address, sequences|
293     sequences[address.type] = (sequences[address.type] || 0) + 1
294     builder << address.to_xml(as: :Aha, sequence: sequences[address.type])
295   end
296   builder.target!
297 end
transition_z=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
211 def transition_z=(value)
212   fail(ArgumentError, "invalid transition_z") unless value.nil? || (value.is_a?(AIXM::Z) && value.qnh?)
213   @transition_z = value
214 end
type() click to toggle source

The type is usually derived from the presence of runways and helipads, however, this may be overridden by setting an alternative value, most notably :landing_site.

@!attribute type @return [Symbol] type of airport (see {TYPES})

    # File lib/aixm/feature/airport.rb
180 def type
181   @type = case
182     when @type then @type
183     when runways.any? && (helipads.any? || fatos.any?) then :aerodrome_and_heliport
184     when runways.any? then :aerodrome
185     when helipads.any? || fatos.any? then :heliport
186   end
187 end
type=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
189 def type=(value)
190   resolved_value = TYPES.lookup(value&.to_s&.to_sym, nil)
191   fail(ArgumentError, "invalid type") unless resolved_value == :landing_site
192   @type = resolved_value
193 end
xy=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
195 def xy=(value)
196   fail(ArgumentError, "invalid xy") unless value.is_a? AIXM::XY
197   @xy = value
198 end
z=(value) click to toggle source
    # File lib/aixm/feature/airport.rb
200 def z=(value)
201   fail(ArgumentError, "invalid z") unless value.nil? || (value.is_a?(AIXM::Z) && value.qnh?)
202   @z = value
203 end