Class: AIXM::Feature::Unit
- Inherits:
-
AIXM::Feature
- Object
- AIXM::Feature
- AIXM::Feature::Unit
- Defined in:
- lib/aixm/feature/unit.rb
Overview
Units providing all kind of services such as air traffic management, search and rescue, meteorological services and so forth.
Cheat Sheet in Pseudo Code:
unit = AIXM.unit(
source: String or nil
organisation: AIXM.organisation
name: String
type: TYPES
class: :icao or :other
)
unit.airport = AIXM.airport or nil
unit.remarks = String or nil
unit.add_service(AIXM.service)
Constant Summary collapse
- TYPES =
{ ACC: :area_control_centre, ADSU: :automatic_dependent_surveillance_unit, ADVC: :advisory_centre, ALPS: :alerting_post, AOF: :aeronautical_information_services_office, APP: :approach_control_office, 'APP-ARR': :arrivals_approach_control_office, 'APP-DEP': :depatures_approach_control_office, ARO: :air_traffic_service_reporting_office, ARTCC: :air_route_traffic_control_centre, ATCC: :air_traffic_control_centre, ATFMU: :air_traffic_flow_management_unit, ATMU: :air_traffic_management_unit, ATSU: :air_traffic_services_unit, BOF: :briefing_office, BS: :commercial_broadcasting_station, COM: :communications_office, FCST: :forecasting_office, FIC: :flight_information_centre, FSS: :flight_service_station, GCA: :ground_controlled_approach_systems_office, MET: :meteorological_office, MIL: :military_station, MILOPS: :military_flight_operations_briefing_office, MWO: :meteorological_watch_office, NOF: :international_notam_office, OAC: :oceanic_control_centre, PAR: :precision_approach_radar_centre, RAD: :radar_office, RAFC: :regional_area_forecast_centre, RCC: :rescue_coordination_centre, RSC: :rescue_sub_centre, SAR: :search_and_rescue_centre, SMC: :surface_movement_control_office, SMR: :surface_movement_radar_office, SRA: :surveillance_radar_approach_centre, SSR: :secondary_surveillance_radar_centre, TAR: :terminal_area_surveillance_radar_centre, TRACON: :terminal_radar_approach_control, TWR: :aerodrome_control_tower, UAC: :upper_area_control_centre, UDF: :uhf_direction_finding_station, UIC: :upper_information_centre, VDF: :vdf_direction_finding_station, WAFC: :world_area_forecast_centre, OTHER: :other # specify in remarks }.freeze
- CLASSES =
{ ICAO: :icao, OTHER: :other # specify in remarks }.freeze
Instance Attribute Summary collapse
-
#airport ⇒ AIXM::Feature::Airport?
Airport.
-
#class ⇒ Symbol
Class of unit (see CLASSES).
-
#name ⇒ String
Name of unit (e.g. “MARSEILLE ACS”).
-
#organisation ⇒ AIXM::Feature::Organisation
Superior organisation.
-
#remarks ⇒ String?
Free text remarks.
-
#services ⇒ Array<AIXM::Feature::Service>
readonly
Services provided by this unit.
-
#type ⇒ Symbol
Type of unit (see TYPES).
Attributes inherited from AIXM::Feature
Instance Method Summary collapse
-
#add_service(service) ⇒ self
Add a service provided by this unit.
-
#initialize(source: nil, organisation:, name:, type:, class:) ⇒ Unit
constructor
A new instance of Unit.
- #inspect ⇒ String
-
#original_class ⇒ Symbol
Class of unit (see CLASSES).
-
#to_uid ⇒ String
UID markup.
-
#to_xml ⇒ String
AIXM or OFMX markup.
Methods inherited from AIXM::Feature
Constructor Details
#initialize(source: nil, organisation:, name:, type:, class:) ⇒ Unit
Returns a new instance of Unit.
94 95 96 97 98 99 |
# File 'lib/aixm/feature/unit.rb', line 94 def initialize(source: nil, organisation:, name:, type:, class:) super(source: source) self.organisation, self.name, self.type = organisation, name, type self.class = binding.local_variable_get(:class) @services = [] end |
Instance Attribute Details
#airport ⇒ AIXM::Feature::Airport?
Returns airport.
89 90 91 |
# File 'lib/aixm/feature/unit.rb', line 89 def airport @airport end |
#class ⇒ Symbol
Use original_class to query the Ruby object class.
Returns class of unit (see CLASSES).
123 |
# File 'lib/aixm/feature/unit.rb', line 123 alias_method :original_class, :class |
#name ⇒ String
Returns name of unit (e.g. “MARSEILLE ACS”).
83 84 85 |
# File 'lib/aixm/feature/unit.rb', line 83 def name @name end |
#organisation ⇒ AIXM::Feature::Organisation
Returns superior organisation.
80 81 82 |
# File 'lib/aixm/feature/unit.rb', line 80 def organisation @organisation end |
#remarks ⇒ String?
Returns free text remarks.
92 93 94 |
# File 'lib/aixm/feature/unit.rb', line 92 def remarks @remarks end |
#services ⇒ Array<AIXM::Feature::Service> (readonly)
Returns services provided by this unit.
154 155 156 |
# File 'lib/aixm/feature/unit.rb', line 154 def services @services.sort { |a, b| a.type <=> b.type } end |
#type ⇒ Symbol
Returns type of unit (see TYPES).
86 87 88 |
# File 'lib/aixm/feature/unit.rb', line 86 def type @type end |
Instance Method Details
#add_service(service) ⇒ self
Add a service provided by this unit.
145 146 147 148 149 150 |
# File 'lib/aixm/feature/unit.rb', line 145 def add_service(service) fail(ArgumentError, "invalid service") unless service.is_a? AIXM::Feature::Service service.send(:unit=, self) @services << service self end |
#inspect ⇒ String
102 103 104 |
# File 'lib/aixm/feature/unit.rb', line 102 def inspect %Q(#<#{original_class} name=#{name.inspect} type=#{type.inspect}>) end |
#original_class ⇒ Symbol
Use original_class to query the Ruby object class.
Returns class of unit (see CLASSES).
123 |
# File 'lib/aixm/feature/unit.rb', line 123 alias_method :original_class, :class |
#to_uid ⇒ String
Returns UID markup.
159 160 161 162 163 164 |
# File 'lib/aixm/feature/unit.rb', line 159 def to_uid builder = Builder::XmlMarkup.new(indent: 2) builder.UniUid do |uni_uid| uni_uid.txtName(name) end end |
#to_xml ⇒ String
Returns AIXM or OFMX markup.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/aixm/feature/unit.rb', line 167 def to_xml builder = Builder::XmlMarkup.new(indent: 2) builder.comment! "Unit: #{name}" builder.Uni({ source: (source if AIXM.ofmx?) }.compact) do |uni| uni << to_uid.indent(2) uni << organisation.to_uid.indent(2) uni << airport.to_uid.indent(2) if airport uni.codeType(TYPES.key(type).to_s) uni.codeClass(CLASSES.key(self.class).to_s) uni.txtRmk(remarks) if remarks end services.each.with_object({}) do |service, sequences| sequences[service.type] = (sequences[service.type] || 0) + 1 builder << service.to_xml(sequence: sequences[service.type]) end builder.target! end |