Class: AIXM::Feature::Obstacle

Inherits:
AIXM::Feature show all
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
{
  CABLE: :cable,
  SOLID: :solid,
  OTHER: :other
}.freeze

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature

#source

Instance Method Summary collapse

Methods inherited from AIXM::Feature

#==

Constructor Details

#initialize(source: nil, name: nil, type:, xy:, z:, radius:) ⇒ Obstacle

Returns a new instance of 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

#heightAIXM::D?

Returns height from ground to top point

Returns:

  • (AIXM::D, nil)

    height from ground to top point


90
91
92
# File 'lib/aixm/feature/obstacle.rb', line 90

def height
  @height
end

#height_accurateBoolean?

Returns height accuracy true => height measured, false => height estimated, nil => unknown

Returns:

  • (Boolean, nil)

    height accuracy true => height measured, false => height estimated, nil => unknown


94
95
96
# File 'lib/aixm/feature/obstacle.rb', line 94

def height_accurate
  @height_accurate
end

#lightingBoolean?

Returns lighting (e.g. strobes) true => lighting present, false => no lighting, nil => unknown

Returns:

  • (Boolean, nil)

    lighting (e.g. strobes) true => lighting present, false => no lighting, nil => unknown


77
78
79
# File 'lib/aixm/feature/obstacle.rb', line 77

def lighting
  @lighting
end

#lighting_remarksString?

Returns detailed description of the lighting

Returns:

  • (String, nil)

    detailed description of the lighting


80
81
82
# File 'lib/aixm/feature/obstacle.rb', line 80

def lighting_remarks
  @lighting_remarks
end

Returns type of physical link between this and another obstacle

Returns:

  • (Symbol, nil)

    type of physical link between this and another obstacle


118
119
120
# File 'lib/aixm/feature/obstacle.rb', line 118

def link_type
  @link_type
end

#linked_toSymbol?

Returns another obstacle to which a physical link exists

Returns:

  • (Symbol, nil)

    another obstacle to which a physical link exists


115
116
117
# File 'lib/aixm/feature/obstacle.rb', line 115

def linked_to
  @linked_to
end

#markingBoolean?

Returns marking (e.g. red/white paint) true => marking present, false => no marking, nil => unknown

Returns:

  • (Boolean, nil)

    marking (e.g. red/white paint) true => marking present, false => no marking, nil => unknown


84
85
86
# File 'lib/aixm/feature/obstacle.rb', line 84

def marking
  @marking
end

#marking_remarksString?

Returns detailed description of the marking

Returns:

  • (String, nil)

    detailed description of the marking


87
88
89
# File 'lib/aixm/feature/obstacle.rb', line 87

def marking_remarks
  @marking_remarks
end

#nameString

Returns full name

Returns:

  • (String)

    full name


61
62
63
# File 'lib/aixm/feature/obstacle.rb', line 61

def name
  @name
end

#obstacle_groupAIXM::Feature::ObstacleGroup

Returns group this obstacle belongs to

Returns:


112
113
114
# File 'lib/aixm/feature/obstacle.rb', line 112

def obstacle_group
  @obstacle_group
end

#radiusAIXM::D

Returns circular base radius

Returns:

  • (AIXM::D)

    circular base radius


70
71
72
# File 'lib/aixm/feature/obstacle.rb', line 70

def radius
  @radius
end

#remarksString?

Returns free text remarks

Returns:

  • (String, nil)

    free text remarks


109
110
111
# File 'lib/aixm/feature/obstacle.rb', line 109

def remarks
  @remarks
end

#typeSymbol

Returns type of obstacle

Returns:

  • (Symbol)

    type of obstacle


64
65
66
# File 'lib/aixm/feature/obstacle.rb', line 64

def type
  @type
end

#valid_fromTime, ...

Returns effective after this point in time

Returns:

  • (Time, Date, String, nil)

    effective after this point in time


103
104
105
# File 'lib/aixm/feature/obstacle.rb', line 103

def valid_from
  @valid_from
end

#valid_untilTime, ...

Returns effective until this point in time

Returns:

  • (Time, Date, String, nil)

    effective until this point in time


106
107
108
# File 'lib/aixm/feature/obstacle.rb', line 106

def valid_until
  @valid_until
end

#xyAIXM::XY

Returns circular base center point

Returns:

  • (AIXM::XY)

    circular base center point


67
68
69
# File 'lib/aixm/feature/obstacle.rb', line 67

def xy
  @xy
end

#xy_accuracyAIXM::D?

Returns margin of error for circular base center point

Returns:

  • (AIXM::D, nil)

    margin of error for circular base center point


97
98
99
# File 'lib/aixm/feature/obstacle.rb', line 97

def xy_accuracy
  @xy_accuracy
end

#zAIXM::Z

Returns elevation of the top point in :qnh

Returns:

  • (AIXM::Z)

    elevation of the top point in :qnh


73
74
75
# File 'lib/aixm/feature/obstacle.rb', line 73

def z
  @z
end

#z_accuracyAIXM::D?

Returns margin of error for top point

Returns:

  • (AIXM::D, nil)

    margin of error for top point


100
101
102
# File 'lib/aixm/feature/obstacle.rb', line 100

def z_accuracy
  @z_accuracy
end

Instance Method Details

#grouped?Boolean

Returns whether part of an obstacle group

Returns:

  • (Boolean)

    whether part of an obstacle group


223
224
225
# File 'lib/aixm/feature/obstacle.rb', line 223

def grouped?
  obstacle_group && obstacle_group.obstacles.count > 1
end

#inspectString

Returns:

  • (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

Returns whether obstacle is linked to another one

Returns:

  • (Boolean)

    whether obstacle is linked to another one


228
229
230
# File 'lib/aixm/feature/obstacle.rb', line 228

def linked?
  !!linked_to
end

#to_uid(as: :ObsUid) ⇒ String

Returns UID markup

Returns:

  • (String)

    UID markup


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

Returns AIXM or OFMX markup

Returns:

  • (String)

    AIXM or OFMX markup


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