Class: VORuby::STC::V1_30::GeodType

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

Overview

The Geodetic reference frame; semi-major axis and inverse flattening may be provided to define the reference spheroid; the default is the IAU 1976 reference spheroid.

Direct Known Subclasses

GEO_D

Instance Attribute Summary collapse

Attributes inherited from CoordRefFrameType

#name, #ref_frame_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IcrsType

icrs_from_xml

Methods inherited from SpaceRefFrameType

space_ref_frame_from_xml

Methods inherited from CoordRefFrameType

coord_ref_frame_from_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(radius, inv_flattening, unit, ref_frame_id, name = nil) ⇒ GeodType

Returns a new instance of GeodType.



6537
6538
6539
6540
6541
6542
# File 'lib/voruby/stc/1.30/stc.rb', line 6537

def initialize(radius, inv_flattening, unit, ref_frame_id, name=nil)
  super(ref_frame_id, name)
  self.radius = radius || 6378140
  self.inv_flattening = inv_flattening || 298.257
  self.unit = unit || PosUnitType.new('m')
end

Instance Attribute Details

#inv_flatteningObject

Returns the value of attribute inv_flattening.



6535
6536
6537
# File 'lib/voruby/stc/1.30/stc.rb', line 6535

def inv_flattening
  @inv_flattening
end

#radiusObject

Returns the value of attribute radius.



6535
6536
6537
# File 'lib/voruby/stc/1.30/stc.rb', line 6535

def radius
  @radius
end

#unitObject

Returns the value of attribute unit.



6535
6536
6537
# File 'lib/voruby/stc/1.30/stc.rb', line 6535

def unit
  @unit
end

Class Method Details

.from_xml(xml) ⇒ Object



6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
# File 'lib/voruby/stc/1.30/stc.rb', line 6577

def self.from_xml(xml)
  root = element_from(xml)
  
  name = REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri})
  radius = root.attributes.get_attribute_ns(obj_ns.uri, 'radius')
  inv_flattening = root.attributes.get_attribute_ns(obj_ns.uri, 'inv_flattening')
  unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  
  self.new(
    radius ? Float(radius.value) : nil,
    inv_flattening ? Float(inv_flattening.value) : nil,
    unit ? PosUnitType.new(unit.value) : nil,
    *IcrsType.icrs_from_xml(root)
  )
end

Instance Method Details

#==(g) ⇒ Object



6560
6561
6562
6563
6564
6565
# File 'lib/voruby/stc/1.30/stc.rb', line 6560

def ==(g)
  super(g) and
  self.radius == g.radius and
  self.inv_flattening == g.inv_flattening and
  self.unit == g.unit
end

#to_xml(name = nil) ⇒ Object



6567
6568
6569
6570
6571
6572
6573
6574
6575
# File 'lib/voruby/stc/1.30/stc.rb', line 6567

def to_xml(name=nil)
  el = super(name)
  
  el.attributes["#{obj_ns.prefix}:radius"] = self.radius.to_s if self.radius
  el.attributes["#{obj_ns.prefix}:inv_flattening"] = self.inv_flattening.to_s if self.inv_flattening
  el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s if self.unit
  
  el
end