Class: VORuby::STC::V1_30::CircleType

Inherits:
ShapeType show all
Defined in:
lib/voruby/stc/1.30/stc.rb

Overview

Circle shape: center and radius.

Direct Known Subclasses

Circle, Circle2

Instance Attribute Summary collapse

Attributes inherited from RegionType

#area, #coord_system_id, #note

Attributes inherited from SpatialIntervalType

#epoch, #unit

Attributes inherited from CoordIntervalType

#fill_factor, #frame_id, #hi_include, #lo_include

Attributes included from STCReference

#id, #idref, #ucd, #xlink_href, #xlink_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ShapeType

shape_from_xml

Methods inherited from RegionType

region_from_xml

Methods inherited from SpatialIntervalType

spatial_interval_from_xml

Methods inherited from CoordIntervalType

coord_interval_from_xml, #hi_include?, #lo_include?

Methods inherited from STCBaseType

stc_base_from_xml

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(center, radius, area = nil, lo_include = true, hi_include = true, options = {}) ⇒ CircleType

Returns a new instance of CircleType.



5298
5299
5300
5301
5302
# File 'lib/voruby/stc/1.30/stc.rb', line 5298

def initialize(center, radius, area=nil, lo_include=true, hi_include=true, options={})
  super(area, lo_include, hi_include, options)
  self.center = center
  self.radius = radius
end

Instance Attribute Details

#centerObject

Returns the value of attribute center.



5296
5297
5298
# File 'lib/voruby/stc/1.30/stc.rb', line 5296

def center
  @center
end

#radiusObject

Returns the value of attribute radius.



5296
5297
5298
# File 'lib/voruby/stc/1.30/stc.rb', line 5296

def radius
  @radius
end

Class Method Details

.from_xml(xml) ⇒ Object



5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
# File 'lib/voruby/stc/1.30/stc.rb', line 5338

def self.from_xml(xml)
  root = element_from(xml)
  
  radius = REXML::XPath.first(root, 'x:Radius', {'x' => obj_ns.uri})
  self.new(
    Double2Type.from_xml(REXML::XPath.first(root, 'x:Center', {'x' => obj_ns.uri})),
    radius ? Double1Type.from_xml(REXML::XPath.first(root, 'x:Radius', {'x' => obj_ns.uri})) : nil,
    *ShapeType.shape_from_xml(root)
  )
end

Instance Method Details

#==(c) ⇒ Object



5318
5319
5320
5321
5322
# File 'lib/voruby/stc/1.30/stc.rb', line 5318

def ==(c)
  super(c) and
  self.center == c.center and
  self.radius == c.radius
end

#to_sObject



5334
5335
5336
# File 'lib/voruby/stc/1.30/stc.rb', line 5334

def to_s
  "CIRCLE #{self.coord_system_id || IdRef.new('J2000')} #{self.center} #{self.radius}"
end

#to_xml(name = nil) ⇒ Object



5324
5325
5326
5327
5328
5329
5330
5331
5332
# File 'lib/voruby/stc/1.30/stc.rb', line 5324

def to_xml(name=nil)
  el = super(name)
  
  el.add_element(self.center.to_xml('Center')) if self.center
  el.add_element(self.radius.to_xml('Radius')) if self.radius
  
  collapse_namespaces(el)
  el
end