Class: AIXM::Feature::Airport

Inherits:
AIXM::Feature show all
Includes:
Association, Memoize
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
  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.

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

Constants inherited from AIXM::Feature

REGION_RE

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature

#region, #source

Instance Method Summary collapse

Methods included from Memoize

cache, included, method

Methods included from Association

included

Methods inherited from AIXM::Feature

#==

Constructor Details

#initialize(source: nil, region: nil, organisation:, id: nil, name:, xy:) ⇒ Airport

Returns a new instance of Airport.


145
146
147
148
149
# File 'lib/aixm/feature/airport.rb', line 145

def initialize(source: nil, region: nil, organisation:, id: nil, name:, xy:)
  super(source: source, region: region)
  self.organisation, self.name, self.xy = organisation, name, xy
  self.id = id   # name must already be set
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.

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

Returns:

  • (Float, nil)

    magnetic declination in degrees

See Also:


131
132
133
# File 'lib/aixm/feature/airport.rb', line 131

def declination
  @declination
end

#gpsString?

Returns GPS code.

Returns:

  • (String, nil)

    GPS code


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

def gps
  @gps
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


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

def id
  @id
end

#nameString

Returns full name.

Returns:

  • (String)

    full name


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

def name
  @name
end

#operatorString?

Returns operator of the airport.

Returns:

  • (String, nil)

    operator of the airport


140
141
142
# File 'lib/aixm/feature/airport.rb', line 140

def operator
  @operator
end

#remarksString?

Returns free text remarks.

Returns:

  • (String, nil)

    free text remarks


143
144
145
# File 'lib/aixm/feature/airport.rb', line 143

def remarks
  @remarks
end

#timetableAIXM::Component::Timetable?

Returns operating hours.

Returns:


137
138
139
# File 'lib/aixm/feature/airport.rb', line 137

def timetable
  @timetable
end

#transition_zAIXM::Z?

Returns transition altitude in :qnh.

Returns:

  • (AIXM::Z, nil)

    transition altitude in :qnh


134
135
136
# File 'lib/aixm/feature/airport.rb', line 134

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)


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

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

#xyAIXM::XY

Returns reference point.

Returns:


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

def xy
  @xy
end

#zAIXM::Z?

Returns elevation in :qnh.

Returns:

  • (AIXM::Z, nil)

    elevation in :qnh


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

def z
  @z
end

Instance Method Details

#add_address(address) ⇒ self

Parameters:

Returns:

  • (self)

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

has_many :addresses, as: :addressable

#add_designated_point(designated_point) ⇒ Object

Parameters:


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

has_many :designated_points

#add_fato(fato) ⇒ Object

Parameters:


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

has_many :fatos

#add_helipad(helipad) ⇒ Object

Parameters:


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

has_many :helipads

#add_runway(runway) ⇒ Object

Parameters:


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

has_many :runways

#add_unit(unit) ⇒ Object

Parameters:


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

has_many :units

#add_usage_limitation {|AIXM::Feature::Airport::UsageLimitation| ... } ⇒ self

Yields:

Returns:

  • (self)

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

has_many :usage_limitations, accept: 'AIXM::Feature::Airport::UsageLimitation' do |usage_limitation, type:| end

#addressesArray<AIXM::Feature::Address>

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

Returns:


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

has_many :addresses, as: :addressable

#designated_pointsArray<AIXM::Feature::NavigationalAid::DesignatedPoint>

Returns designated points.

Returns:


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

has_many :designated_points

#fatosArray<AIXM::Component::FATO>

Returns FATOs present at this airport.

Returns:


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

has_many :fatos

#helipadsArray<AIXM::Component::Helipad>

Returns helipads present at this airport.

Returns:


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

has_many :helipads

#inspectString

Returns:

  • (String)

152
153
154
# File 'lib/aixm/feature/airport.rb', line 152

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

#organisationAIXM::Feature::Organisation

Returns superior organisation.

Returns:


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

belongs_to :organisation, as: :member

#runwaysArray<AIXM::Component::Runway>

Returns runways present at this airport.

Returns:


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

has_many :runways

#to_uid(as: :AhpUid) ⇒ String

Returns UID markup.

Returns:

  • (String)

    UID markup


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

def to_uid(as: :AhpUid)
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.tag!(as, ({ region: (region if AIXM.ofmx?) }.compact)) do |tag|
    tag.codeId(id)
  end
end

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

Returns UID markup.

Returns:

  • (String)

    UID markup


240
241
242
243
244
245
# File 'lib/aixm/feature/airport.rb', line 240

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
end

#to_xmlString

Returns AIXM or OFMX markup.

Returns:

  • (String)

    AIXM or OFMX markup


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

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

#unitsArray<AIXM::Feature::Unit>

Returns units.

Returns:


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

has_many :units

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

Returns usage limitations.

Returns:


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

has_many :usage_limitations, accept: 'AIXM::Feature::Airport::UsageLimitation' do |usage_limitation, type:| end