Class: AIXM::Feature::Airport
- Inherits:
-
AIXM::Feature
- Object
- AIXM::Feature
- AIXM::Feature::Airport
- 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
Instance Attribute Summary collapse
-
#declination ⇒ Float?
When looking towards the geographic (aka: true) north, a positive declination represents the magnetic north is to the right (aka: east) by this angle.
-
#gps ⇒ String?
GPS code.
-
#id ⇒ String
ICAO indicator, IATA indicator or generated indicator.
-
#name ⇒ String
Full name.
-
#operator ⇒ String?
Operator of the airport.
-
#remarks ⇒ String?
Free text remarks.
-
#timetable ⇒ AIXM::Component::Timetable?
Operating hours.
-
#transition_z ⇒ AIXM::Z?
Transition altitude in
:qnh
. -
#type ⇒ Symbol
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
. -
#xy ⇒ AIXM::XY
Reference point.
-
#z ⇒ AIXM::Z?
Elevation in
:qnh
.
Attributes inherited from AIXM::Feature
Instance Method Summary collapse
- #add_address(address) ⇒ self
- #add_designated_point(designated_point) ⇒ Object
- #add_fato(fato) ⇒ Object
- #add_helipad(helipad) ⇒ Object
- #add_runway(runway) ⇒ Object
- #add_unit(unit) ⇒ Object
- #add_usage_limitation {|AIXM::Feature::Airport::UsageLimitation| ... } ⇒ self
-
#addresses ⇒ Array<AIXM::Feature::Address>
Postal address, url, A/A or A/G frequency etc.
-
#designated_points ⇒ Array<AIXM::Feature::NavigationalAid::DesignatedPoint>
Designated points.
-
#fatos ⇒ Array<AIXM::Component::FATO>
FATOs present at this airport.
-
#helipads ⇒ Array<AIXM::Component::Helipad>
Helipads present at this airport.
-
#initialize(source: nil, region: nil, organisation:, id: nil, name:, xy:) ⇒ Airport
constructor
A new instance of Airport.
- #inspect ⇒ String
-
#organisation ⇒ AIXM::Feature::Organisation
Superior organisation.
-
#runways ⇒ Array<AIXM::Component::Runway>
Runways present at this airport.
-
#to_uid(as: :AhpUid) ⇒ String
UID markup.
-
#to_wrapped_uid(as: :AhpUid, with:) ⇒ String
UID markup.
-
#to_xml ⇒ String
AIXM or OFMX markup.
-
#units ⇒ Array<AIXM::Feature::Unit>
Units.
-
#usage_limitations ⇒ Array<AIXM::Feature::Airport::UsageLimitation>
Usage limitations.
Methods included from Memoize
Methods included from Association
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
#declination ⇒ Float?
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.
131 132 133 |
# File 'lib/aixm/feature/airport.rb', line 131 def declination @declination end |
#gps ⇒ String?
Returns GPS code.
117 118 119 |
# File 'lib/aixm/feature/airport.rb', line 117 def gps @gps end |
#id ⇒ String
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)
108 109 110 |
# File 'lib/aixm/feature/airport.rb', line 108 def id @id end |
#name ⇒ String
Returns full name.
111 112 113 |
# File 'lib/aixm/feature/airport.rb', line 111 def name @name end |
#operator ⇒ String?
Returns operator of the airport.
140 141 142 |
# File 'lib/aixm/feature/airport.rb', line 140 def operator @operator end |
#remarks ⇒ String?
Returns free text remarks.
143 144 145 |
# File 'lib/aixm/feature/airport.rb', line 143 def remarks @remarks end |
#timetable ⇒ AIXM::Component::Timetable?
Returns operating hours.
137 138 139 |
# File 'lib/aixm/feature/airport.rb', line 137 def @timetable end |
#transition_z ⇒ AIXM::Z?
Returns transition altitude in :qnh
.
134 135 136 |
# File 'lib/aixm/feature/airport.rb', line 134 def transition_z @transition_z end |
#type ⇒ Symbol
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
.
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 |
#xy ⇒ AIXM::XY
Returns reference point.
114 115 116 |
# File 'lib/aixm/feature/airport.rb', line 114 def xy @xy end |
#z ⇒ AIXM::Z?
Returns 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
56 |
# File 'lib/aixm/feature/airport.rb', line 56 has_many :addresses, as: :addressable |
#add_designated_point(designated_point) ⇒ Object
87 |
# File 'lib/aixm/feature/airport.rb', line 87 has_many :designated_points |
#add_usage_limitation {|AIXM::Feature::Airport::UsageLimitation| ... } ⇒ self
81 |
# File 'lib/aixm/feature/airport.rb', line 81 has_many :usage_limitations, accept: 'AIXM::Feature::Airport::UsageLimitation' do |usage_limitation, type:| end |
#addresses ⇒ Array<AIXM::Feature::Address>
Returns postal address, url, A/A or A/G frequency etc.
56 |
# File 'lib/aixm/feature/airport.rb', line 56 has_many :addresses, as: :addressable |
#designated_points ⇒ Array<AIXM::Feature::NavigationalAid::DesignatedPoint>
Returns designated points.
87 |
# File 'lib/aixm/feature/airport.rb', line 87 has_many :designated_points |
#fatos ⇒ Array<AIXM::Component::FATO>
Returns FATOs present at this airport.
62 |
# File 'lib/aixm/feature/airport.rb', line 62 has_many :fatos |
#helipads ⇒ Array<AIXM::Component::Helipad>
Returns helipads present at this airport.
68 |
# File 'lib/aixm/feature/airport.rb', line 68 has_many :helipads |
#inspect ⇒ String
152 153 154 |
# File 'lib/aixm/feature/airport.rb', line 152 def inspect %Q(#<#{self.class} id=#{id.inspect}>) end |
#organisation ⇒ AIXM::Feature::Organisation
Returns superior organisation.
97 |
# File 'lib/aixm/feature/airport.rb', line 97 belongs_to :organisation, as: :member |
#runways ⇒ Array<AIXM::Component::Runway>
Returns runways present at this airport.
74 |
# File 'lib/aixm/feature/airport.rb', line 74 has_many :runways |
#to_uid(as: :AhpUid) ⇒ String
Returns 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.
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_xml ⇒ String
Returns 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 << .to_xml(as: :Aht).indent(2) if 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 |
#units ⇒ Array<AIXM::Feature::Unit>
Returns units.
93 |
# File 'lib/aixm/feature/airport.rb', line 93 has_many :units |
#usage_limitations ⇒ Array<AIXM::Feature::Airport::UsageLimitation>
Returns usage limitations.
81 |
# File 'lib/aixm/feature/airport.rb', line 81 has_many :usage_limitations, accept: 'AIXM::Feature::Airport::UsageLimitation' do |usage_limitation, type:| end |