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

Returns a new instance of Airport


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

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)

Returns postal address, url, A/A or A/G frequency etc

Returns:


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

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.

Returns:

  • (Float, nil)

    magnetic declination in degrees

See Also:


79
80
81
# File 'lib/aixm/feature/airport.rb', line 79

def declination
  @declination
end

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

Returns FATOs present at this airport

Returns:


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

def fatos
  @fatos
end

#gpsString?

Returns GPS code

Returns:

  • (String, nil)

    GPS code


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

def gps
  @gps
end

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

Returns helipads present at this airport

Returns:


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

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)

Returns:

  • (String)

    airport indicator


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

def id
  @id
end

#nameString

Returns full name

Returns:

  • (String)

    full name


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

def name
  @name
end

#operatorString?

Returns operator of the airport

Returns:

  • (String, nil)

    operator of the airport


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

def operator
  @operator
end

#organisationAIXM::Feature::Organisation

Returns superior organisation

Returns:


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

def organisation
  @organisation
end

#remarksString?

Returns free text remarks

Returns:

  • (String, nil)

    free text remarks


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

def remarks
  @remarks
end

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

Returns runways present at this airport

Returns:


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

def runways
  @runways
end

#timetableAIXM::Component::Timetable?

Returns operating hours

Returns:


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

def timetable
  @timetable
end

#transition_zAIXM::Z?

Returns transition altitude in :qnh

Returns:

  • (AIXM::Z, nil)

    transition altitude in :qnh


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

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.

Returns:

  • (Symbol)

    type of airport (see TYPES)


149
150
151
152
153
154
155
156
# File 'lib/aixm/feature/airport.rb', line 149

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>

Returns usage limitations

Returns:


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

def usage_limitations
  @usage_limitations
end

#xyAIXM::XY

Returns reference point

Returns:


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

def xy
  @xy
end

#zAIXM::Z?

Returns elevation in :qnh

Returns:

  • (AIXM::Z, nil)

    elevation in :qnh


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.

Returns:

  • (self)

271
272
273
274
275
276
# File 'lib/aixm/feature/airport.rb', line 271

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.

Parameters:

Returns:

  • (self)

214
215
216
217
218
219
# File 'lib/aixm/feature/airport.rb', line 214

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.

Parameters:

Returns:

  • (self)

225
226
227
228
229
230
# File 'lib/aixm/feature/airport.rb', line 225

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.

Parameters:

Returns:

  • (self)

203
204
205
206
207
208
# File 'lib/aixm/feature/airport.rb', line 203

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:

Returns:

  • (self)

260
261
262
263
264
265
# File 'lib/aixm/feature/airport.rb', line 260

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

#inspectString

Returns:

  • (String)

116
117
118
# File 'lib/aixm/feature/airport.rb', line 116

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

#to_uid(as: :AhpUid) ⇒ String

Returns UID markup

Returns:

  • (String)

    UID markup


279
280
281
282
283
284
# File 'lib/aixm/feature/airport.rb', line 279

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

#to_xmlString

Returns AIXM or OFMX markup

Returns:

  • (String)

    AIXM or OFMX markup


287
288
289
290
291
292
293
294
295
296
297
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
# File 'lib/aixm/feature/airport.rb', line 287

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.AhuUid do |ahu_uid|
        ahu_uid << to_uid.indent(4)
      end
      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