lib/aixm/component/helipad.rb in aixm-0.3.5 vs lib/aixm/component/helipad.rb in aixm-0.3.6
- old
+ new
@@ -1,26 +1,37 @@
using AIXM::Refinements
module AIXM
class Component
- # Helipads are TLOF (touch-down and lift-off areas) e.g. for helicopters.
+ # Helipads are TLOF (touch-down and lift-off areas) for vertical take-off
+ # aircraft such as helicopters.
#
# ===Cheat Sheet in Pseudo Code:
# helipad = AIXM.helipad(
# name: String
+ # xy = AIXM.xy
# )
- # helipad.xy = AIXM.xy
# helipad.z = AIXM.z or nil
# helipad.length = AIXM.d or nil # must use same unit as width
# helipad.width = AIXM.d or nil # must use same unit as length
# helipad.surface = AIXM.surface
+ # helipad.marking = String or nil
+ # helipad.fato = AIXM.fato or nil
+ # helipad.helicopter_class = HELICOPTER_CLASSES or nil
# helipad.status = STATUSES or nil
# helipad.remarks = String or nil
#
# @see https://github.com/openflightmaps/ofmx/wiki/Airport#tla-helipad-tlof
class Helipad
+ HELICOPTER_CLASSES = {
+ '1': :'1',
+ '2': :'2',
+ '3': :'3',
+ OTHER: :other # specify in remarks
+ }.freeze
+
STATUSES = {
CLSD: :closed,
WIP: :work_in_progress, # e.g. construction work
PARKED: :parked_aircraft, # parked or disabled aircraft on helipad
FAILAID: :visual_aids_failure, # failure or irregular operation of visual aids
@@ -47,19 +58,32 @@
attr_reader :width
# @return [AIXM::Component::Surface] surface of the helipad
attr_reader :surface
+ # @return [String, nil] markings
+ attr_reader :marking
+
+ # @return [AIXM::Component::FATO, nil] FATO the helipad is situated on
+ attr_reader :fato
+
+ # @return [Integer, Symbol, nil] suitable helicopter class
+ attr_reader :helicopter_class
+
# @return [Symbol, nil] status of the helipad (see {STATUSES}) or +nil+ for normal operation
attr_reader :status
# @return [String, nil] free text remarks
attr_reader :remarks
- def initialize(name:)
- self.name = name
+ # @return [Array<AIXM::Component::Lighting>] installed lighting systems
+ attr_reader :lightings
+
+ def initialize(name:, xy:)
+ self.name, self.xy = name, xy
@surface = AIXM.surface
+ @lightings = []
end
# @return [String]
def inspect
%Q(#<#{self.class} airport=#{airport&.id.inspect} name=#{name.inspect}>)
@@ -100,18 +124,42 @@
fail(ArgumentError, "invalid width unit") if length && length.unit != value.unit
@width = value
end
end
+ def marking=(value)
+ @marking = value&.to_s
+ end
+
+ def fato=(value)
+ fail(ArgumentError, "invalid FATO") unless value.nil? || value.is_a?(AIXM::Component::FATO)
+ @fato = value
+ end
+
+ def helicopter_class=(value)
+ @helicopter_class = value.nil? ? nil : (HELICOPTER_CLASSES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid helicopter class"))
+ end
+
def status=(value)
@status = value.nil? ? nil : (STATUSES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid status"))
end
def remarks=(value)
@remarks = value&.to_s
end
+ # Add a lighting system to the runway direction.
+ #
+ # @param lighting [AIXM::Component::Lighting] lighting instance
+ # @return [self]
+ def add_lighting(lighting)
+ fail(ArgumentError, "invalid lighting") unless lighting.is_a? AIXM::Component::Lighting
+ lighting.send(:lightable=, self)
+ @lightings << lighting
+ self
+ end
+
# @return [String] UID markup
def to_uid
builder = Builder::XmlMarkup.new(indent: 2)
builder.TlaUid do |tla_uid|
tla_uid << airport.to_uid.indent(2)
@@ -122,10 +170,11 @@
# @return [String] AIXM or OFMX markup
def to_xml
builder = Builder::XmlMarkup.new(indent: 2)
builder.Tla do |tla|
tla << to_uid.indent(2)
+ tla << fato.to_uid.indent(2) if fato
tla.geoLat(xy.lat(AIXM.schema))
tla.geoLong(xy.long(AIXM.schema))
tla.codeDatum('WGE')
if z
tla.valElev(z.alt)
@@ -136,12 +185,18 @@
tla.uomDim(length.unit.to_s.upcase) if length
tla.uomDim(width.unit.to_s.upcase) if width && !length
unless (xml = surface.to_xml).empty?
tla << xml.indent(2)
end
+ tla.codeClassHel(HELICOPTER_CLASSES.key(helicopter_class).to_s) if helicopter_class
+ tla.txtMarking(marking) if marking
tla.codeSts(STATUSES.key(status).to_s) if status
tla.txtRmk(remarks) if remarks
end
+ lightings.each do |lighting|
+ builder << lighting.to_xml(as: :Tls)
+ end
+ builder.target!
end
end
end
end