Class: VORuby::STC::V1_30::SphericalRefFrameType

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

Overview

A custom space reference frame type defined through pole and X-axis directions.

Direct Known Subclasses

SphericalRefFrame, SphericalSpaceRefFrame

Instance Attribute Summary collapse

Attributes inherited from CoordRefFrameType

#name, #ref_frame_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CoordRefFrameType

coord_ref_frame_from_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(frame, pole_zaxis, xaxis, ref_frame_id, options = {}) ⇒ SphericalRefFrameType

Returns a new instance of SphericalRefFrameType.



6598
6599
6600
6601
6602
6603
6604
# File 'lib/voruby/stc/1.30/stc.rb', line 6598

def initialize(frame, pole_zaxis, xaxis, ref_frame_id, options={})
  super(ref_frame_id, options[:name])
  self.frame = frame
  self.pole_zaxis = pole_zaxis
  self.xaxis = xaxis
  self.id = options[:id]
end

Instance Attribute Details

#frameObject

Returns the value of attribute frame.



6596
6597
6598
# File 'lib/voruby/stc/1.30/stc.rb', line 6596

def frame
  @frame
end

#idObject

Returns the value of attribute id.



6596
6597
6598
# File 'lib/voruby/stc/1.30/stc.rb', line 6596

def id
  @id
end

#pole_zaxisObject

Returns the value of attribute pole_zaxis.



6596
6597
6598
# File 'lib/voruby/stc/1.30/stc.rb', line 6596

def pole_zaxis
  @pole_zaxis
end

#xaxisObject

Returns the value of attribute xaxis.



6596
6597
6598
# File 'lib/voruby/stc/1.30/stc.rb', line 6596

def xaxis
  @xaxis
end

Class Method Details

.from_xml(xml) ⇒ Object



6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
# File 'lib/voruby/stc/1.30/stc.rb', line 6653

def self.from_xml(xml)
  root = element_from(xml)
  
  pz = REXML::XPath.first(root, 'x:Pole_Zaxis', {'x' => obj_ns.uri})
  xa = REXML::XPath.first(root, 'x:Xaxis', {'x' => obj_ns.uri})
  
  rfi, name = CoordRefFrameType.coord_ref_frame_from_xml(root)
  
  id = root.attributes.get_attribute_ns(obj_ns.uri, 'id')
  options = {:name => name, :id => id ? Id.new(id.value) : nil}
  
  self.new(
    REXML::XPath.first(root, 'x:Frame', {'x' => obj_ns.uri}).text,
    pz ? AstroCoordsType.from_xml(pz) : nil,
    xa ? AstroCoordsType.from_xml(xa) : nil,
    rfi,
    options
  )
end

Instance Method Details

#==(f) ⇒ Object



6629
6630
6631
6632
6633
6634
6635
# File 'lib/voruby/stc/1.30/stc.rb', line 6629

def ==(f)
  super(f) and
  self.frame == f.frame and
  self.pole_zaxis == f.pole_zaxis and
  self.xaxis == f.xaxis and
  self.id == f.id
end

#to_xml(name = nil) ⇒ Object



6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
# File 'lib/voruby/stc/1.30/stc.rb', line 6637

def to_xml(name=nil)
  el = super(name)
  
  frame_el = REXML::Element.new("#{obj_ns.prefix}:Frame")
  frame_el.text = self.frame
  el.add_element(frame_el)
  
  el.add_element(self.pole_zaxis.to_xml('Pole_Zaxis')) if self.pole_zaxis
  el.add_element(self.xaxis.to_xml('Xaxis')) if self.xaxis
  
  el.attributes["#{obj_ns.prefix}:id"] = self.id.to_s if self.id
  
  collapse_namespaces(el)
  el
end