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.remarks = String or nil
airport.add_runway(AIXM.runway)
airport.add_helipad(AIXM.helipad)
airport.add_usage_limitation(UsageLimitation::TYPES)

Defined Under Namespace

Classes: UsageLimitation

Constant Summary collapse

ID_PATTERN =
/^([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:, name:, xy:) ⇒ Airport

Returns a new instance of Airport


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

def initialize(source: nil, organisation:, id:, name:, xy:)
  super(source: source)
  self.organisation, self.id, self.name, self.xy = organisation, id, name, xy
  @runways, @helipads, @usage_limitations = [], [], []
end

Instance Attribute Details

#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:


73
74
75
# File 'lib/aixm/feature/airport.rb', line 73

def declination
  @declination
end

#gpsString?

Returns GPS code

Returns:

  • (String, nil)

    GPS code


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

def gps
  @gps
end

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

Returns helipads present at this airport

Returns:


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

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


53
54
55
# File 'lib/aixm/feature/airport.rb', line 53

def id
  @id
end

#nameString

Returns full name

Returns:

  • (String)

    full name


56
57
58
# File 'lib/aixm/feature/airport.rb', line 56

def name
  @name
end

#organisationAIXM::Feature::Organisation

Returns superior organisation

Returns:


42
43
44
# File 'lib/aixm/feature/airport.rb', line 42

def organisation
  @organisation
end

#remarksString?

Returns free text remarks

Returns:

  • (String, nil)

    free text remarks


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

def remarks
  @remarks
end

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

Returns runways present at this airport

Returns:


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

def runways
  @runways
end

#timetableAIXM::Component::Timetable?

Returns operating hours

Returns:


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

def timetable
  @timetable
end

#transition_zAIXM::Z?

Returns transition altitude in :qnh

Returns:

  • (AIXM::Z, nil)

    transition altitude in :qnh


76
77
78
# File 'lib/aixm/feature/airport.rb', line 76

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)


130
131
132
133
134
135
136
137
# File 'lib/aixm/feature/airport.rb', line 130

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

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

Returns usage limitations

Returns:


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

def usage_limitations
  @usage_limitations
end

#xyAIXM::XY

Returns reference point

Returns:


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

def xy
  @xy
end

#zAIXM::Z?

Returns elevation in :qnh

Returns:

  • (AIXM::Z, nil)

    elevation in :qnh


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

def z
  @z
end

Instance Method Details

#add_helipad(helipad) ⇒ self

Add a helipad to the airport.

Parameters:

Returns:

  • (self)

190
191
192
193
194
195
# File 'lib/aixm/feature/airport.rb', line 190

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)

179
180
181
182
183
184
# File 'lib/aixm/feature/airport.rb', line 179

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)

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

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)

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

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

#to_uidString

Returns UID markup

Returns:

  • (String)

    UID markup


233
234
235
236
237
238
# File 'lib/aixm/feature/airport.rb', line 233

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

#to_xmlString

Returns AIXM or OFMX markup

Returns:

  • (String)

    AIXM or OFMX markup


241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/aixm/feature/airport.rb', line 241

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
    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
  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
  builder.target!
end