Class: VORuby::STC::V1_30::SphereType

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

Overview

Defines a sphere. A special kind of area is a circle or sphere (in two or three dimensions), defined by a center position and a radius; the radius requires a unit.

Direct Known Subclasses

Sphere

Instance Attribute Summary collapse

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 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(radius, center, radius_unit = PosUnitType.new('deg'), lo_include = true, hi_include = true, options = {}) ⇒ SphereType

Returns a new instance of SphereType.



4651
4652
4653
4654
4655
4656
# File 'lib/voruby/stc/1.30/stc.rb', line 4651

def initialize(radius, center, radius_unit=PosUnitType.new('deg'), lo_include=true, hi_include=true, options={})
  self.radius = radius
  self.center = center
  self.radius_unit = radius_unit || PosUnitType.new('deg')
  super(lo_include, hi_include, options)
end

Instance Attribute Details

#centerObject

Returns the value of attribute center.



4649
4650
4651
# File 'lib/voruby/stc/1.30/stc.rb', line 4649

def center
  @center
end

#radiusObject

Returns the value of attribute radius.



4649
4650
4651
# File 'lib/voruby/stc/1.30/stc.rb', line 4649

def radius
  @radius
end

#radius_unitObject

Returns the value of attribute radius_unit.



4649
4650
4651
# File 'lib/voruby/stc/1.30/stc.rb', line 4649

def radius_unit
  @radius_unit
end

Class Method Details

.from_xml(xml) ⇒ Object



4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
# File 'lib/voruby/stc/1.30/stc.rb', line 4699

def self.from_xml(xml)
  root = element_from(xml)
  
  radius_unit = root.attributes.get_attribute_ns(obj_ns.uri, 'radius_unit')
  self.new(
    Double1Type.from_xml(REXML::XPath.first(root, 'x:Radius', {'x' => obj_ns.uri})),
    Double3Type.from_xml(REXML::XPath.first(root, 'x:Center', {'x' => obj_ns.uri})),
    radius_unit ? PosUnitType.new(radius_unit.value) : nil,
    *SpatialIntervalType.spatial_interval_from_xml(root)
  )
end

Instance Method Details

#==(s) ⇒ Object



4681
4682
4683
4684
4685
4686
# File 'lib/voruby/stc/1.30/stc.rb', line 4681

def ==(s)
  super(s) and
  self.radius == s.radius and
  self.center == s.center and
  self.radius_unit == s.radius_unit
end

#to_xml(name = nil) ⇒ Object



4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
# File 'lib/voruby/stc/1.30/stc.rb', line 4688

def to_xml(name=nil)
  el = super(name)
  
  el.attributes["#{obj_ns.prefix}:radius_unit"] = self.radius_unit.to_s if self.radius_unit
  el.add_element(self.radius.to_xml('Radius')) if self.radius
  el.add_element(self.center.to_xml('Center')) if self.center
  
  collapse_namespaces(el)
  el
end