Class: AIXM::Feature::ObstacleGroup
- Inherits:
-
AIXM::Feature
- Object
- Component
- AIXM::Feature
- AIXM::Feature::ObstacleGroup
- Includes:
- Concerns::Association, Concerns::Remarks
- Defined in:
- lib/aixm/feature/obstacle_group.rb
Overview
Groups of obstacles which consist of either linked (e.g. power line towers) or unlinked (e.g. wind turbines) members.
Cheat Sheet in Pseudo Code:
obstacle_group = AIXM.obstacle_group(
source: String or nil # see remarks below
region: String or nil
name: String or nil
)
obstacle_group.xy_accuracy = AIXM.d or nil
obstacle_group.z_accuracy = AIXM.d or nil
obstacle_group.remarks = String or nil
obstacle_group.comment = Object or nil
obstacle_group.add_obstacle( # add an obstacle to the group
AIXM.obstacle
)
obstacle_group.add_obstacle( # add an obstacle to the group and link
AIXM.obstacle, # it to the obstacle last added to the group
linked_to: :previous,
link_type: LINK_TYPES
)
obstacle_group.add_obstacle( # add an obstacle to the group and link
AIXM.obstacle, # it to any obstacle already in the group
linked_to: AIXM.obstacle,
link_type: LINK_TYPES
)
Please note: As soon as an obstacle is added to an obstacle group, the xy_accuracy
and z_accuracy
of the obstacle group overwrite whatever is set on the individual obstacles. On the other hand, if the obstacle group has no source
set, it will inherit this value from the first obstacle in the group.
Constant Summary
Constants inherited from AIXM::Feature
Instance Attribute Summary
Attributes included from Concerns::Remarks
Attributes inherited from AIXM::Feature
Attributes inherited from Component
Instance Method Summary collapse
- #add_obstacle(obstacle, linked_to: nil, link_type: nil) ⇒ self
-
#initialize(source: nil, region: nil, name: nil) ⇒ ObstacleGroup
constructor
See the cheat sheet for examples on how to create instances of this class.
- #inspect ⇒ String
-
#name ⇒ String
Obstacle group name.
- #name=(value) ⇒ Object
-
#obstacles ⇒ Array<AIXM::Feature::Obstacle>
Obstacles in this obstacle group.
-
#source ⇒ String
Reference to source of the feature data.
-
#xy_accuracy ⇒ AIXM::D?
Margin of error for circular base center point.
- #xy_accuracy=(value) ⇒ Object
-
#z_accuracy ⇒ AIXM::D?
Margin of error for top point.
- #z_accuracy=(value) ⇒ Object
Methods included from Concerns::Association
Methods inherited from AIXM::Feature
Methods included from Concerns::HashEquality
Methods included from Concerns::XMLBuilder
#build_fragment, #to_uid, #to_xml
Methods included from Concerns::Memoize
Constructor Details
#initialize(source: nil, region: nil, name: nil) ⇒ ObstacleGroup
See the cheat sheet for examples on how to create instances of this class.
83 84 85 86 |
# File 'lib/aixm/feature/obstacle_group.rb', line 83 def initialize(source: nil, region: nil, name: nil) super(source: source, region: region) self.name = name end |
Instance Method Details
#add_obstacle(obstacle, linked_to: nil, link_type: nil) ⇒ self
57 58 59 60 61 62 |
# File 'lib/aixm/feature/obstacle_group.rb', line 57 has_many :obstacles do |obstacle, linked_to: nil, link_type: nil| if linked_to obstacle.send(:linked_to=, linked_to == :previous ? @obstacles.last : linked_to) obstacle.send(:link_type=, (link_type || :other)) end end |
#inspect ⇒ String
89 90 91 |
# File 'lib/aixm/feature/obstacle_group.rb', line 89 def inspect %Q(#<#{self.class} #{obstacles.count} obstacle(s)>) end |
#name ⇒ String
Returns obstacle group name.
75 76 77 78 79 |
# File 'lib/aixm/feature/obstacle_group.rb', line 75 %i(source name xy_accuracy z_accuracy).each do |method| define_method method do instance_variable_get(:"@#{method}") || obstacles.first&.send(method) end end |
#name=(value) ⇒ Object
93 94 95 96 |
# File 'lib/aixm/feature/obstacle_group.rb', line 93 def name=(value) fail(ArgumentError, "invalid name") unless value.nil? || value.is_a?(String) @name = value&.uptrans end |
#obstacles ⇒ Array<AIXM::Feature::Obstacle>
Returns obstacles in this obstacle group.
57 58 59 60 61 62 |
# File 'lib/aixm/feature/obstacle_group.rb', line 57 has_many :obstacles do |obstacle, linked_to: nil, link_type: nil| if linked_to obstacle.send(:linked_to=, linked_to == :previous ? @obstacles.last : linked_to) obstacle.send(:link_type=, (link_type || :other)) end end |
#source ⇒ String
Returns reference to source of the feature data.
75 76 77 78 79 |
# File 'lib/aixm/feature/obstacle_group.rb', line 75 %i(source name xy_accuracy z_accuracy).each do |method| define_method method do instance_variable_get(:"@#{method}") || obstacles.first&.send(method) end end |
#xy_accuracy ⇒ AIXM::D?
Returns margin of error for circular base center point.
75 76 77 78 79 |
# File 'lib/aixm/feature/obstacle_group.rb', line 75 %i(source name xy_accuracy z_accuracy).each do |method| define_method method do instance_variable_get(:"@#{method}") || obstacles.first&.send(method) end end |
#xy_accuracy=(value) ⇒ Object
98 99 100 101 |
# File 'lib/aixm/feature/obstacle_group.rb', line 98 def xy_accuracy=(value) fail(ArgumentError, "invalid xy accuracy") unless value.nil? || value.is_a?(AIXM::D) @xy_accuracy = value end |
#z_accuracy ⇒ AIXM::D?
Returns margin of error for top point.
75 76 77 78 79 |
# File 'lib/aixm/feature/obstacle_group.rb', line 75 %i(source name xy_accuracy z_accuracy).each do |method| define_method method do instance_variable_get(:"@#{method}") || obstacles.first&.send(method) end end |