Class: VORuby::STC::V1_30::Cart2DRefFrameType

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

Cart2DRefFrame, Cart2DSpaceRefFrame

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

Returns a new instance of Cart2DRefFrameType.



6811
6812
6813
6814
6815
6816
# File 'lib/voruby/stc/1.30/stc.rb', line 6811

def initialize(transform, projection, ref_frame_id, options={})
  super(ref_frame_id, options[:name])
  self.transform = transform
  self.projection = projection || ProjectionType.new('')
  self.id = options[:id]
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6809
6810
6811
# File 'lib/voruby/stc/1.30/stc.rb', line 6809

def id
  @id
end

#projectionObject

Returns the value of attribute projection.



6809
6810
6811
# File 'lib/voruby/stc/1.30/stc.rb', line 6809

def projection
  @projection
end

#transformObject

Returns the value of attribute transform.



6809
6810
6811
# File 'lib/voruby/stc/1.30/stc.rb', line 6809

def transform
  @transform
end

Class Method Details

.from_xml(xml) ⇒ Object



6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
# File 'lib/voruby/stc/1.30/stc.rb', line 6858

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(
    xml_to_obj(root, CTransform2, true),
    projection ? ProjectionType.new(projection.value) : nil,
    rfi,
    {:name => name, :id => id ? Id.new(id.value) : nil}
  )
end

Instance Method Details

#==(c) ⇒ Object



6840
6841
6842
6843
6844
6845
# File 'lib/voruby/stc/1.30/stc.rb', line 6840

def ==(c)
  super(c) and
  self.transform == c.transform and
  self.projection == c.projection and
  self.id == c.id
end

#to_xml(name = nil) ⇒ Object



6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
# File 'lib/voruby/stc/1.30/stc.rb', line 6847

def to_xml(name=nil)
  el = super(name)
  
  el.add_element(self.transform.to_xml)
  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