class AIXM::Component::Geometry::Circle
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 )
Attributes
center_xy[R]
@return [AIXM::XY] center point
radius[R]
@return [AIXM::D] circle radius
Public Class Methods
new(center_xy:, radius:)
click to toggle source
# File lib/aixm/component/geometry/circle.rb 29 def initialize(center_xy:, radius:) 30 self.center_xy, self.radius = center_xy, radius 31 end
Public Instance Methods
center_xy=(value)
click to toggle source
# File lib/aixm/component/geometry/circle.rb 38 def center_xy=(value) 39 fail(ArgumentError, "invalid center xy") unless value.is_a? AIXM::XY 40 @center_xy = value 41 end
inspect()
click to toggle source
@return [String]
# File lib/aixm/component/geometry/circle.rb 34 def inspect 35 %Q(#<#{self.class} center_xy="#{center_xy}" radius="#{radius.to_s}">) 36 end
radius=(value)
click to toggle source
# File lib/aixm/component/geometry/circle.rb 43 def radius=(value) 44 fail(ArgumentError, "invalid radius") unless value.is_a?(AIXM::D) && value.dist > 0 45 @radius = value 46 end
to_xml()
click to toggle source
@return [String] AIXM
or OFMX markup
# File lib/aixm/component/geometry/circle.rb 49 def to_xml 50 builder = Builder::XmlMarkup.new(indent: 2) 51 builder.Avx do |avx| 52 avx.codeType('CWA') 53 avx.geoLat(north_xy.lat(AIXM.schema)) 54 avx.geoLong(north_xy.long(AIXM.schema)) 55 avx.codeDatum('WGE') 56 avx.geoLatArc(center_xy.lat(AIXM.schema)) 57 avx.geoLongArc(center_xy.long(AIXM.schema)) 58 end 59 end
Private Instance Methods
north_xy()
click to toggle source
Coordinates of the point which is both strictly north of the center and on the circumference of the circle.
# File lib/aixm/component/geometry/circle.rb 65 def north_xy 66 AIXM.xy( 67 lat: center_xy.lat + radius.to_km.dist / (AIXM::XY::EARTH_RADIUS / 1000) * 180 / Math::PI, 68 long: center_xy.long 69 ) 70 end