class AIXM::Feature::Obstacle
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 region: String or nil name: String or nil type: TYPES xy: AIXM.xy z: AIXM.z radius: AIXM.d or nil ) 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 {AIXM::Feature::ObstacleGroup} for how to define physical links between two obstacles (e.g. cables between powerline towers).
Please note: Accuracies (xy_accuracy
and z_accuracy
) set on an obstacle group are implicitly applied to all obstacles of the group unless they have their own, different accuracies set.
Constants
- LINK_TYPES
- TYPES
Attributes
@return [AIXM::D, nil] height from ground to top point
@return [Boolean, nil] height accuracy
true => height measured, false => height estimated, nil => unknown
@return [Boolean, nil] lighting (e.g. strobes)
true => lighting present, false => no lighting, nil => unknown
@return [String, nil] detailed description of the lighting
@return [Symbol, nil] type of physical link between this and another obstacle
@return [Symbol, nil] another obstacle to which a physical link exists
@return [Boolean, nil] marking (e.g. red/white paint)
true => marking present, false => no marking, nil => unknown
@return [String, nil] detailed description of the marking
@return [String] full name
@return [AIXM::D] circular base radius
@return [String, nil] free text remarks
@return [Symbol] type of obstacle
@return [Time, Date, String, nil] effective after this point in time
@return [Time, Date, String, nil] effective until this point in time
@return [AIXM::XY] circular base center point
@return [AIXM::D, nil] margin of error for circular base center point
@return [AIXM::Z] elevation of the top point in :qnh
@return [AIXM::D, nil] margin of error for top point
Public Class Methods
# File lib/aixm/feature.rb 15 def initialize(source: nil, region: nil) 16 self.source = source 17 self.region = region || AIXM.config.region 18 end
AIXM::Feature::new
# File lib/aixm/feature/obstacle.rb 125 def initialize(source: nil, region: nil, name: nil, type:, xy:, z:, radius: nil) 126 super(source: source, region: region) 127 self.name, self.type, self.xy, self.z, self.radius = name, type, xy, z, radius 128 @lighting = @marking = false 129 end
Public Instance Methods
# File lib/aixm/feature/obstacle.rb 178 def height=(value) 179 fail(ArgumentError, "invalid height") unless value.nil? || (value.is_a?(AIXM::D) && value.dist > 0) 180 @height = value 181 end
# File lib/aixm/feature/obstacle.rb 183 def height_accurate=(value) 184 fail(ArgumentError, "invalid height accurate") unless [true, false, nil].include? value 185 @height_accurate = value 186 end
@return [String]
# File lib/aixm/feature/obstacle.rb 132 def inspect 133 %Q(#<#{self.class} xy="#{xy.to_s}" type=#{type.inspect}>) 134 end
# File lib/aixm/feature/obstacle.rb 160 def lighting=(value) 161 fail(ArgumentError, "invalid lighting") unless [true, false, nil].include? value 162 @lighting = value 163 end
# File lib/aixm/feature/obstacle.rb 165 def lighting_remarks=(value) 166 @lighting_remarks = value&.to_s 167 end
@return [Boolean] whether obstacle is linked to another one
# File lib/aixm/feature/obstacle.rb 222 def linked? 223 !!linked_to 224 end
# File lib/aixm/feature/obstacle.rb 169 def marking=(value) 170 fail(ArgumentError, "invalid marking") unless [true, false, nil].include? value 171 @marking = value 172 end
# File lib/aixm/feature/obstacle.rb 174 def marking_remarks=(value) 175 @marking_remarks = value&.to_s 176 end
# File lib/aixm/feature/obstacle.rb 136 def name=(value) 137 fail(ArgumentError, "invalid name") unless value.nil? || value.is_a?(String) 138 @name = value&.uptrans 139 end
# File lib/aixm/feature/obstacle.rb 155 def radius=(value) 156 fail(ArgumentError, "invalid radius") unless value.nil? || (value.is_a?(AIXM::D) && value.dist > 0) 157 @radius = value 158 end
# File lib/aixm/feature/obstacle.rb 206 def remarks=(value) 207 @remarks = value&.to_s 208 end
@return [String] UID markup
# File lib/aixm/feature/obstacle.rb 227 def to_uid(as: :ObsUid) 228 builder = Builder::XmlMarkup.new(indent: 2) 229 builder.tag!(as, { region: (region if AIXM.ofmx?) }.compact) do |tag| 230 tag.geoLat((xy.lat(AIXM.schema))) 231 tag.geoLong((xy.long(AIXM.schema))) 232 end 233 end
@return [String] AIXM
or OFMX markup
# File lib/aixm/feature/obstacle.rb 237 def to_xml(delegate: true) 238 return obstacle_group.to_xml if delegate && obstacle_group && AIXM.ofmx? 239 builder = Builder::XmlMarkup.new(indent: 2) 240 builder.comment! "Obstacle: [#{type}] #{xy.to_s} #{name}".strip 241 builder.Obs do |obs| 242 obs << to_uid.indent(2) 243 obs << obstacle_group.to_uid.indent(2) if obstacle_group && AIXM.ofmx? 244 obs.txtName(name) if name 245 if AIXM.ofmx? 246 obs.codeType(TYPES.key(type).to_s) 247 else 248 obs.txtDescrType(TYPES.key(type).to_s) 249 end 250 obs.codeGroup(obstacle_group ? 'Y' : 'N') if AIXM.aixm? 251 if AIXM.ofmx? 252 obs.codeLgt(lighting ? 'Y' : 'N') unless lighting.nil? 253 obs.codeMarking(marking ? 'Y' : 'N') unless marking.nil? 254 else 255 obs.codeLgt(lighting ? 'Y' : 'N') 256 end 257 obs.txtDescrLgt(lighting_remarks) if lighting_remarks 258 obs.txtDescrMarking(marking_remarks) if marking_remarks 259 obs.codeDatum('WGE') 260 if accuracy = (xy_accuracy || (obstacle_group&.xy_accuracy if AIXM.aixm?)) 261 obs.valGeoAccuracy(accuracy.dist.trim) 262 obs.uomGeoAccuracy(accuracy.unit.upcase.to_s) 263 end 264 obs.valElev(z.alt) 265 if accuracy = (z_accuracy || (obstacle_group&.z_accuracy if AIXM.aixm?)) 266 obs.valElevAccuracy(accuracy.to_ft.dist.round) 267 obs.uomElevAccuracy('FT') if AIXM.ofmx? 268 end 269 obs.valHgt(height.to_ft.dist.round) if height 270 obs.uomDistVer('FT') 271 if AIXM.ofmx? && !height_accurate.nil? 272 obs.codeHgtAccuracy(height_accurate ? 'Y' : 'N') 273 end 274 if AIXM.ofmx? 275 if radius 276 obs.valRadius(radius.dist.trim) 277 obs.uomRadius(radius.unit.upcase.to_s) 278 end 279 if linked? 280 obs << linked_to.to_uid(as: :ObsUidLink).indent(2) 281 obs.codeLinkType(LINK_TYPES.key(link_type).to_s) 282 end 283 obs.datetimeValidWef(valid_from.xmlschema) if valid_from 284 obs.datetimeValidTil(valid_until.xmlschema) if valid_until 285 end 286 obs.txtRmk(remarks) if remarks 287 end 288 end
# File lib/aixm/feature/obstacle.rb 141 def type=(value) 142 @type = TYPES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid type") 143 end
# File lib/aixm/feature/obstacle.rb 198 def valid_from=(value) 199 @valid_from = value&.to_time 200 end
# File lib/aixm/feature/obstacle.rb 202 def valid_until=(value) 203 @valid_until = value&.to_time 204 end
# File lib/aixm/feature/obstacle.rb 145 def xy=(value) 146 fail(ArgumentError, "invalid xy") unless value.is_a? AIXM::XY 147 @xy = value 148 end
# File lib/aixm/feature/obstacle.rb 188 def xy_accuracy=(value) 189 fail(ArgumentError, "invalid xy accuracy") unless value.nil? || value.is_a?(AIXM::D) 190 @xy_accuracy = value 191 end
# File lib/aixm/feature/obstacle.rb 150 def z=(value) 151 fail(ArgumentError, "invalid z") unless value.is_a?(AIXM::Z) && value.qnh? 152 @z = value 153 end
# File lib/aixm/feature/obstacle.rb 193 def z_accuracy=(value) 194 fail(ArgumentError, "invalid z accuracy") unless value.nil? || value.is_a?(AIXM::D) 195 @z_accuracy = value 196 end
Private Instance Methods
# File lib/aixm/feature/obstacle.rb 216 def link_type=(value) 217 @link_type = LINK_TYPES.lookup(value&.to_s&.to_sym, nil) || fail(ArgumentError, "invalid link type") 218 end
# File lib/aixm/feature/obstacle.rb 210 def linked_to=(value) 211 fail(ArgumentError, "invalid linked to") unless value.is_a?(AIXM::Feature::Obstacle) 212 @linked_to = value 213 end