Class: AIXM::Feature::Obstacle
- Inherits:
-
AIXM::Feature
- Object
- AIXM::Feature
- AIXM::Feature::Obstacle
- Defined in:
- lib/aixm/feature/obstacle.rb
Overview
Obstacles are individual objects described as cylindrical volume with circular base and height.
Cheat Sheet in Pseudo Code:
obstacle = AIXM.obstacle(
source: String or nil
name: String or nil
type: TYPES
xy: AIXM.xy
z: AIXM.z
radius: AIXM.d
)
obstacle.lighting = true or false (default for AIXM) or nil (means: unknown, default for OFMX)
obstacle.lighting_remarks = String or nil
obstacle.marking = true or false or nil (means: unknown, default)
obstacle.marking_remarks = String or nil
obstacle.height = AIXM.d or nil
obstacle.height_accurate = true or false or nil (means: unknown, default)
obstacle.xy_accuracy = AIXM.d or nil
obstacle.z_accuracy = AIXM.d or nil
obstacle.valid_from = Time or Date or String or nil
obstacle.valid_until = Time or Date or String or nil
obstacle.remarks = String or nil
obstacle.link_to # => AIXM.obstacle or nil
obstacle.link_type # => LINK_TYPE or nil
See ObstacleGroup for how to define physical links between two obstacles (e.g. cables between powerline towers).
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!
Constant Summary collapse
- TYPES =
{ ANTENNA: :antenna, BUILDING: :building, CHIMNEY: :chimney, CRANE: :crane, MAST: :mast, TOWER: :tower, WINDTURBINE: :wind_turbine, OTHER: :other # specify in remarks }.freeze
- LINK_TYPES =
{ CABLE: :cable, SOLID: :solid, OTHER: :other }.freeze
Instance Attribute Summary collapse
-
#height ⇒ AIXM::D?
Height from ground to top point.
-
#height_accurate ⇒ Boolean?
Height accuracy true => height measured, false => height estimated, nil => unknown.
-
#lighting ⇒ Boolean?
Lighting (e.g. strobes) true => lighting present, false => no lighting, nil => unknown.
-
#lighting_remarks ⇒ String?
Detailed description of the lighting.
-
#link_type ⇒ Symbol?
readonly
Type of physical link between this and another obstacle.
-
#linked_to ⇒ Symbol?
readonly
Another obstacle to which a physical link exists.
-
#marking ⇒ Boolean?
Marking (e.g. red/white paint) true => marking present, false => no marking, nil => unknown.
-
#marking_remarks ⇒ String?
Detailed description of the marking.
-
#name ⇒ String
Full name.
-
#obstacle_group ⇒ AIXM::Feature::ObstacleGroup
readonly
Group this obstacle belongs to.
-
#radius ⇒ AIXM::D
Circular base radius.
-
#remarks ⇒ String?
Free text remarks.
-
#type ⇒ Symbol
Type of obstacle.
-
#valid_from ⇒ Time, ...
Effective after this point in time.
-
#valid_until ⇒ Time, ...
Effective until this point in time.
-
#xy ⇒ AIXM::XY
Circular base center point.
-
#xy_accuracy ⇒ AIXM::D?
Margin of error for circular base center point.
-
#z ⇒ AIXM::Z
Elevation of the top point in
:qnh. -
#z_accuracy ⇒ AIXM::D?
Margin of error for top point.
Attributes inherited from AIXM::Feature
Instance Method Summary collapse
-
#grouped? ⇒ Boolean
Whether part of an obstacle group.
-
#initialize(source: nil, name: nil, type:, xy:, z:, radius:) ⇒ Obstacle
constructor
A new instance of Obstacle.
- #inspect ⇒ String
-
#linked? ⇒ Boolean
Whether obstacle is linked to another one.
-
#to_uid(as: :ObsUid) ⇒ String
UID markup.
-
#to_xml(delegate: true) ⇒ String
AIXM or OFMX markup.
Methods inherited from AIXM::Feature
Constructor Details
#initialize(source: nil, name: nil, type:, xy:, z:, radius:) ⇒ Obstacle
120 121 122 123 124 |
# File 'lib/aixm/feature/obstacle.rb', line 120 def initialize(source: nil, name: nil, type:, xy:, z:, radius:) super(source: source) self.name, self.type, self.xy, self.z, self.radius = name, type, xy, z, radius @lighting = @marking = @height_accurate = false end |
Instance Attribute Details
#height ⇒ AIXM::D?
90 91 92 |
# File 'lib/aixm/feature/obstacle.rb', line 90 def height @height end |
#height_accurate ⇒ Boolean?
94 95 96 |
# File 'lib/aixm/feature/obstacle.rb', line 94 def height_accurate @height_accurate end |
#lighting ⇒ Boolean?
77 78 79 |
# File 'lib/aixm/feature/obstacle.rb', line 77 def lighting @lighting end |
#lighting_remarks ⇒ String?
80 81 82 |
# File 'lib/aixm/feature/obstacle.rb', line 80 def lighting_remarks @lighting_remarks end |
#link_type ⇒ Symbol?
118 119 120 |
# File 'lib/aixm/feature/obstacle.rb', line 118 def link_type @link_type end |
#linked_to ⇒ Symbol?
115 116 117 |
# File 'lib/aixm/feature/obstacle.rb', line 115 def linked_to @linked_to end |
#marking ⇒ Boolean?
84 85 86 |
# File 'lib/aixm/feature/obstacle.rb', line 84 def marking @marking end |
#marking_remarks ⇒ String?
87 88 89 |
# File 'lib/aixm/feature/obstacle.rb', line 87 def marking_remarks @marking_remarks end |
#name ⇒ String
61 62 63 |
# File 'lib/aixm/feature/obstacle.rb', line 61 def name @name end |
#obstacle_group ⇒ AIXM::Feature::ObstacleGroup
112 113 114 |
# File 'lib/aixm/feature/obstacle.rb', line 112 def obstacle_group @obstacle_group end |
#radius ⇒ AIXM::D
70 71 72 |
# File 'lib/aixm/feature/obstacle.rb', line 70 def radius @radius end |
#remarks ⇒ String?
109 110 111 |
# File 'lib/aixm/feature/obstacle.rb', line 109 def remarks @remarks end |
#type ⇒ Symbol
64 65 66 |
# File 'lib/aixm/feature/obstacle.rb', line 64 def type @type end |
#valid_from ⇒ Time, ...
103 104 105 |
# File 'lib/aixm/feature/obstacle.rb', line 103 def valid_from @valid_from end |
#valid_until ⇒ Time, ...
106 107 108 |
# File 'lib/aixm/feature/obstacle.rb', line 106 def valid_until @valid_until end |
#xy ⇒ AIXM::XY
67 68 69 |
# File 'lib/aixm/feature/obstacle.rb', line 67 def xy @xy end |
#xy_accuracy ⇒ AIXM::D?
97 98 99 |
# File 'lib/aixm/feature/obstacle.rb', line 97 def xy_accuracy @xy_accuracy end |
#z ⇒ AIXM::Z
73 74 75 |
# File 'lib/aixm/feature/obstacle.rb', line 73 def z @z end |
#z_accuracy ⇒ AIXM::D?
100 101 102 |
# File 'lib/aixm/feature/obstacle.rb', line 100 def z_accuracy @z_accuracy end |
Instance Method Details
#grouped? ⇒ Boolean
223 224 225 |
# File 'lib/aixm/feature/obstacle.rb', line 223 def grouped? obstacle_group && obstacle_group.obstacles.count > 1 end |
#inspect ⇒ String
127 128 129 |
# File 'lib/aixm/feature/obstacle.rb', line 127 def inspect %Q(#<#{self.class} xy="#{xy.to_s}" type=#{type.inspect}>) end |
#linked? ⇒ Boolean
228 229 230 |
# File 'lib/aixm/feature/obstacle.rb', line 228 def linked? !!linked_to end |
#to_uid(as: :ObsUid) ⇒ String
233 234 235 236 237 238 239 240 241 |
# File 'lib/aixm/feature/obstacle.rb', line 233 def to_uid(as: :ObsUid) self.obstacle_group ||= singleton_obstacle_group builder = Builder::XmlMarkup.new(indent: 2) builder.tag!(as) do |tag| tag << obstacle_group.to_uid.indent(2) if AIXM.ofmx? tag.geoLat((xy.lat(AIXM.schema))) tag.geoLong((xy.long(AIXM.schema))) end end |
#to_xml(delegate: true) ⇒ String
244 245 246 247 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 |
# File 'lib/aixm/feature/obstacle.rb', line 244 def to_xml(delegate: true) self.obstacle_group ||= singleton_obstacle_group return obstacle_group.to_xml if delegate && AIXM.ofmx? builder = Builder::XmlMarkup.new(indent: 2) builder.comment! "Obstacle: [#{type}] #{xy.to_s} #{name}".strip builder.Obs do |obs| obs << to_uid.indent(2) obs.txtName(name) if name if AIXM.ofmx? obs.codeType(TYPES.key(type).to_s) else obs.txtDescrType(TYPES.key(type).to_s) end obs.codeGroup(grouped? ? 'Y' : 'N') if AIXM.ofmx? obs.codeLgt(lighting ? 'Y' : 'N') unless lighting.nil? obs.codeMarking(marking ? 'Y' : 'N') unless marking.nil? else obs.codeLgt(lighting ? 'Y' : 'N') end obs.txtDescrLgt(lighting_remarks) if lighting_remarks obs.txtDescrMarking(marking_remarks) if marking_remarks obs.codeDatum('WGE') if AIXM.aixm? && obstacle_group.xy_accuracy obs.valGeoAccuracy(obstacle_group.xy_accuracy.dist.trim) obs.uomGeoAccuracy(obstacle_group.xy_accuracy.unit.upcase.to_s) end obs.valElev(z.alt) if AIXM.aixm? && obstacle_group.z_accuracy obs.valElevAccuracy(obstacle_group.z_accuracy.to_ft.dist.round) end obs.valHgt(height.to_ft.dist.round) if height obs.uomDistVer('FT') if AIXM.ofmx? && !height_accurate.nil? obs.codeHgtAccuracy(height_accurate ? 'Y' : 'N') end if AIXM.ofmx? if radius obs.valRadius(radius.dist.trim) obs.uomRadius(radius.unit.upcase.to_s) end if grouped? && linked? obs << linked_to.to_uid(as: :ObsUidLink).indent(2) obs.codeLinkType(LINK_TYPES.key(link_type).to_s) end obs.datetimeValidWef(valid_from.xmlschema) if valid_from obs.datetimeValidTil(valid_until.xmlschema) if valid_until end obs.txtRmk(remarks) if remarks end end |