Class: AIXM::Component::Geometry::Circle

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

Overview

Circles are defined by a #center_xy and a #radius.

Cheat Sheet in Pseudo Code:

circle = AIXM.circle(
  center_xy: AIXM.xy
  radius: AIXM.d
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(center_xy:, radius:) ⇒ Circle


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

def initialize(center_xy:, radius:)
  self.center_xy, self.radius = center_xy, radius
end

Instance Attribute Details

#center_xyAIXM::XY


18
19
20
# File 'lib/aixm/component/geometry/circle.rb', line 18

def center_xy
  @center_xy
end

#radiusAIXM::D


21
22
23
# File 'lib/aixm/component/geometry/circle.rb', line 21

def radius
  @radius
end

Instance Method Details

#inspectString


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

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

#to_xmlString


43
44
45
46
47
48
49
50
51
52
53
# File 'lib/aixm/component/geometry/circle.rb', line 43

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