Class: AIXM::Component::Geometry::Arc

Inherits:
Point
  • Object
show all
Defined in:
lib/aixm/component/geometry/arc.rb

Overview

Arcs are clockwise or counter clockwise circle segments around a #center_xy and starting at Point#xy.

Cheat Sheet in Pseudo Code:

arc = AIXM.arc(
  xy: AIXM.xy
  center_xy: AIXM.xy
  clockwise: true or false
)

Instance Attribute Summary collapse

Attributes inherited from Point

#xy

Instance Method Summary collapse

Constructor Details

#initialize(xy:, center_xy:, clockwise:) ⇒ Arc

Returns a new instance of Arc


22
23
24
25
# File 'lib/aixm/component/geometry/arc.rb', line 22

def initialize(xy:, center_xy:, clockwise:)
  super(xy: xy)
  self.center_xy, self.clockwise = center_xy, clockwise
end

Instance Attribute Details

#center_xyAIXM::XY

Returns center point

Returns:


20
21
22
# File 'lib/aixm/component/geometry/arc.rb', line 20

def center_xy
  @center_xy
end

#clockwise=(value) ⇒ Boolean (writeonly)

Returns wheter the arc is going clockwise (true) or not (false)

Returns:

  • (Boolean)

    wheter the arc is going clockwise (true) or not (false)


39
40
41
# File 'lib/aixm/component/geometry/arc.rb', line 39

def clockwise?
  @clockwise
end

Instance Method Details

#clockwise?Boolean

Returns wheter the arc is going clockwise (true) or not (false)

Returns:

  • (Boolean)

    wheter the arc is going clockwise (true) or not (false)


39
40
41
# File 'lib/aixm/component/geometry/arc.rb', line 39

def clockwise?
  @clockwise
end

#inspectString

Returns:

  • (String)

28
29
30
# File 'lib/aixm/component/geometry/arc.rb', line 28

def inspect
  %Q(#<#{self.class} xy="#{xy.to_s}">)
end

#to_xmlString

Returns AIXM or OFMX markup

Returns:

  • (String)

    AIXM or OFMX markup


49
50
51
52
53
54
55
56
57
58
59
# File 'lib/aixm/component/geometry/arc.rb', line 49

def to_xml
  builder = Builder::XmlMarkup.new(indent: 2)
  builder.Avx do |avx|
    avx.codeType(clockwise? ? 'CWA' : 'CCA')
    avx.geoLat(xy.lat(AIXM.schema))
    avx.geoLong(xy.long(AIXM.schema))
    avx.codeDatum('WGE')
    avx.geoLatArc(center_xy.lat(AIXM.schema))
    avx.geoLongArc(center_xy.long(AIXM.schema))
  end
end