Class: AIXM::Feature::Airport

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

Overview

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
  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.

Defined Under Namespace

Classes: UsageLimitation

Constant Summary collapse

ID_RE =
/^([A-Z]{3,4}|[A-Z]{2}[A-Z\d]{4,})$/.freeze
TYPES =
{
  AD: :aerodrome,
  HP: :heliport,
  AH: :aerodrome_and_heliport,
  LS: :landing_site
}.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, organisation:, id: nil, name:, xy:) ⇒ Airport


111
112
113
114
115
116
# File 'lib/aixm/feature/airport.rb', line 111

def initialize(source: nil, organisation:, id: nil, name:, xy:)
  super(source: source)
  self.organisation, self.name, self.xy = organisation, name, xy
  self.id = id   # name must already be set
  @runways, @fatos, @helipads, @usage_limitations, @addresses = [], [], [], [], []
end

Instance Attribute Details

#addressesArray<AIXM::Feature::Address> (readonly)


109
110
111
# File 'lib/aixm/feature/airport.rb', line 109

def addresses
  @addresses
end

#declinationFloat?

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.


82
83
84
# File 'lib/aixm/feature/airport.rb', line 82

def declination
  @declination
end

#fatosArray<AIXM::Component::FATO> (readonly)


100
101
102
# File 'lib/aixm/feature/airport.rb', line 100

def fatos
  @fatos
end

#gpsString?


68
69
70
# File 'lib/aixm/feature/airport.rb', line 68

def gps
  @gps
end

#helipadsArray<AIXM::Component::Helipad> (readonly)


103
104
105
# File 'lib/aixm/feature/airport.rb', line 103

def helipads
  @helipads
end

#idString

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)


59
60
61
# File 'lib/aixm/feature/airport.rb', line 59

def id
  @id
end

#nameString


62
63
64
# File 'lib/aixm/feature/airport.rb', line 62

def name
  @name
end

#operatorString?


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

def operator
  @operator
end

#organisationAIXM::Feature::Organisation


48
49
50
# File 'lib/aixm/feature/airport.rb', line 48

def organisation
  @organisation
end

#remarksString?


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

def remarks
  @remarks
end

#runwaysArray<AIXM::Component::Runway> (readonly)


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

def runways
  @runways
end

#timetableAIXM::Component::Timetable?


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

def timetable
  @timetable
end

#transition_zAIXM::Z?


85
86
87
# File 'lib/aixm/feature/airport.rb', line 85

def transition_z
  @transition_z
end

#typeSymbol

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.


152
153
154
155
156
157
158
159
# File 'lib/aixm/feature/airport.rb', line 152

def type
  @type = case
    when @type then @type
    when runways.any? && (helipads.any? || fatos.any?) then :aerodrome_and_heliport
    when runways.any? then :aerodrome
    when helipads.any? || fatos.any? then :heliport
  end
end

#usage_limitationsArray<AIXM::Feature::Airport::UsageLimitation>


106
107
108
# File 'lib/aixm/feature/airport.rb', line 106

def usage_limitations
  @usage_limitations
end

#xyAIXM::XY


65
66
67
# File 'lib/aixm/feature/airport.rb', line 65

def xy
  @xy
end

#zAIXM::Z?


71
72
73
# File 'lib/aixm/feature/airport.rb', line 71

def z
  @z
end

Instance Method Details

#add_address(address) ⇒ self

Add an address (postal address, url, A/A or A/G frequency etc) to the airport.


274
275
276
277
278
279
# File 'lib/aixm/feature/airport.rb', line 274

def add_address(address)
  fail(ArgumentError, "invalid address") unless address.is_a? AIXM::Feature::Address
  address.send(:addressable=, self)
  @addresses << address
  self
end

#add_fato(fato) ⇒ self

Add a FATO to the airport.


217
218
219
220
221
222
# File 'lib/aixm/feature/airport.rb', line 217

def add_fato(fato)
  fail(ArgumentError, "invalid FATO") unless fato.is_a? AIXM::Component::FATO
  fato.send(:airport=, self)
  @fatos << fato
  self
end

#add_helipad(helipad) ⇒ self

Add a helipad to the airport.


228
229
230
231
232
233
# File 'lib/aixm/feature/airport.rb', line 228

def add_helipad(helipad)
  fail(ArgumentError, "invalid helipad") unless helipad.is_a? AIXM::Component::Helipad
  helipad.send(:airport=, self)
  @helipads << helipad
  self
end

#add_runway(runway) ⇒ self

Add a runway to the airport.


206
207
208
209
210
211
# File 'lib/aixm/feature/airport.rb', line 206

def add_runway(runway)
  fail(ArgumentError, "invalid runway") unless runway.is_a? AIXM::Component::Runway
  runway.send(:airport=, self)
  @runways << runway
  self
end

#add_usage_limitation(type) {|usage_limitation| ... } ⇒ self

Add an airport usage limitation.

See UsageLimitation::TYPES for recognized limitations and UsageLimitation#add_condition for recognized conditions.

Multiple conditions are joined with an implicit or whereas the specifics of a condition (aircraft, rule etc) are joined with an implicit and.

Examples:

Limitation applying to any traffic

airport.add_usage_limitation(:permitted)

Limitation applying to specific traffic

airport.add_usage_limitation(:reservation_required) do |reservation_required|
  reservation_required.add_condition do |condition|
    condition.aircraft = :glider
  end
  reservation_required.add_condition do |condition|
    condition.rule = :ifr
    condition.origin = :international
  end
  reservation_required.timetable = AIXM::H24
  reservation_required.remarks = "Reservation 24 HRS prior to arrival"
end

Yield Parameters:


263
264
265
266
267
268
# File 'lib/aixm/feature/airport.rb', line 263

def add_usage_limitation(type)
  usage_limitation = UsageLimitation.new(type: type)
  yield(usage_limitation) if block_given?
  @usage_limitations << usage_limitation
  self
end

#inspectString


119
120
121
# File 'lib/aixm/feature/airport.rb', line 119

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

#to_uid(as: :AhpUid) ⇒ String


282
283
284
285
286
287
# File 'lib/aixm/feature/airport.rb', line 282

def to_uid(as: :AhpUid)
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.tag!(as) do |tag|
    tag.codeId(id)
  end.insert_payload_hash(region: AIXM.config.mid_region)
end

#to_wrapped_uid(as: :AhpUid, with:) ⇒ String


290
291
292
293
294
295
# File 'lib/aixm/feature/airport.rb', line 290

def to_wrapped_uid(as: :AhpUid, with:)
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.tag!(with) do |tag|
    tag << to_uid(as: as).indent(2)
  end.insert_payload_hash(region: AIXM.config.mid_region)
end

#to_xmlString


298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/aixm/feature/airport.rb', line 298

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.comment! "Airport: #{id} #{name}"
  builder.Ahp({ source: (source if AIXM.ofmx?) }.compact) do |ahp|
    ahp << to_uid.indent(2)
    ahp << organisation.to_uid.indent(2)
    ahp.txtName(name)
    ahp.codeIcao(id) if id.length == 4
    ahp.codeIata(id) if id.length == 3
    ahp.codeGps(gps) if AIXM.ofmx? && gps
    ahp.codeType(TYPES.key(type).to_s) if type
    ahp.geoLat(xy.lat(AIXM.schema))
    ahp.geoLong(xy.long(AIXM.schema))
    ahp.codeDatum('WGE')
    if z
      ahp.valElev(z.alt)
      ahp.uomDistVer(z.unit.upcase.to_s)
    end
    ahp.valMagVar(declination) if declination
    ahp.txtNameAdmin(operator) if operator
    if transition_z
      ahp.valTransitionAlt(transition_z.alt)
      ahp.uomTransitionAlt(transition_z.unit.upcase.to_s)
    end
    ahp << timetable.to_xml(as: :Aht).indent(2) if timetable
    ahp.txtRmk(remarks) if remarks
  end
  runways.each do |runway|
    builder << runway.to_xml
  end
  fatos.each do |fato|
    builder << fato.to_xml
  end
  helipads.each do |helipad|
    builder << helipad.to_xml
  end
  if usage_limitations.any?
    builder.Ahu do |ahu|
      ahu << to_wrapped_uid(with: :AhuUid).indent(2)
      usage_limitations.each do |usage_limitation|
        ahu << usage_limitation.to_xml.indent(2)
      end
    end
  end
  addresses.each.with_object({}) do |address, sequences|
    sequences[address.type] = (sequences[address.type] || 0) + 1
    builder << address.to_xml(as: :Aha, sequence: sequences[address.type])
  end
  builder.target!
end