Class: VORuby::STC::V1_10::STC::CustomSpaceRefFrameType

Inherits:
SpaceRefFrameType show all
Includes:
SerializableToXml
Defined in:
lib/voruby/stc/1.10/stc.rb

Overview

A custome space reference frame type Define coordinate reference frame from scratch; pole and X-axis need to be defined in a known coordinate system

Direct Known Subclasses

CustomSpaceRefFrame

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ CustomSpaceRefFrameType

Returns a new instance of CustomSpaceRefFrameType.



151
152
153
154
155
156
# File 'lib/voruby/stc/1.10/stc.rb', line 151

def initialize(options={})
  raise_argument_required_error('frame') if !options.has_key?(:frame)
  raise_argument_required_error('pole z axis') if !options.has_key?(:pole_zaxis)
  raise_argument_required_error('x axis') if !options.has_key?(:xaxis)
  options.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#frameObject

Returns the value of attribute frame.



149
150
151
# File 'lib/voruby/stc/1.10/stc.rb', line 149

def frame
  @frame
end

#pole_zaxisObject

Returns the value of attribute pole_zaxis.



149
150
151
# File 'lib/voruby/stc/1.10/stc.rb', line 149

def pole_zaxis
  @pole_zaxis
end

#xaxisObject

Returns the value of attribute xaxis.



149
150
151
# File 'lib/voruby/stc/1.10/stc.rb', line 149

def xaxis
  @xaxis
end

Class Method Details

.from_xml(xml) ⇒ Object



200
201
202
203
204
205
206
207
208
209
210
# File 'lib/voruby/stc/1.10/stc.rb', line 200

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
    :frame => REXML::XPath.first(root, 'x:Frame', {'x' => obj_ns.uri}).text,
    :pole_zaxis => AstroCoords.from_xml(REXML::XPath.first(root, 'x:Pole_Zaxis', {'x' => obj_ns.uri})),
    :xaxis => AstroCoords.from_xml(REXML::XPath.first(root, 'x:Xaxis', {'x' => obj_ns.uri}))
  }
  
  CustomSpaceRefFrameType.new(options)
end

Instance Method Details

#==(f) ⇒ Object



175
176
177
178
179
180
# File 'lib/voruby/stc/1.10/stc.rb', line 175

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

#to_xml(name = nil) ⇒ Object



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/voruby/stc/1.10/stc.rb', line 182

def to_xml(name=nil)
  el = element(name)
  
  coords_ns = NAMESPACES['VORuby::STC::V1_10::Coords']
  el.add_namespace(coords_ns.prefix, coords_ns.uri)
  
  frame = REXML::Element.new("#{obj_ns.prefix}:Frame")
  frame.text = self.frame
  el.add_element(frame)
  
  el.add_element(self.pole_zaxis.to_xml('Pole_Zaxis', obj_ns))
  el.add_element(self.xaxis.to_xml('Xaxis', obj_ns))
  
  collapse_namespaces(el)
  
  el
end