Class: AIXM::Feature::Obstacle

Inherits:
AIXM::Feature show all
Includes:
Association, Memoize
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
  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 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.

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

Constants inherited from AIXM::Feature

REGION_RE

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature

#region, #source

Instance Method Summary collapse

Methods included from Memoize

cache, included, method

Methods included from Association

included

Methods inherited from AIXM::Feature

#==

Constructor Details

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

Returns a new instance of Obstacle.


125
126
127
128
129
# File 'lib/aixm/feature/obstacle.rb', line 125

def initialize(source: nil, region: nil, name: nil, type:, xy:, z:, radius: nil)
  super(source: source, region: region)
  self.name, self.type, self.xy, self.z, self.radius = name, type, xy, z, radius
  @lighting = @marking = false
end

Instance Attribute Details

#heightAIXM::D?

Returns height from ground to top point.

Returns:

  • (AIXM::D, nil)

    height from ground to top point


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

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


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

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


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

def lighting
  @lighting
end

#lighting_remarksString?

Returns detailed description of the lighting.

Returns:

  • (String, nil)

    detailed description of the lighting


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

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


123
124
125
# File 'lib/aixm/feature/obstacle.rb', line 123

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


120
121
122
# File 'lib/aixm/feature/obstacle.rb', line 120

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


92
93
94
# File 'lib/aixm/feature/obstacle.rb', line 92

def marking
  @marking
end

#marking_remarksString?

Returns detailed description of the marking.

Returns:

  • (String, nil)

    detailed description of the marking


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

def marking_remarks
  @marking_remarks
end

#nameString

Returns full name.

Returns:

  • (String)

    full name


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

def name
  @name
end

#radiusAIXM::D

Returns circular base radius.

Returns:

  • (AIXM::D)

    circular base radius


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

def radius
  @radius
end

#remarksString?

Returns free text remarks.

Returns:

  • (String, nil)

    free text remarks


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

def remarks
  @remarks
end

#typeSymbol

Returns type of obstacle.

Returns:

  • (Symbol)

    type of obstacle


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

def type
  @type
end

#valid_fromTime, ...

Returns effective after this point in time.

Returns:

  • (Time, Date, String, nil)

    effective after this point in time


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

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


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

def valid_until
  @valid_until
end

#xyAIXM::XY

Returns circular base center point.

Returns:

  • (AIXM::XY)

    circular base center point


75
76
77
# File 'lib/aixm/feature/obstacle.rb', line 75

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


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

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


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

def z
  @z
end

#z_accuracyAIXM::D?

Returns margin of error for top point.

Returns:

  • (AIXM::D, nil)

    margin of error for top point


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

def z_accuracy
  @z_accuracy
end

Instance Method Details

#inspectString

Returns:

  • (String)

132
133
134
# File 'lib/aixm/feature/obstacle.rb', line 132

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


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

def linked?
  !!linked_to
end

#obstacle_groupAIXM::Feature::ObstacleGroup

Returns group this obstacle belongs to.

Returns:


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

belongs_to :obstacle_group

#to_uid(as: :ObsUid) ⇒ String

Returns UID markup.

Returns:

  • (String)

    UID markup


227
228
229
230
231
232
233
# File 'lib/aixm/feature/obstacle.rb', line 227

def to_uid(as: :ObsUid)
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.tag!(as, { region: (region if AIXM.ofmx?) }.compact) do |tag|
    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


237
238
239
240
241
242
243
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
# File 'lib/aixm/feature/obstacle.rb', line 237

def to_xml(delegate: true)
  return obstacle_group.to_xml if delegate && obstacle_group && 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 << obstacle_group.to_uid.indent(2) if obstacle_group && AIXM.ofmx?
    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(obstacle_group ? 'Y' : 'N') if AIXM.aixm?
    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 accuracy = (xy_accuracy || (obstacle_group&.xy_accuracy if AIXM.aixm?))
      obs.valGeoAccuracy(accuracy.dist.trim)
      obs.uomGeoAccuracy(accuracy.unit.upcase.to_s)
    end
    obs.valElev(z.alt)
    if accuracy = (z_accuracy || (obstacle_group&.z_accuracy if AIXM.aixm?))
      obs.valElevAccuracy(accuracy.to_ft.dist.round)
      obs.uomElevAccuracy('FT') if AIXM.ofmx?
    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 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