Class: VORuby::STC::V1_30::TimeCoordinateType

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

Overview

Time coordinate type; sibling of BasicCoordinateType. Single Error, Resolution, Size, PixSize elements indicate definite values; pairs indicate ranges.

Direct Known Subclasses

Time

Instance Attribute Summary collapse

Attributes inherited from CoordinateType

#frame_id, #name

Attributes included from STCReference

#id, #idref, #ucd, #xlink_href, #xlink_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CoordinateType

coordinate_from_xml

Methods inherited from STCBaseType

stc_base_from_xml

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ TimeCoordinateType

Returns a new instance of TimeCoordinateType.



1636
1637
1638
1639
# File 'lib/voruby/stc/1.30/stc.rb', line 1636

def initialize(options={})
  options[:unit] ||= TimeUnitType.new('s')
  super(options)
end

Instance Attribute Details

#coord_system_idObject

Returns the value of attribute coord_system_id.



1633
1634
1635
# File 'lib/voruby/stc/1.30/stc.rb', line 1633

def coord_system_id
  @coord_system_id
end

#errorObject

Returns the value of attribute error.



1633
1634
1635
# File 'lib/voruby/stc/1.30/stc.rb', line 1633

def error
  @error
end

#pix_sizeObject

Returns the value of attribute pix_size.



1633
1634
1635
# File 'lib/voruby/stc/1.30/stc.rb', line 1633

def pix_size
  @pix_size
end

#resolutionObject

Returns the value of attribute resolution.



1633
1634
1635
# File 'lib/voruby/stc/1.30/stc.rb', line 1633

def resolution
  @resolution
end

#sizeObject

Returns the value of attribute size.



1633
1634
1635
# File 'lib/voruby/stc/1.30/stc.rb', line 1633

def size
  @size
end

#time_instantObject

Returns the value of attribute time_instant.



1633
1634
1635
# File 'lib/voruby/stc/1.30/stc.rb', line 1633

def time_instant
  @time_instant
end

#unitObject

Returns the value of attribute unit.



1633
1634
1635
# File 'lib/voruby/stc/1.30/stc.rb', line 1633

def unit
  @unit
end

Class Method Details

.from_xml(xml) ⇒ Object



1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
# File 'lib/voruby/stc/1.30/stc.rb', line 1721

def self.from_xml(xml)
  root = element_from(xml)
  
  options = CoordinateType.coordinate_from_xml(root)
  
  time_instant = REXML::XPath.first(root, 'x:TimeInstant', {'x' => obj_ns.uri})
  options[:time_instant] = AstronTimeType.from_xml(time_instant) if time_instant
  
  error = REXML::XPath.match(root, 'x:Error', {'x' => obj_ns.uri})
  options[:error] = ErrorList.new(error.collect{ |e| Error.from_xml(e) }) if error
  options[:error] = nil if options[:error].size == 0
  
  resolution = REXML::XPath.match(root, 'x:Resolution', {'x' => obj_ns.uri})
  options[:resolution] = ResolutionList.new(resolution.collect{ |r| Resolution.from_xml(r) }) if resolution
  options[:resolution] = nil if options[:resolution].size == 0
  
  size = REXML::XPath.match(root, 'x:Size', {'x' => obj_ns.uri})
  options[:size] = SizeList.new(size.collect{ |s| Size.from_xml(s) }) if size
  options[:size] = nil if options[:size].size == 0
  
  pix_size = REXML::XPath.match(root, 'x:PixSize', {'x' => obj_ns.uri})
  options[:pix_size] = PixSizeList.new(pix_size.collect{ |p| PixSize.from_xml(p) }) if pix_size
  options[:pix_size] = nil if options[:pix_size].size == 0
  
  coord_system_id = root.attributes.get_attribute_ns(obj_ns.uri, 'coord_system_id')
  options[:coord_system_id] = IdRef.new(coord_system_id.value) if coord_system_id
  
  unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options[:unit] = TimeUnitType.new(unit.value) if unit
  
  self.new(options)
end

Instance Method Details

#==(c) ⇒ Object



1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
# File 'lib/voruby/stc/1.30/stc.rb', line 1694

def ==(c)
  super(c) and
  self.time_instant == c.time_instant and
  self.error == c.error and
  self.resolution == c.resolution and
  self.size == c.size and
  self.pix_size == c.pix_size and
  self.coord_system_id == c.coord_system_id and
  self.unit == c.unit
end

#to_xml(name = nil) ⇒ Object



1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
# File 'lib/voruby/stc/1.30/stc.rb', line 1705

def to_xml(name=nil)
  el = super(name)
  
  el.add_element(self.time_instant.to_xml('TimeInstant')) if self.time_instant
  self.error.each{ |e| el.add_element(e.to_xml) } if self.error
  self.resolution.each{ |r| el.add_element(r.to_xml) } if self.resolution
  self.size.each{ |s| el.add_element(s.to_xml) } if self.size
  self.pix_size.each{ |p| el.add_element(p.to_xml) } if self.pix_size
  
  el.attributes["#{obj_ns.prefix}:coord_system_id"] = self.coord_system_id.to_s if self.coord_system_id
  el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s if self.unit
  
  collapse_namespaces(el)
  el
end