lib/aixm/component/helipad.rb in aixm-1.0.0 vs lib/aixm/component/helipad.rb in aixm-1.1.0

- old
+ new

@@ -1,34 +1,34 @@ using AIXM::Refinements module AIXM - module Component + class Component # 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 + # 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.dimensions = AIXM.r or nil # helipad.surface = AIXM.surface # helipad.marking = String or nil + # helipad.add_lighting = AIXM.lighting # helipad.fato = AIXM.fato or nil - # helipad.helicopter_class = HELICOPTER_CLASSES or nil + # helipad.performance_class = PERFORMANCE_CLASSES or nil # helipad.status = STATUSES or nil # helipad.remarks = String or nil # # @see https://gitlab.com/openflightmaps/ofmx/wikis/Airport#tla-helipad-tlof - class Helipad + class Helipad < Component include AIXM::Association include AIXM::Memoize - HELICOPTER_CLASSES = { + PERFORMANCE_CLASSES = { '1': :'1', '2': :'2', '3': :'3', OTHER: :other # specify in remarks }.freeze @@ -42,22 +42,25 @@ OTHER: :other # specify in remarks }.freeze # @!method fato # @return [AIXM::Component::FATO, nil] FATO the helipad is situated on + # # @!method fato=(fato) # @param fato [AIXM::Component::FATO, nil] has_one :fato, allow_nil: true # @!method surface # @return [AIXM::Component::Surface] surface of the helipad + # # @!method surface=(surface) # @param surface [AIXM::Component::Surface] - has_one :surface + has_one :surface, accept: 'AIXM::Component::Surface' # @!method lightings # @return [Array<AIXM::Component::Lighting>] installed lighting systems + # # @!method add_lighting(lighting) # @param lighting [AIXM::Component::Lighting] # @return [self] has_many :lightings, as: :lightable @@ -72,21 +75,18 @@ attr_reader :xy # @return [AIXM::Z, nil] elevation in +:qnh+ attr_reader :z - # @return [AIXM::D, nil] length - attr_reader :length + # @return [AIXM::R, nil] dimensions + attr_reader :dimensions - # @return [AIXM::D, nil] width - attr_reader :width - # @return [String, nil] markings attr_reader :marking - # @return [Integer, Symbol, nil] suitable helicopter class - attr_reader :helicopter_class + # @return [Integer, Symbol, nil] suitable performance class + attr_reader :performance_class # @return [Symbol, nil] status of the helipad (see {STATUSES}) or +nil+ for normal operation attr_reader :status # @return [String, nil] free text remarks @@ -115,32 +115,21 @@ def z=(value) fail(ArgumentError, "invalid z") unless value.nil? || (value.is_a?(AIXM::Z) && value.qnh?) @z = value end - def length=(value) - @length = if value - fail(ArgumentError, "invalid length") unless value.is_a?(AIXM::D) && value.dist > 0 - fail(ArgumentError, "invalid length unit") if width && width.unit != value.unit - @length = value - end + def dimensions=(value) + fail(ArgumentError, "invalid dimensions") unless value.nil? || value.is_a?(AIXM::R) + @dimensions = value end - def width=(value) - @width = if value - fail(ArgumentError, "invalid width") unless value.is_a?(AIXM::D) && value.dist > 0 - fail(ArgumentError, "invalid width unit") if length && length.unit != value.unit - @width = value - end - end - def marking=(value) @marking = value&.to_s end - def helicopter_class=(value) - @helicopter_class = value.nil? ? nil : (HELICOPTER_CLASSES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid helicopter class")) + def performance_class=(value) + @performance_class = value.nil? ? nil : (PERFORMANCE_CLASSES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid performance class")) end def status=(value) @status = value.nil? ? nil : (STATUSES.lookup(value.to_s.to_sym, nil) || fail(ArgumentError, "invalid status")) end @@ -170,17 +159,18 @@ tla.codeDatum('WGE') if z tla.valElev(z.alt) tla.uomDistVer(z.unit.upcase.to_s) end - tla.valLen(length.dist.trim) if length - tla.valWid(width.dist.trim) if width - tla.uomDim(length.unit.to_s.upcase) if length - tla.uomDim(width.unit.to_s.upcase) if width && !length + if dimensions + tla.valLen(dimensions.length.to_m.dim.trim) + tla.valWid(dimensions.width.to_m.dim.trim) + tla.uomDim('M') + end unless (xml = surface.to_xml).empty? tla << xml.indent(2) end - tla.codeClassHel(HELICOPTER_CLASSES.key(helicopter_class).to_s) if helicopter_class + tla.codeClassHel(PERFORMANCE_CLASSES.key(performance_class).to_s) if performance_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|