Class: VORuby::STC::V1_30::Cart1DRefFrameType

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

Overview

A custom space reference frame type defined through a 2-D Cartesian mapping (rotate and scale).

Direct Known Subclasses

Cart1DSpaceRefFrame, ScalarRefFrame

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(scale, projection, ref_frame_id, options = {}) ⇒ Cart1DRefFrameType

Returns a new instance of Cart1DRefFrameType.



6739
6740
6741
6742
6743
6744
# File 'lib/voruby/stc/1.30/stc.rb', line 6739

def initialize(scale, projection, ref_frame_id, options={})
  super(ref_frame_id, options[:name])
  self.scale = scale
  self.projection = projection
  self.id = options[:id]
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6737
6738
6739
# File 'lib/voruby/stc/1.30/stc.rb', line 6737

def id
  @id
end

#projectionObject

Returns the value of attribute projection.



6737
6738
6739
# File 'lib/voruby/stc/1.30/stc.rb', line 6737

def projection
  @projection
end

#scaleObject

Returns the value of attribute scale.



6737
6738
6739
# File 'lib/voruby/stc/1.30/stc.rb', line 6737

def scale
  @scale
end

Class Method Details

.from_xml(xml) ⇒ Object



6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
# File 'lib/voruby/stc/1.30/stc.rb', line 6790

def self.from_xml(xml)
  root = element_from(xml)
  
  rfi, name = CoordRefFrameType.coord_ref_frame_from_xml(root)       
   
  id = root.attributes.get_attribute_ns(obj_ns.uri, 'id')
  projection = root.attributes.get_attribute_ns(obj_ns.uri, 'projection')
  
  self.new(
    Double1Type.from_xml(REXML::XPath.first(root, 'x:Scale', {'x' => obj_ns.uri})),
    projection ? ProjectionType.new(projection.value) : nil,
    rfi,
    {:name => name, :id => id ? Id.new(id.value) : nil}
  )
end

Instance Method Details

#==(r) ⇒ Object



6772
6773
6774
6775
6776
6777
# File 'lib/voruby/stc/1.30/stc.rb', line 6772

def ==(r)
  super(r) and
  self.scale == r.scale and
  self.projection == r.projection and
  self.id == r.id
end

#to_xml(name = nil) ⇒ Object



6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
# File 'lib/voruby/stc/1.30/stc.rb', line 6779

def to_xml(name=nil)
  el = super(name)
  
  el.add_element(self.scale.to_xml('Scale'))
  el.attributes["#{obj_ns.prefix}:id"] = self.id.to_s if self.id
  el.attributes["#{obj_ns.prefix}:projection"] = self.projection.to_s if self.projection
  
  collapse_namespaces(el)
  el
end